model = new CurrencyModel(); } public function datalist() { if (request()->isAjax()) { $param = get_params(); $where = [['delete_time', '=', 0]]; if (!empty($param['keywords'])) { $where[] = ['code|title', 'like', '%' . $param['keywords'] . '%']; } $list = $this->model->where($where)->order('sort asc, id asc')->select(); return to_assign(0, '', $list); } return view(); } public function add() { $param = get_params(); if (request()->isAjax()) { if (empty($param['code'])) { return to_assign(1, '币种代码不能为空'); } if (empty($param['title'])) { return to_assign(1, '币种名称不能为空'); } if (!empty($param['id']) && $param['id'] > 0) { return $this->model->edit($param); } return $this->model->add($param); } $id = isset($param['id']) ? (int) $param['id'] : 0; if ($id > 0) { View::assign('detail', $this->model->getById($id)); } return view(); } public function set() { if (request()->isAjax()) { $param = get_params(); $res = $this->model->strict(false)->field('id,status')->update($param); if ($res) { add_log($param['status'] == 1 ? 'recovery' : 'disable', $param['id'], $param); return to_assign(); } return to_assign(0, '操作失败'); } return to_assign(1, '错误的请求'); } public function del() { if (request()->isDelete()) { $param = get_params(); $id = isset($param['id']) ? (int) $param['id'] : 0; return $this->model->delById($id); } return to_assign(1, '错误的请求'); } }