wugg 3 years ago
parent
commit
29ab3dff2c
4 changed files with 65 additions and 4 deletions
  1. 5 3
      app/admin/controller/Group.php
  2. 54 0
      app/admin/controller/User.php
  3. 6 0
      app/admin/route/app.php
  4. 0 1
      app/common.php

+ 5 - 3
app/admin/controller/Group.php

@@ -3,11 +3,11 @@ namespace app\admin\controller;
 
 use app\BaseController;
 use think\facade\Db;
-use think\app;
+use think\App;
 
 class Group extends BaseController
 {
-    public function __construct(App $app)
+    public  function __construct(App $app)
     {
         parent::__construct($app);
         $post  =$this->request->post();
@@ -20,6 +20,7 @@ class Group extends BaseController
         if(!empty($effetc) && $effetc['code']!=0){
             return error_show($effetc['code'],$effetc['message']);
         }
+        $this->uid = isset($effetc['data']['user']['id']) ? $effetc['data']['user']['id'] :"";
     }
 
     /**
@@ -30,12 +31,13 @@ class Group extends BaseController
      * @throws \think\exception\DbException
      */
     public function GroupList(){
+
         $post  =$this->request->post();
         $token = isset($post['token']) ? trim($post['token']) : "";
 
         $page = isset($post['page']) ? intval($post['page']): 1;
         $size = isset($post['size']) ? intval($post['size']):10;
-        $condition=[['is_del'=>0]];
+        $condition=['is_del'=>0];
         $count = Db::name("role_group")->where($condition)->count();
         $page>=ceil($count/$size) ? $page=ceil($count/$size) :"";
         $list =  Db::name("role_group")->where($condition)->page($page,$size)->select();

+ 54 - 0
app/admin/controller/User.php

@@ -101,6 +101,11 @@ class User extends BaseController
             return error_show(1002,"原密码不能为空");
         }
         $data = resetpasswd($token,['newpwd'=>$newPwd,'oldpwd'=>$oldpwd]);
+        if(empty($userinfo)||$userinfo['code']!=0){
+            return error_show($userinfo['code'],$userinfo['message']);
+        }else{
+            return app_show(0,"密码修改成功");
+        }
     }
 
     public  function  userAll(){
@@ -157,6 +162,12 @@ class User extends BaseController
                 ->field("roleid,role_name")->find();
             $value['roleid'] = isset($role['roleid']) ? $role['roleid'] :"";
             $value['role_name'] = isset($role['role_name']) ? $role['role_name'] :"";
+            $depart = Db::name("depart_user")->where([["uid","=",$data['uid']],["is_del","=",0]])->column("itemid");
+            $value['depart']="";
+            if(!empty($depart)){
+                $deparname = Db::name("company_item")->where(["id"=>$depart,"is_del"=>0])->column("name");
+                $value['depart'] = implode(",",$deparname);
+            }
             $list[]=$value;
         }
         return app_show(0,"获取成功",["list"=>$list,"count"=>$userinfo['data']["count"]]);
@@ -196,4 +207,47 @@ class User extends BaseController
 
         return $insert? app_show(0,'数据新建成功'):error_show(1004,'数据新建失败');
     }
+
+    /**
+     * 保存新建的资源
+     *
+     * @param  \think\Request  $request
+     * @return \think\Response
+     */
+    public function UserSave()
+    {
+        $post=$this->request->post();
+        $toke= isset($post['token'])? trim($post['token']):"";
+        if ($toke==""){
+            return app_show(100,"token不能为空");
+        }
+        $verify = VerifyToken($toke);
+        if ($verify['code']!=0){
+            return app_show($verify['code'],$verify['message']);
+        }
+        $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;
+        $data=[
+            "id"=>$userid,
+            "nickname"=>$nickname,
+            "mobile"=>$mobile,
+            "email"=>$email
+        ];
+    }
 }

+ 6 - 0
app/admin/route/app.php

@@ -62,6 +62,12 @@ Route::rule('iuserdel','admin/Departuser/userdel');
 Route::rule('userlist', 'admin/User/list');
 Route::rule('userinfo', 'admin/User/userInfo');
 Route::rule('userall', 'admin/User/userList');
+
+Route::rule("userstatus","Api/UserInfo/UserStatus");
+Route::rule("usersave","Api/UserInfo/UserSave");
+Route::rule("passset","Api/UserInfo/PassSet");
+Route::rule("userinfobyid","Api/UserInfo/info");
+
 Route::rule('stat','admin/Newfill/stat');
 Route::rule('userp','admin/Newfill/userp');
 

+ 0 - 1
app/common.php

@@ -100,7 +100,6 @@ function makeSalt(){
  */
 function VerifyTokens($token){
     $host = Config::get("app");
-
     $url = $host["api_host"]."/Api/verify_token";
     $data=[
         "token"=>$token