DictService.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\DictModel;
  13. /**
  14. * 字典-服务类
  15. * @author wesmiler
  16. * @since 2020/11/11
  17. * Class DictService
  18. * @package App\Services
  19. */
  20. class DictService extends BaseService
  21. {
  22. /**
  23. * 构造函数
  24. * @author wesmiler
  25. * @since 2020/11/11
  26. * DictService constructor.
  27. */
  28. public function __construct()
  29. {
  30. $this->model = new DictModel();
  31. }
  32. /**
  33. * 获取字典列表
  34. * @return array
  35. * @since 2020/11/11
  36. * @author wesmiler
  37. */
  38. public function getList()
  39. {
  40. $param = request()->all();
  41. // 查询条件
  42. $map = [];
  43. // 字典类型ID
  44. $dicttypeId = getter($param, "dicttypeId", 0);
  45. if ($dicttypeId) {
  46. $map[] = ['dicttype_id', '=', $dicttypeId];
  47. }
  48. // 字典名称
  49. $name = getter($param, "name");
  50. if ($name) {
  51. $map[] = ['name', 'like', "%{$name}%"];
  52. }
  53. // 字典编码
  54. $code = getter($param, 'code');
  55. if ($code) {
  56. $map[] = ['code', '=', $code];
  57. }
  58. $list = $this->model->getList($map, [['sort', 'asc']]);
  59. return message("操作成功", true, $list);
  60. }
  61. }