request->post('type'); if ($type) { $where['type'] = $type; } $model = new IdentityModel(); $list = $model->getList($where); return $this->renderSuccess(compact('list')); } /** * @notes:新增 * @return Json * @author: wanghousheng */ public function add(): Json { $data = $this->postForm(); if (!$data) { return $this->renderError('缺少必要参数'); } $model = new IdentityModel(); if ($model->add($data)) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } /** * @notes:编辑 * @param int $identityId * @return Json * @author: wanghousheng */ public function edit(int $identityId): Json { $data = $this->postForm(); if (!$data) { return $this->renderError('缺少必要参数'); } $model = IdentityModel::detail($identityId); if ($model->edit($data)) { return $this->renderSuccess('编辑成功'); } return $this->renderError($model->getError() ?: '编辑失败'); } /** * @notes:删除 * @param array $identityId * @return Json * @author: wanghousheng */ public function delete(array $identityId): Json { $model = new IdentityModel; if ($model->remove($identityId)) { return $this->renderSuccess('删除成功'); } return $this->renderError('删除失败'); } /** * @notes:身份值 * @return Json * @author: wanghousheng */ public function typeList(): Json { $list = array_values(IdentityEnum::data()); return $this->renderSuccess(compact('list')); } }