request->params([ ["tel",""], ["name",""], ["password",""], ["sex",""], ["birthday",["",""]], ["is_show",""] ]); return success((new UserService())->getPage($data)); } /** * 会员管理详情 * @param int $id * @return \think\Response */ public function info(int $id){ return success((new UserService())->getInfo($id)); } /** * 添加会员管理 * @return \think\Response */ public function add(){ $data = $this->request->params([ ["tel",""], ["name",""], ["pic",""], ["password",""], ["pid",0], ["level",0], ["wx_openid",""], ["wx_unionid",""], ["sex",""], ["birthday","2024-02-20 11:15:10"], ["is_show",""], ]); //验证手机号唯一 $isTelExist = (new UserService())->isTelExist($data['tel']); if ($isTelExist) { return fail('手机号已存在'); } $data['password'] = create_password($data['password']); //根据pid计算对应的用户层级 $data['level'] = (new UserService())->createLevel($data['pid']); $this->validate($data, 'addon\hygl\app\validate\user\User.add'); $id = (new UserService())->add($data); return success('ADD_SUCCESS', ['id' => $id]); } /** * 会员管理编辑 * @param $id 会员管理id * @return \think\Response */ public function edit(int $id){ $data = $this->request->params([ ["tel",""], ["name",""], ["pic",""], ["password",""], ["pid",0], ["level",0], ["wx_openid",""], ["wx_unionid",""], ["sex",""], ["birthday","2024-02-20 11:15:10"], ["is_show",""], ]); //验证手机号唯一 $isTelExist = (new UserService())->isTelExist($data['tel'],$id); if ($isTelExist) { return fail('手机号已存在'); } if ($data['password']) { $data['password'] = create_password($data['password']); } else { unset($data['password']); } //根据pid计算对应的用户层级 $data['level'] = (new UserService())->createLevel($data['pid']); $this->validate($data, 'addon\hygl\app\validate\user\User.edit'); (new UserService())->edit($id, $data); return success('EDIT_SUCCESS'); } /** * 会员管理删除 * @param $id 会员管理id * @return \think\Response */ public function del(int $id){ (new UserService())->del($id); return success('DELETE_SUCCESS'); } //获取全部用户 public function getUserAll(){ return success(( new UserService())->getUserAll()); } //获取全部站点 public function getSiteAll(){ return success(( new UserService())->getSiteAll()); } }