ConfigService.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services\Common;
  12. use App\Models\ConfigModel;
  13. use App\Services\BaseService;
  14. /**
  15. * 配置管理-服务类
  16. * @author laravel开发员
  17. * @since 2020/11/11
  18. * Class ConfigService
  19. * @package App\Services\Common
  20. */
  21. class ConfigService extends BaseService
  22. {
  23. /**
  24. * 构造函数
  25. * @author laravel开发员
  26. * @since 2020/11/11
  27. * ConfigService constructor.
  28. */
  29. public function __construct()
  30. {
  31. $this->model = new ConfigModel();
  32. }
  33. /**
  34. * 获取配置列表
  35. * @return array
  36. * @since 2020/11/11
  37. * @author laravel开发员
  38. */
  39. public function getList()
  40. {
  41. $param = request()->all();
  42. // 查询条件
  43. $map = [];
  44. // 配置分组ID
  45. $configgroupId = getter($param, "configgroupId", 0);
  46. if ($configgroupId) {
  47. $map[] = ['config_group_id', '=', $configgroupId];
  48. }
  49. // 配置标题
  50. $title = getter($param, "title");
  51. if ($title) {
  52. $map[] = ['name', 'title', "%{$title}%"];
  53. }
  54. $list = $this->model->getList($map, [['sort', 'asc']]);
  55. return message("操作成功", true, $list);
  56. }
  57. /**
  58. * 编辑
  59. * @return array
  60. */
  61. public function edit()
  62. {
  63. $data = request()->all();
  64. $image = isset($data['value']) && !is_array($data['value'])? trim($data['value']) : '';
  65. if ($image &&strpos($image, "temp")) {
  66. $data['value'] = save_image($image, '');
  67. } else if($image &&strpos($image, "uploads")){
  68. $data['value'] = get_image_path($image);
  69. }
  70. $type = isset($data['type']) && $data['type']? trim($data['type']) : 'text';
  71. if($type == 'daterange'){
  72. $data['value'] = isset($data['value']) && !is_array($data['value'])? trim($data['value']) : json_encode($data['value'],256);
  73. }
  74. return parent::edit($data); // TODO: Change the autogenerated stub
  75. }
  76. }