Explorar el Código

Merge branch 'dev' of wugg/useraccount into master

wugg hace 1 año
padre
commit
c8163d090a

+ 3 - 1
app/controller/Base.php

@@ -8,7 +8,9 @@ use think\App;
 use think\Response;
 use think\exception\HttpResponseException;
 class Base extends \app\BaseController{
-	public function __construct(App $app) {parent::__construct($app);}
+	public function __construct(App $app) {
+		parent::__construct($app);
+	}
 	     /**
 	* @param string $message
 	* @param int $code

+ 21 - 1
app/controller/User.php

@@ -4,7 +4,7 @@ declare (strict_types = 1);
 namespace app\controller;
 
 use app\model\Account;
-use think\facade\Cache;
+use app\model\AccountPlat;use think\facade\Cache;
 use think\Exception;
 use think\facade\Db;
 use think\App;
@@ -171,6 +171,7 @@ class User extends Base
         	"position"=>$acc->accountitem->position??'',
         	"depart_name"=>$acc->depart_name,
         	"company_relaton"=>$acc->company_relaton,
+        	"system_version"=>(new AccountPlat())->where(['account_id'=>$acc->id])->column('system_version','plat_code')
         	];
        
         if($post['openId']!=''){
@@ -411,6 +412,7 @@ class User extends Base
         	'position'=>$acc->accountitem->position??'',
         	'depart_name'=>$acc->depart_name,
         	'company_relaton'=>$acc->company_relaton,
+        	'system_version'=>(new AccountPlat())->where(['account_id'=>$acc->id])->column('system_version','plat_code')
         	];
    	   $token = makeToken($userinfo);
         if ($token == '') $this->error('token生成失败',1003);
@@ -419,4 +421,22 @@ class User extends Base
         $userinfo['token'] = $token;
    	 $this->success('获取成功',$userinfo,0);
    }
+   /**
+	* 系统板本更新
+	*/
+   public function setSystemVer(){
+    $param = $this->request->only(['account_id' => '', 'plat_code' => '','system_version'=>''], 'post', 'trim');
+     $valid =Validate::rule([
+     	'account_id|账户主键'=>'require|number|egt:0',
+     	'plat_code|系统类型'=>'require|max:255|in:cx,st',
+     	'system_version|系统更新版本号'=>'require'
+     	]);
+    if($valid->check($param)==false) $this->error($valid->getError());
+    $accountPlat= new AccountPlat();
+    $info =$accountPlat->where($param)->findOrEmpty();
+    if($info->isEmpty()==false) $this->error('记录信息已存在',1003);
+    $accountPlat->where(["account_id"=>$param['account_id'],"plat_code"=>$param['plat_code']])->delete();
+    $pl= $accountPlat->save($param);
+    $pl? $this->success('记录成功',[],0): $this->error('记录失败',1003);;
+   }
 }

+ 2 - 4
app/controller/UserInfo.php

@@ -6,7 +6,7 @@ namespace app\controller;
 use app\BaseController;
 use app\model\Account;
 use app\model\AccountCompany;
-use think\App;
+use app\model\AccountPlat;use think\App;
 use think\Exception;
 use think\facade\Db;
 use think\facade\Validate;
@@ -101,9 +101,7 @@ class UserInfo extends BaseController
         if (empty($list)) {
             return json_show(1004, "未找到用户信息");
         }
-//        $list['plat']= Db::name("account_plat")->alias("a")
-//        	->leftJoin("platform b","a.plat_code=b.plat_code and b.status=1")
-//        	->where(["a.status"=>1,"a.is_del"=>0,"a.account_id"=>$list['id']])->column("a.plat_code,plat_name");
+		$list['system_version']=(new AccountPlat())->where(['account_id'=>$list['id']])->column('system_version','plat_code');
         $list['company_relaton'] = Db::name("account_company")->where(["account_id" => $list['id'], "is_del" => 0, "status" => 1])
             ->column("companyCode,companyName,company_type,is_main,status");
         return json_show(0, "获取成功", $list);

+ 15 - 20
app/middleware/CheckAuth.php

@@ -7,13 +7,6 @@ use think\facade\Db;
 class CheckAuth
 {
 	protected $noCheck=[];
-	// header头配置
-	protected $header = [
-		'Access-Control-Allow-Credentials' => 'true',
-		'Access-Control-Max-Age'           => 1800,
-		'Access-Control-Allow-Methods'     => 'GET, POST, PATCH, PUT, DELETE, OPTIONS',
-		'Access-Control-Allow-Headers'     => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With,token',
-	];
     /**
      * 处理请求
      *
@@ -26,20 +19,22 @@ class CheckAuth
     	if($request->isOptions()){
     		return json();
     	}
-//    	$header =$request->header();
-//	    $header = !empty($header) ? array_merge($this->header, $header) : $this->header;
-//	    if (!isset($header['Access-Control-Allow-Origin'])) {
-//		    $origin = $request->header('origin');
-//		    $header['Access-Control-Allow-Origin'] = $origin;
-//	    }
-//
+    	$header =$request->header();
 	    $param =$request->post();
-//    	if($header['is_strict_login']==True){
-//    	    $check =$this->check($header,$param);
-//	         if($check['code']==1){
-//		        return json_show(104,$check['msg']);
-//			}
-//    	}
+	    if (isset($header['web-auth'])&&$header['web-auth']==1) {
+		    $data=[
+		    	"origin"=>$header['origin']??"",
+		    	"noce"=>$header['noce']??'',
+		    	"timestamp"=>$header['timestamp']??'',
+		    	"sign"=>$header['sign']??'',
+		    	];
+	    	$check= \Header::checkHeader($header);
+	    }else{
+		    $check =$this->check($header,$param);
+		    if($check['code']==1){
+		        return json_show(104,$check['msg']);
+		    }
+	    }
     
        return $next($request);
     }

+ 18 - 0
app/model/AccountPlat.php

@@ -0,0 +1,18 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\model;
+
+use think\Model;use think\model\concern\SoftDelete;
+
+/**
+ * @mixin \think\Model
+ */
+class AccountPlat extends Model
+{
+   	use SoftDelete;
+	protected $createTime = 'addtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = 'delete_time';
+    protected $hidden = ['delete_time'];
+}

+ 1 - 0
route/app.php

@@ -16,6 +16,7 @@ Route::rule('register', 'User/register');
 Route::rule('dingTalk', 'User/DingTalk');
 Route::rule('accountquery', 'User/AccountQuery');
 Route::rule('bindwx', 'User/BindWx');
+Route::rule('setSystemVer', 'User/setSystemVer');
 
 Route::rule('userlist', 'UserInfo/UserList');
 Route::rule('usersave', 'UserInfo/UserSave');