request->params([ ['username', ''], ['realname', ''], ['role', ''], ['create_time', []], ['last_time', []], ]); $list = (new SiteUserService())->getPage($data); return success($list); } /** * 用户详情 * @param $uid * @return Response */ public function info($uid) { return success((new SiteUserService())->getInfo($uid)); } /** * 新增用户 * @return Response * @throws Exception */ public function add() { $data = $this->request->params([ ['uid', 0], ['username', ''], ['password', ''], ['real_name', ''], ['head_img', ''], ['status', UserDict::ON], ['role_ids', []] ]); if (!$data['uid']) $this->validate($data, 'app\validate\sys\User.add'); $uid = (new SiteUserService())->add($data); return success('ADD_SUCCESS', ['uid' => $uid]); } /** * 更新用户 */ public function edit($uid) { $data = $this->request->params([ ['real_name', ''], ['head_img', ''], ['status', UserDict::ON], ['role_ids', []], ['password', ''] ]); (new SiteUserService())->edit($uid, $data); return success('MODIFY_SUCCESS'); } /** * 更新字段 * @param $uid * @param $field * @return Response */ public function modify($uid, $field) { $data = $this->request->params([ ['value', ''], ['field', $field] ]); $data[$field] = $data['value']; // $this->validate($data, 'app\validate\sys\User.modify'); (new SiteUserService())->modify($uid, $field, $data['value']); return success('MODIFY_SUCCESS'); } /** * 删除单个用户 * @param $uid * @return Response */ public function del($uid) { (new UserService())->del($uid); return success('DELETE_SUCCESS'); } /** * 锁定用户 */ public function lock($uid) { (new SiteUserService())->lock($uid); return success('MODIFY_SUCCESS'); } /** * 解锁用户 */ public function unlock($uid) { (new SiteUserService())->unlock($uid); return success('MODIFY_SUCCESS'); } }