Explorar el Código

Merge branch 'dev_wf' of wugg/cxinv into dev

wufeng hace 2 años
padre
commit
fdc298ce1d
Se han modificado 3 ficheros con 55 adiciones y 0 borrados
  1. 40 0
      app/admin/controller/User.php
  2. 1 0
      app/admin/route/app.php
  3. 14 0
      app/common.php

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

@@ -610,6 +610,46 @@ class User extends BaseController{
 		 return $post['id']==""?app_show(0,"账户新建成功"):app_show(0,"账户编辑成功");
 	}
 
+    //添加超管账号
+    public function adminAccountAdd()
+    {
+
+        $post = $this->request->only(['nickname', 'mobile', 'email' => '', 'relaComNo' => ''], 'post', 'trim');
+        $validate = Validate::rule([
+            'nickname|真实姓名' => 'require|min:2|max:200',
+            'mobile|手机号' => 'require|mobile',
+            'email|邮箱' => 'email|max:255',
+            'companyArr|关联账户' => 'array|max:100',
+        ]);
+        if ($validate->check($post) == false) return error_show(1004, $validate->getError());
+
+        $post['companyArr'][] = [
+            "companyCode" => '',
+            "companyName" => '',
+            "company_type" => 0,
+            "is_main" => 1,
+        ];
+
+        $rs = add_admin_acount($post);
+        if (!isset($rs['code']) || $rs['code'] != 0) return error_show(1004, $rs['message']);
+
+        $up = Db::name("user_role")->insert([
+            "uid" => $rs['data']["userid"],
+            "nickname" => $rs['data']["nickname"],
+            "roleid" => 1,
+            "companyNo" => '',
+            "company_type" => '',
+            "status" => 1,
+            "is_main" => 1,
+            "is_del" => 0,
+            "addtime" => date("Y-m-d H:i:s"),
+            "updatetime" => date("Y-m-d H:i:s"),
+        ]);
+        if ($up == false) return error_show(1004, '超管账户分配角色失败');
+
+        return app_show(0, '添加超管账号成功');
+    }
+
 
 
 }

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

@@ -30,6 +30,7 @@ Route::rule('setpwd', 'admin/User/setPwd');
 Route::rule('setstatus', 'admin/User/setStatus');
 Route::rule('setcompanystatus', 'admin/User/setCompanyStatus');
 Route::rule('getcompany', 'admin/User/GetCompany');
+Route::rule('adminAccountAdd', 'admin/User/adminAccountAdd');
 
 Route::rule('rolelist', 'admin/Role/roleList');
 Route::rule('roleall', 'admin/Role/roleAll');

+ 14 - 0
app/common.php

@@ -248,6 +248,20 @@ function addacount($condition){
 
     return json_decode($response,true);
 }
+
+//添加超管账号
+if(function_exists('add_admin_account') == false){
+    function add_admin_acount(array $data=[]){
+        $host = Config::get("app");
+
+        $url = $host["api_host"]."/add_admin_account";
+        $response=curl_request($url,$data);
+
+        return json_decode($response,true);
+    }
+}
+
+
 if(!function_exists("headerSign")){
 
 	function headerSign($post){