| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services\Common;
- use App\Models\ConfigModel;
- use App\Services\BaseService;
- use App\Services\RedisService;
- /**
- * 配置管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class ConfigService
- * @package App\Services\Common
- */
- class ConfigService extends BaseService
- {
- /**
- * 构造函数
- * @author laravel开发员
- * @since 2020/11/11
- * ConfigService constructor.
- */
- public function __construct()
- {
- $this->model = new ConfigModel();
- }
- /**
- * 获取配置列表
- * @return array
- * @since 2020/11/11
- * @author laravel开发员
- */
- public function getList()
- {
- $param = request()->all();
- // 查询条件
- $map = [];
- // 配置分组ID
- $configgroupId = getter($param, "configgroupId", 0);
- if ($configgroupId) {
- $map[] = ['config_group_id', '=', $configgroupId];
- }
- // 配置标题
- $title = getter($param, "title");
- if ($title) {
- $map[] = ['name', 'title', "%{$title}%"];
- }
- $list = $this->model->getList($map, [['sort', 'asc']]);
- return message("操作成功", true, $list);
- }
- /**
- * 编辑
- * @return array
- */
- public function edit()
- {
- $data = request()->all();
- $data['value'] = isset($data['value'])? $data['value'] :'';
- $code = isset($data['code'])? $data['code'] :'';
- $image = isset($data['value']) && !is_array($data['value'])? trim($data['value']) : '';
- if ($image &&strpos($image, "uploads")){
- $data['value'] = get_image_path($image);
- }
- $type = isset($data['type']) && $data['type']? trim($data['type']) : 'text';
- if($type == 'daterange'){
- $data['value'] = isset($data['value']) && !is_array($data['value'])? trim($data['value']) : json_encode($data['value'],256);
- }
- if($type == 'price'){
- $data['value'] = $data['value']? str_replace(['|','-',':'],['|','-',':'], $data['value']) : '';
- }
- if(isset($data['options_value'])){
- unset($data['options_value']);
- }
- $data['options'] = isset($data['options'])? $data['options'] :'';
- RedisService::keyDel("caches:config:app*");
- RedisService::keyDel("caches:config:groups:5");
- RedisService::keyDel(env('APP_NAME')."_cache:*");
- if($code){
- RedisService::keyDel("caches:config:code:{$code}");
- }
- return parent::edit($data); // TODO: Change the autogenerated stub
- }
- }
|