123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <?php
- namespace app\admin\controller\sys_manage;
- use app\admin\service\sys_manage\ConfigService;
- use app\admin\validate\sys_manage\ConfigValidate;
- use app\model\SysConfig;
- use support\Request;
- class ConfigController
- {
- /**
- * @Desc 配置列表
- * @Author Gorden
- * @Date 2024/2/22 16:35
- *
- * @param Request $request
- * @return \support\Response
- */
- public function configList(Request $request)
- {
- return ConfigService::configList($request);
- }
- /**
- * @Desc 配置详情
- * @Author Gorden
- * @Date 2024/2/22 16:36
- *
- * @param $id
- * @return \support\Response
- */
- public function configInfo($id)
- {
- return ConfigService::configInfo($id);
- }
- /**
- * @Desc 添加配置
- * @Author Gorden
- * @Date 2024/2/22 15:57
- *
- * @param Request $request
- * @return \support\Response
- */
- public function addConfig(Request $request)
- {
- $validate = new ConfigValidate();
- if (!$validate->scene('add')->check($request->post())) {
- return json_fail($validate->getError());
- }
- return ConfigService::addConfig($request->post());
- }
- /**
- * @Desc 修改配置
- * @Author Gorden
- * @Date 2024/2/22 16:24
- *
- * @param $id
- * @param Request $request
- * @return \support\Response
- */
- public function updateConfig($id, Request $request)
- {
- $validate = new ConfigValidate();
- if (!$validate->scene('update')->check($request->post())) {
- return json_fail($validate->getError());
- }
- return ConfigService::updateConfig($id, $request->post());
- }
- /**
- * @Desc 修改配置状态
- * @Author Gorden
- * @Date 2024/2/22 16:38
- *
- * @param $id
- * @param Request $request
- * @return \support\Response
- */
- public function updateStatus($id, Request $request)
- {
- $validate = new ConfigValidate();
- if (!$validate->scene('update_status')->check($request->post())) {
- return json_fail($validate->getError());
- }
- return ConfigService::updateStatus($id, $request->post());
- }
- /**
- * @Desc 删除配置
- * @Author Gorden
- * @Date 2024/2/22 16:39
- *
- * @param $id
- * @return \support\Response
- */
- public function delConfig(Request $request)
- {
- return ConfigService::delConfig($request);
- }
- public function bottomMenuList()
- {
- $config = SysConfig::where('config_name', 'APP底部菜单')->first()->toArray();
- return json_success('', json_decode($config['config_value_json']));
- }
- public function bottomMenuSave(Request $request)
- {
- try {
- SysConfig::where('config_name', 'APP底部菜单')->update(['config_value_json' => json_encode($request->post())]);
- return json_success('success');
- } catch (\Exception $e) {
- return json_fail('APP底部菜单保存失败');
- }
- }
- public function navMenuList()
- {
- $config = SysConfig::where('config_name', 'APP导航菜单')->first()->toArray();
- return json_success('', json_decode($config['config_value_json']));
- }
- public function navMenuSave(Request $request)
- {
- try {
- SysConfig::where('config_name', 'APP导航菜单')->update(['config_value_json' => json_encode($request->post())]);
- return json_success('success');
- } catch (\Exception $e) {
- return json_fail('APP底部菜单保存失败');
- }
- }
- public function paramsList(Request $request)
- {
- $type = $request->get('type', '');
- return ConfigService::getParams($this->getType($type));
- }
- public function paramsSave(Request $request)
- {
- return ConfigService::paramsSave($request, $this->getType($request->post('type', '')));
- }
- private function getType($type)
- {
- switch ($type) {
- case 'sys':
- return 'sys';
- break;
- case 'pay':
- return 'app-pay-unionpay';
- break;
- case 'msg':
- return 'app-sms-aliyun';
- break;
- case 'face':
- return 'app-face-aliyun';
- break;
- case 'ocr':
- return 'app-cert-ocr-aliyun';
- break;
- case 'ws':
- return 'app-websocket';
- break;
- case 'shortcutMenu':
- return 'app-menu-shortcut';
- break;
- case 'navigationMenu':
- return 'app-menu-navigation';
- break;
- case 'footerMenu':
- return 'app-menu-footer';
- break;
- default:
- return '';
- break;
- }
- }
- }
|