load->model('market/Market_sys_dictionary_model', 'mdSysDictionary'); } /** * Notes:获取字典 * Created on: 2022/9/19 11:11 * Created by: dengbw */ public function index_get() { $dictCode = $this->input_param('dictCode'); $where['status>='] = 0; $dictCode && $where['dictCode like "%' . $dictCode . '%"'] = null; $sort_order = 'sortNumber asc,dictId desc'; $res = $this->mdSysDictionary->select($where, $sort_order); foreach ($res as $k => $v) { $res[$k]['dictId'] = intval($v['dictId']); } $this->return_response_list($res); } /** * Notes:添加字典 * Created on: 2022/9/19 11:01 * Created by: dengbw */ public function index_post() { $dictName = $this->input_param('dictName'); $dictCode = $this->input_param('dictCode'); $sortNumber = intval($this->input_param('sortNumber')); $comments = $this->input_param('comments'); if (!$dictName) { $this->return_json('请输入字典名称'); } if (!$dictCode) { $this->return_json('请输入字典值'); } !$comments && $comments = ''; $addDate = ['dictName' => $dictName, 'dictCode' => $dictCode, 'sortNumber' => $sortNumber, 'comments' => $comments , 'createTime' => date('Y-m-d H:i:s')]; $id = $this->mdSysDictionary->add($addDate); if (!$id) { $this->return_json('添加字典失败'); } $this->return_response(); } /** * Notes:修改字典 * Created on: 2022/9/19 11:05 * Created by: dengbw */ public function index_put() { $dictId = intval($this->input_param('dictId')); $dictName = $this->input_param('dictName'); $dictCode = $this->input_param('dictCode'); $sortNumber = intval($this->input_param('sortNumber')); $comments = $this->input_param('comments'); if (!$dictId) { $this->return_json('参数错误'); } if (!$dictName) { $this->return_json('请输入字典名称'); } if (!$dictCode) { $this->return_json('请输入字典值'); } !$comments && $comments = ''; $upDate = ['dictName' => $dictName, 'dictCode' => $dictCode, 'sortNumber' => $sortNumber, 'comments' => $comments]; $this->mdSysDictionary->update($upDate, ['dictId' => $dictId]); $this->return_response(); } /** * Notes:删除字典 * Created on: 2022/9/19 11:08 * Created by: dengbw * @param null $dictId */ public function index_delete($dictId = null) { $dictId = intval($dictId); if (!$dictId) { $this->return_json('参数错误'); } $this->mdSysDictionary->update(['status' => -1], ['dictId' => $dictId]); $this->return_response(); } /** * Notes:批量删除字典 * Created on: 2022/10/21 17:11 * Created by: dengbw */ public function batch_delete() { $ids = $this->input_param('ids'); if (!$ids) { $this->return_json('参数错误'); } $str_ids = implode(',', $ids); if ($str_ids) { $this->mdSysDictionary->update(['status' => -1], ["dictId in($str_ids)" => null]); } $this->return_response(); } }