DevicesService.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Laravel框架 [ Laravel ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 南京Laravel研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: wesmiler <12345678@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services;
  12. use App\Models\DevicesModel;
  13. /**
  14. * 供灯设备管理-服务类
  15. * @author wesmiler
  16. * @since 2020/11/11
  17. * Class DevicesService
  18. * @package App\Services
  19. */
  20. class DevicesService extends BaseService
  21. {
  22. /**
  23. * 构造函数
  24. * @author wesmiler
  25. * @since 2020/11/11
  26. * DevicesService constructor.
  27. */
  28. public function __construct()
  29. {
  30. $this->model = new DevicesModel();
  31. }
  32. /**
  33. * 获取友链列表
  34. * @return array
  35. * @since 2020/11/11
  36. * @author wesmiler
  37. */
  38. public function getList()
  39. {
  40. $params = request()->all();
  41. return parent::getList();
  42. }
  43. /**
  44. * 添加或编辑
  45. * @return array
  46. * @since 2020/11/11
  47. * @author wesmiler
  48. */
  49. public function edit()
  50. {
  51. $data = request()->all();
  52. $code = isset($data['code'])? $data['code'] : '';
  53. $id = isset($data['id'])? $data['id'] : 0;
  54. if($code && $checkId = $this->model->where('code', $code)->value('id')){
  55. if(($checkId && !$id) || ($id && $checkId != $id) ){
  56. return message("设备编号[{$code}]已存在",false);
  57. }
  58. }
  59. $startNum = isset($data['start_num'])? $data['start_num'] : 0;
  60. $endNum = isset($data['end_num'])? $data['end_num'] : 0;
  61. if($endNum<=$startNum){
  62. return message("截止可选灯号必须大于开始可选灯号",false);
  63. }
  64. $data['update_time'] = time();
  65. return parent::edit($data); // TODO: Change the autogenerated stub
  66. }
  67. }