123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace app\admin\controller\sys_manage;
- use app\controller\Curd;
- use app\model\Content;
- use support\exception\BusinessException;
- use support\Request;
- use support\Response;
- class FinanceController extends Curd
- {
- public function __construct()
- {
- $this->model = new Content();
- }
- public function info(Request $request): Response
- {
- $data = $this->model->where('content_category', 'FINANCE')->first();
- if (!empty($data->content_config_json)){
- $data->content_config_json = json_decode($data->content_config_json);
- }
- return json_success('', $data);
- }
- protected function updateInput(Request $request): array
- {
- $primary_key = $this->model->getKeyName();
- $id = $request->post($primary_key);
- $params = $request->post();
- if (is_array($params['content_config_json'])){
- $params['content_config_json'] = json_encode(array_filter($params['content_config_json'],function ($value){
- return ($value != '' && $value != ' ' && $value != null);
- }), JSON_UNESCAPED_UNICODE);
- }
- $data = $this->inputFilter($params);
- $model = $this->model->find($id);
- if (!$model) {
- throw new BusinessException('记录不存在', 2);
- }
- unset($data[$primary_key]);
- return [$id, $data];
- }
- }
|