|
@@ -2,255 +2,263 @@
|
|
|
|
|
|
declare (strict_types = 1);
|
|
|
namespace app\admin\controller;
|
|
|
-use app\admin\BaseController;use think\App;use think\facade\Db;
|
|
|
+use app\admin\BaseController;use think\App;use think\facade\Db;use think\facade\Validate;
|
|
|
|
|
|
class User extends BaseController{
|
|
|
public function __construct(App $app) {parent::__construct($app);}
|
|
|
- //获取用户列表分页
|
|
|
- public function userList(){
|
|
|
- if(isset($this->post['status'])&&$this->post['status']!==''){
|
|
|
- $uid =Db::name("user_role")->where(["status"=>1,"is_del"=>0])->column("uid");
|
|
|
- if($this->post['status']==1){
|
|
|
- $this->post['uid']= isset($uids)?array_unique(array_merge($uids,$uid)):$uid;
|
|
|
+ /**
|
|
|
+ * 设置供应商信息
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ */
|
|
|
+ public function EditUserCompany(){
|
|
|
+ $post = $this->request->only(["token"=>"","nickname"=>"","id"=>"","mobile"=>"","companyArr"=>[]],"post");
|
|
|
+ $valide = $validate=Validate::rule([
|
|
|
+ 'nickname|真实姓名' => 'require|max:255',
|
|
|
+ 'id|账户ID' => 'require|number|gt:0',
|
|
|
+ 'mobile|手机号' => 'require|number|mobile',
|
|
|
+ 'companyArr|业务公司' => 'require|array',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if($valide->check($post)==false) return json_show(1004,$valide->getError());
|
|
|
+ $saveinfo =[
|
|
|
+ "id"=>$post['id'],
|
|
|
+ "nickname"=>$post['nickname'],
|
|
|
+ "mobile"=>$post['mobile'],
|
|
|
+ "token"=>$post['token']
|
|
|
+ ];
|
|
|
+ $saev= resetinfo($saveinfo);
|
|
|
+
|
|
|
+ if(!isset($saev['code'])||$saev['code']!=0){
|
|
|
+ return error_show(1004,$saev['message']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $companyinfo = ["id"=>$post['id'],"company"=>$post['companyArr'],"token"=>$post['token']];
|
|
|
+ $companyset =setUserCompany($companyinfo);
|
|
|
+ if(!isset($companyset['code'])||$companyset['code']!=0){
|
|
|
+ return error_show(1004,$companyset['message']);
|
|
|
+ }
|
|
|
+ return app_show(0,"设置成功");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 用户列表
|
|
|
+ */
|
|
|
+ public function userList(){
|
|
|
+ $post=$this->request->only(["token"=>"","nickname"=>"","relaComNo"=>"","username"=>"","status"=>"","page"=>1,
|
|
|
+ "size"=>10],"post");
|
|
|
+ if($post['status']!==''){
|
|
|
+ $uid =Db::name("user_role")->where(["status"=>1,"is_del"=>0])->column("uid");
|
|
|
+ if($post['status']==1){
|
|
|
+ $post['uid']= isset($uids)?array_unique(array_merge($uids,$uid)):$uid;
|
|
|
}else{
|
|
|
- $this->post['nouid']=$uid;
|
|
|
+ $post['nouid']=$uid;
|
|
|
}
|
|
|
- unset($this->post['status']);
|
|
|
- }
|
|
|
- $userinfo=GetList($this->post['token'],$this->post);
|
|
|
+ unset($post['status']);
|
|
|
+ }
|
|
|
+ $post['companyNo'] =$post['relaComNo']??"";
|
|
|
+ unset($post['relaComNo']);
|
|
|
+ $userinfo=GetUserList($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");
|
|
|
- $roleArr = Db::name("user_role")->where(["status"=>1,"is_del"=>0])->column("roleid,status","uid");
|
|
|
- $role[0]="";
|
|
|
+ $roleArr = Db::name("user_role")->alias("a")
|
|
|
+ ->leftJoin("role b","a.roleid=b.id")
|
|
|
+ ->where(["a.status"=>1,"a.is_del"=>0])
|
|
|
+ ->column("role_name,roleid,a.status","a.companyNo");
|
|
|
$list=[];
|
|
|
foreach ($data as $value){
|
|
|
- $value['roleid']=isset($roleArr[$value['id']]['roleid'])?$roleArr[$value['id']]['roleid'] :"";
|
|
|
- $value['status']=isset($roleArr[$value['id']]['status'])?$roleArr[$value['id']]['status']:"";
|
|
|
- $value["role_name"] = isset($role[$value["roleid"]]) ? $role[$value["roleid"]]:"";
|
|
|
+ $value['roleid']=$roleArr[$value['companyCode']]['roleid']??"";
|
|
|
+ $value['com_status']=$roleArr[$value['companyCode']]['status']??"";
|
|
|
+ $value["role_name"] =$roleArr[$value['companyCode']]['role_name']??"";
|
|
|
$list[]=$value;
|
|
|
}
|
|
|
return app_show(0,"获取成功",["list"=>$list,"count"=>$userinfo['data']["count"]]);
|
|
|
}
|
|
|
|
|
|
- /**获取当前访问用户的信息
|
|
|
+ /**获取当前访问用户的信息
|
|
|
* @param token
|
|
|
* @return \think\response\Json
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
public function userInfo(){
|
|
|
- $userinfo=GetUserInfo($this->post['token']);
|
|
|
+ $post =$this->request->only(["token"=>""],"post","trim");
|
|
|
+ $userinfo=GetUserInfo($post['token']);
|
|
|
if(empty($userinfo)||$userinfo['code']!=0){
|
|
|
return app_show(1002,"员工信息不存在");
|
|
|
}
|
|
|
$data = $userinfo['data'];
|
|
|
- $data['roleid']= $this->roleid;
|
|
|
- $role = Db::name("role")->where("id","=",$data['roleid'])->find();
|
|
|
- $data['role_name']=isset($role['role_name']) ? $role['role_name'] :"";
|
|
|
+
|
|
|
+ $roleArr = Db::name("user_role")->alias("a")
|
|
|
+ ->leftJoin("role b","a.roleid=b.id")
|
|
|
+ ->where(["a.status"=>1,"a.is_del"=>0,"a.uid"=>$data['id']])
|
|
|
+ ->column("role_name,roleid,a.status","a.companyNo");
|
|
|
+ if(!empty($data['company_relaton'])){
|
|
|
+ foreach ($data['company_relaton'] as &$item){
|
|
|
+ $item['roleid'] =isset($roleArr[$item['companyCode']])?$roleArr[$item['companyCode']]['roleid']:"";
|
|
|
+ $item['role_name'] =isset($roleArr[$item['companyCode']])?$roleArr[$item['companyCode']]['role_name']:"";
|
|
|
+ $item['role_status'] =isset($roleArr[$item['companyCode']])?$roleArr[$item['companyCode']]['status']:"";
|
|
|
+ }
|
|
|
+ }
|
|
|
return app_show(0,"获取成功",$data);
|
|
|
}
|
|
|
- //修改用户状态 status 0 禁用1启用
|
|
|
- /**
|
|
|
- * @return \think\response\Json|void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- */
|
|
|
- public function setStatus(){
|
|
|
- $post =$this->post;
|
|
|
- $userid = isset($post['id'])&&$post['id']!==""?intval($post['id']):"";
|
|
|
- if($userid==""){
|
|
|
- return error_show(1004,"参数id 不能为空");
|
|
|
- }
|
|
|
- $status = isset($post['status'])&&$post['status']!=""?intval($post['status']):"";
|
|
|
+ /**
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function setStatus(){
|
|
|
+ $post =$this->request->only(["id"=>"","status"=>"","relaComNo"=>"","token"=>""],"post");
|
|
|
+ $valide =Validate::rule([
|
|
|
+ 'id|账户ID' => 'require|number|gt:0',
|
|
|
+ 'status|状态' => 'require|number|in:0,1',
|
|
|
+ 'relaComNo|业务公司' => 'require|max:255',
|
|
|
+ ]);
|
|
|
+ if($valide->check($post)==false) return error_show(1004,$valide->getError());
|
|
|
+ $message = $post['status']==1?"启用":"禁用";
|
|
|
+ $userinfo =Db::name("user_role")->where(["uid"=>$post['id'],"companyNo"=>$post['relaComNo'],"is_del"=>0])
|
|
|
+ ->find();
|
|
|
+ if($userinfo==false){
|
|
|
+ return error_show(1005,"未找到有关账户信息");
|
|
|
+ }else{
|
|
|
+ $userinfo['status']=$post['status'];
|
|
|
+ $userinfo['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $sa=Db::name("user_role")->save($userinfo);
|
|
|
+ }
|
|
|
+ if($sa==false){
|
|
|
+ return error_show(1005,"{$message}失败");
|
|
|
+ }else{
|
|
|
+ return app_show(0,"{$message}成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if($status===""){
|
|
|
- return error_show(1004,"参数status 不能为空");
|
|
|
- }
|
|
|
- if(!in_array($status,[0,1])){
|
|
|
- return error_show(1004,"参数status无效");
|
|
|
- }
|
|
|
- $message = $status==1?"启用":"禁用";
|
|
|
- $userinfo =Db::name("user_role")->where(["uid"=>$userid,"is_del"=>0])->find();
|
|
|
- if($userinfo==false){
|
|
|
- $data=[
|
|
|
- "uid"=>$userid,
|
|
|
- "roleid"=>0,
|
|
|
- "status"=>$status,
|
|
|
- "is_del"=>0,
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
- "updatetime"=>date("Y-m-d H:i:s"),
|
|
|
- ];
|
|
|
- $sa=Db::name("user_role")->save($data);
|
|
|
- }else{
|
|
|
- $userinfo['status']=$status;
|
|
|
- $userinfo['updatetime']=date("Y-m-d H:i:s");
|
|
|
- $sa=Db::name("user_role")->save($userinfo);
|
|
|
- }
|
|
|
- if($sa==false){
|
|
|
- return error_show(1005,"{$message}失败");
|
|
|
- }else{
|
|
|
+ //获取所有用户的信息
|
|
|
+ public function userAll(){
|
|
|
+ $post=$this->request->only(['relaComNo'=>"","nickname"=>"","roleid"=>"","status"=>""],"post","trim");
|
|
|
+ $condition = [["is_del","=",0]];
|
|
|
|
|
|
- return app_show(0,"{$message}成功");
|
|
|
- }
|
|
|
- }
|
|
|
- //获取所有用户的信息
|
|
|
- public function userAll(){
|
|
|
- if(isset($this->post['status'])&&$this->post['status']!==''){
|
|
|
- $uid =Db::name("user_role")->where(["status"=>1,"is_del"=>0])->column("uid");
|
|
|
- if($this->post['status']==1){
|
|
|
- $this->post['uid']= isset($uids)?array_unique(array_merge($uids,$uid)):$uid;
|
|
|
- }else{
|
|
|
- $this->post['nouid']=$uid;
|
|
|
- }
|
|
|
- unset($this->post['status']);
|
|
|
- }
|
|
|
- $userinfo=GetAccountall($this->post['token'],$this->post);
|
|
|
- if(empty($userinfo)||$userinfo['code']!=0){
|
|
|
- return app_show(1002,"员工信息不存在");
|
|
|
- }
|
|
|
- $data = $userinfo['data'];
|
|
|
- $role = Db::name("role")->column("role_name","id");
|
|
|
- $roleArr = Db::name("user_role")->where(["status"=>1,"is_del"=>0])->column("roleid,status","uid");
|
|
|
- $role[0]="";
|
|
|
- $list=[];
|
|
|
- foreach ($data as $value){
|
|
|
- $value['roleid']=isset($roleArr[$value['id']]['roleid'])?$roleArr[$value['id']]['roleid'] :"";
|
|
|
- $value['status']=isset($roleArr[$value['id']]['status'])?$roleArr[$value['id']]['status']:"";
|
|
|
- $value["role_name"] = isset($role[$value["roleid"]]) ? $role[$value["roleid"]]:"";
|
|
|
- $list[]=$value;
|
|
|
- }
|
|
|
+ $rolecond=" level in (1,2,3)";
|
|
|
+ if($post['relaComNo']!=""){
|
|
|
+ $condition[]=["companyNo","=",$post['relaComNo']];
|
|
|
+ $rolecond = "level=1 or (level in (2,3) and companyNo ='{$post['relaComNo']}' )";
|
|
|
+ }
|
|
|
+ if($post['roleid']!=""){
|
|
|
+ $condition[]=["roleid","=",$post['roleid']];
|
|
|
+ $rolecond = "id={$post['roleid']}";
|
|
|
+ }
|
|
|
+ if($post['status']!="")$condition[]=["status","=",$post['status']];
|
|
|
+ if($post['nickname']!="")$condition[]=["nickname","like","%{$post['nickname']}%"];
|
|
|
+ $list=Db::name("user_role")->where($condition)->select()->toArray();
|
|
|
+ $role = Db::name("role")->whereRaw($rolecond)->column("role_name","id");
|
|
|
+ foreach ($list as &$value){
|
|
|
+ $value['role_name']= $role[$value['roleid']]??"";
|
|
|
+ $value['companyName']= Db::name("supplier_info")->where(["code"=>$value['companyNo']])->value("name",'');
|
|
|
+ }
|
|
|
return app_show(0,"获取成功",$list);
|
|
|
}
|
|
|
- /**
|
|
|
- * 修改用户基础信息
|
|
|
- */
|
|
|
- public function userSave(){
|
|
|
- $post=$this->post;
|
|
|
- $userid = isset($post['id'])&&$post['id']!==""?intval($post['id']):"";
|
|
|
- if($userid==""){
|
|
|
- return error_show(1004,"参数id 不能为空");
|
|
|
- }
|
|
|
|
|
|
- $nickname= isset($post['nickname'])? trim($post['nickname']):"";
|
|
|
- if ($nickname==""){
|
|
|
- return app_show(1001,"昵称不能为空");
|
|
|
- }
|
|
|
- $mobile= isset($post['mobile'])? trim($post['mobile']):"";
|
|
|
- if ($mobile==""){
|
|
|
- return app_show(1002,"手机号不能为空");
|
|
|
- }
|
|
|
- if (checkMobile($mobile)==false){
|
|
|
- return app_show(1002,"手机号格式不正确");
|
|
|
- }
|
|
|
- $email= isset($post['email'])? trim($post['email']):"";
|
|
|
- $role =isset($post['role'])? intval($post['role']):0;
|
|
|
- if($role!=0){
|
|
|
- $roleinfo =Db::name("role")->where("id","=",$role)->find();
|
|
|
- if(empty($roleinfo)){
|
|
|
- return error_show(1002,"角色不存在");
|
|
|
- }
|
|
|
- if($roleinfo['status']==0){
|
|
|
- return error_show(1002,"角色已禁用");
|
|
|
- }
|
|
|
- }
|
|
|
- $userrole = Db::name("user_role")->where(["uid"=>$userid,"is_del"=>0])->find();
|
|
|
+ /**
|
|
|
+ * 修改用户基础信息
|
|
|
+ */
|
|
|
+ public function setRole(){
|
|
|
+ $post=$this->request->only(["id"=>"","nickname"=>"","relaComNo"=>"","company_type"=>"","roleid"=>""],"post","trim");
|
|
|
|
|
|
- Db::startTrans();
|
|
|
- try{
|
|
|
- if(empty($userrole)){
|
|
|
- $roledata =[
|
|
|
- "uid"=>$userid,
|
|
|
- "roleid"=>$role,
|
|
|
- "nickname"=>$nickname,
|
|
|
- "status"=>1,
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
- "updatetime"=>date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $up= Db::name("user_role")->insert($roledata);
|
|
|
- }else{
|
|
|
- $userrole['roleid'] = $role;
|
|
|
- $userrole['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $up=Db::name("user_role")->save($userrole);
|
|
|
- }
|
|
|
- if($up==false){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1004,'用户信息更新失败');
|
|
|
- }
|
|
|
- $data=[
|
|
|
- "id"=>$userid,
|
|
|
- "nickname"=>$nickname,
|
|
|
- "mobile"=>$mobile,
|
|
|
- "email"=>$email
|
|
|
- ];
|
|
|
- $save =resetinfo($post['token'],$data);
|
|
|
- if(!empty($save) && $save['code']!=0){
|
|
|
- Db::rollback();
|
|
|
- return error_show($save['code'],$save['message']);
|
|
|
- }
|
|
|
- Db::commit();
|
|
|
- return app_show(0,'用户信息更新成功');
|
|
|
- }catch (\Exception $e){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1004,$e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- //角色设置
|
|
|
- /** id roleid
|
|
|
- * @return \think\response\Json|void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- */
|
|
|
- public function setRole(){
|
|
|
- $post =$this->post;
|
|
|
- $uid = isset($post['id'])&&$post['id']!=='' ? intval($post['id']) :"";
|
|
|
- if($uid===''){
|
|
|
- return error_show(1004,"参数id 不能为空");
|
|
|
- }
|
|
|
- $roleinfo = Db::name("user_role")->where(["uid"=>$uid])->find();
|
|
|
- $role =isset($post['roleid']) && $post['roleid']!=="" ? intval($post['roleid']) :"";
|
|
|
- if($role===''){
|
|
|
- return error_show(1004,"参数roleid 不能为空");
|
|
|
- }
|
|
|
- $isRole = Db::name('role')->where([['id',"=",$role],['status',"=",1]])->find();
|
|
|
- if(empty($isRole)){
|
|
|
- return error_show(1004,"所选角色不存在");
|
|
|
- }
|
|
|
- if($roleinfo==false){
|
|
|
- $data = [
|
|
|
- 'uid'=>$uid,
|
|
|
- 'roleid'=>$role,
|
|
|
- 'status'=>1,
|
|
|
- 'addtime'=>date('Y-m-d H:i:s'),
|
|
|
- 'updatetime'=>date('Y-m-d H:i:s'),
|
|
|
- ];
|
|
|
- $insert = Db::name('user_role')->insert($data);
|
|
|
- }else{
|
|
|
- $roleinfo['roleid']=$role;
|
|
|
- $roleinfo['status']=1;
|
|
|
- $roleinfo['is_del']=0;
|
|
|
- $roleinfo['updatetime']=date('Y-m-d H:i:s');
|
|
|
- $insert = Db::name('user_role')->save($roleinfo);
|
|
|
- }
|
|
|
- return $insert? app_show(0,'数据新建成功'):error_show(1004,'数据新建失败');
|
|
|
- }
|
|
|
- //密码设置
|
|
|
- public function setPwd(){
|
|
|
- $post =$this->post;
|
|
|
-
|
|
|
- $userid = isset($post['id'])&&$post['id']!==""?intval($post['id']):"";
|
|
|
- if($userid==""){
|
|
|
- return error_show(1004,"参数id 不能为空");
|
|
|
- }
|
|
|
- $newPwd= isset($post['password']) ? trim($post['password']) : "";
|
|
|
- if($newPwd==""){
|
|
|
- return error_show(1001,'密码不能为空');
|
|
|
- }
|
|
|
+ $valide=Validate::rule([
|
|
|
+ "id|账户ID"=>"require|number|gt:0",
|
|
|
+ "nickname|名称"=>"require|max:255",
|
|
|
+ "relaComNo|业务公司"=>"require|max:255",
|
|
|
+ "company_type|业务公司类型"=>"require|number|in:1,2",
|
|
|
+ "roleid|角色ID"=>"require|number",
|
|
|
+ ]);
|
|
|
+ if($valide->check($post)==false) return error_show(1004,$valide->getError());
|
|
|
+ if($post['roleid']!=0){
|
|
|
+ $roleinfo =Db::name("role")->where("id","=",$post['roleid'])->find();
|
|
|
+ if(empty($roleinfo)){
|
|
|
+ return error_show(1002,"角色不存在");
|
|
|
+ }
|
|
|
+ if($roleinfo['status']==0){
|
|
|
+ return error_show(1002,"角色已禁用");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $userrole = Db::name("user_role")
|
|
|
+ ->where(["uid"=>$post['id'],"companyNo"=>$post['relaComNo'],"is_del"=>0])
|
|
|
+ ->find();
|
|
|
|
|
|
- $data = resetpwd($post['token'],["id"=>$userid,'password'=>$newPwd]);
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ if(empty($userrole)){
|
|
|
+ $roledata =[
|
|
|
+ "uid"=>$post['id'],
|
|
|
+ "roleid"=>$post['roleid'],
|
|
|
+ "nickname"=>$post['nickname'],
|
|
|
+ "companyNo"=>$post['relaComNo'],
|
|
|
+ "company_type"=>$post['company_type'],
|
|
|
+ "status"=>1,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $up= Db::name("user_role")->insert($roledata);
|
|
|
+ }else{
|
|
|
+ $userrole['roleid'] = $post['roleid'];
|
|
|
+ $userrole['companyNo'] = $post['relaComNo'];
|
|
|
+ $userrole['company_type'] =$post['company_type'];
|
|
|
+ $userrole['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $up=Db::name("user_role")->save($userrole);
|
|
|
+ }
|
|
|
+ if($up==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,'用户信息更新失败');
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,'用户信息更新成功');
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**获取用户关联业务公司
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function GetCompany(){
|
|
|
+ $post=$this->request->only(["token"=>"","uid"=>"","companyName"=>"","page"=>1,"size"=>20],"post","trim");
|
|
|
+ $where=[];
|
|
|
+ if($post['uid']!=""){
|
|
|
+ $where[]=["a.uid","=",$post['uid']];
|
|
|
+ }else{
|
|
|
+ $where[]=["a.uid","=",$this->uid];
|
|
|
+ }
|
|
|
+ if($post['companyName']!=""){
|
|
|
+ $where[]=["b.name","like","%{$post['companyName']}%"];
|
|
|
+ }
|
|
|
+ $count = Db::name("user_role")->alias("a")
|
|
|
+ ->leftJoin("supplier_info b","a.companyNo=b.code")
|
|
|
+ ->where($where)
|
|
|
+ ->count();
|
|
|
+ $total =ceil($count/$post['size']);
|
|
|
+ $page = $post['page']>$total ? intval($total):intval($post['page']);
|
|
|
+ $list = Db::name("user_role")->alias("a")
|
|
|
+ ->leftJoin("supplier_info b","a.companyNo=b.code")
|
|
|
+ ->where($where)
|
|
|
+ ->field("a.uid,a.nickname,roleid,companyNo,b.name as companyName,a.status,a.company_type")
|
|
|
+ ->page($page,intval($post['size']))
|
|
|
+ ->select()->toArray();
|
|
|
+ foreach ($list as &$value){
|
|
|
+ $value['role_name'] = Db::name("role")->where(["id"=>$value["roleid"]])->value("role_name","");
|
|
|
+ }
|
|
|
+ return app_show(0,'获取成功',["list"=>$list,"count"=>$count]);
|
|
|
+ }
|
|
|
+ //密码设置
|
|
|
+ public function setPwd(){
|
|
|
+ $post=$this->request->only(["id"=>"","password"=>""],"post","trim");
|
|
|
+ $validate=Validate::rule([
|
|
|
+ 'id|账户ID' => 'require|number',
|
|
|
+ 'password|密码' => 'require|min:6|max:200',
|
|
|
+ ]);
|
|
|
+ if($validate->check($post)==false) return error_show(1004,$validate->getError());
|
|
|
+ $data = resetpwd($post);
|
|
|
if(empty($data)||$data['code']!=0){
|
|
|
return error_show($data['code'],$data['message']);
|
|
|
}else{
|