request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return app_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return app_show($effetc['code'],$effetc['message']); } $userinfo=GetUserInfo($token); if(empty($userinfo)||$userinfo['code']!=0){ return app_show(1002,"员工信息不存在"); } $data = $userinfo['data']; $role = Db::name("role")->where("id","=",$data['roleid'])->find(); $data['role_name']=isset($role['role_name']) ? $role['role_name'] :""; return app_show(0,"获取成功",$data); } /** * @param token * @param passwd * @return \think\response\Json * @throws \think\exception\DbException */ public function resetPwd(){ $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $effetc = verfiyToken($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $newPwd= isset($post['passwd']) ? trim($post['passwd']) : ""; if($newPwd==""){ return error_show(1001,'新密码不能为空'); } $oldpasswd= isset($post['oldpasswd']) ? trim($post['oldpasswd']) : ""; if($oldpasswd==""){ return error_show(1001,'旧密码不能为空'); } $account =model("AdminAccount")->GetAccountByUid($effetc['user']['id']); if(!empty ($account) && $account->status!=1){ return error_show(10005, '账户已被禁止登录'); } if($account->password!=sha1($oldpasswd.$account->salt)){ return error_show(10005, '旧密码错误!'); } $salt=makeSalt(); $data=['password'=>sha1($newPwd.$salt),'salt'=>$salt,"updatetime"=>date("Y-m-d H:i:s")]; return AdminAccount::update($data,["id"=>$account->id]) ? app_show(0, '密码修改成功') : error_show(1001,"密码修改失败"); } public function userAll(){ $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return app_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return app_show($effetc['code'],$effetc['message']); } $userinfo=GetAccountall($token); if(empty($userinfo)||$userinfo['code']!=0){ return app_show(1002,"员工信息不存在"); } $data = $userinfo['data']; $role = Db::name("role")->column("role_name","id"); $role[0]=""; $list=[]; foreach ($data as $value){ $value["role_name"] = isset($role[$value["roleid"]]) ? $role[$value["roleid"]]:""; $list[]=$value; } return app_show(0,"获取成功",$list); } /** * @return \think\response\Json|void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function userList(){ $post =$this->request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return app_show(101,'token不能为空'); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return app_show($effetc['code'],$effetc['message']); } $userinfo=GetList($token,$post); if(empty($userinfo)||$userinfo['code']!=0){ return app_show($userinfo['code'],$userinfo['msg']); } $data = $userinfo['data']['list']; $role = Db::name("role")->column("role_name","id"); $role[0]=""; $list=[]; foreach ($data as $value){ $value["role_name"] = isset($role[$value["roleid"]]) ? $role[$value["roleid"]]:""; $list[]=$value; } return app_show(0,"获取成功",["list"=>$list,"count"=>$userinfo['data']["count"]]); } }