Browse Source

细节优化加统一

wufeng 2 years ago
parent
commit
f6eb3cb0b6

+ 2 - 2
app/admin/logic/CommonLogic.php

@@ -15,11 +15,11 @@ class CommonLogic extends BaseLogic
     {
 
         $res = AdminModel::field(true)
-            ->where(["is_del" => AdminModel::$del_normal, "username" => $data['username']])
+            ->where(["is_del" => CommonModel::$del_normal, "username" => $data['username']])
             ->findOrEmpty();
 
         if ($res->isEmpty()) return json_show(CommonModel::$error_token, '该账户不存在');
-        if ($res->status == AdminModel::$status_disable) return json_show(CommonModel::$error_token, '该账户已禁用');
+        if ($res->status == CommonModel::$status_disable) return json_show(CommonModel::$error_token, '该账户已禁用');
 
         if (getPassword($data['password'], $res->salt) != $res->password) return json_show(CommonModel::$error_token, '账户密码错误');
 

+ 3 - 2
app/common.php

@@ -5,6 +5,7 @@ use think\facade\Config;
 use app\model\AdminTokenModel;
 use app\model\AdminModel;
 use think\exception\ValidateException;
+use app\model\CommonModel;
 
 //返回响应数据
 if (!function_exists('json_show')) {
@@ -49,10 +50,10 @@ if (!function_exists('verifyToken')) {
 
         if (strtotime($has->expiretime) <= time()) throw new ValidateException('token已失效');
 
-        $account = AdminModel::where(['id' => $has['adminid'], 'is_del' => AdminModel::$del_normal])->findOrEmpty();
+        $account = AdminModel::where(['id' => $has['adminid'], 'is_del' => CommonModel::$del_normal])->findOrEmpty();
         if ($account->isEmpty()) throw new ValidateException('未找到账户');
 
-        if ($account->status != AdminModel::$status_normal) throw new ValidateException('账户已禁用');
+        if ($account->status != CommonModel::$status_normal) throw new ValidateException('账户已禁用');
 
         $token_str = base64_decode($token);
 

+ 5 - 0
app/mobile/config/common.php

@@ -0,0 +1,5 @@
+<?php
+//api模块通用配置信息
+return [
+    'expire'=>1800,//token的有效时长
+];

+ 34 - 0
app/mobile/config/validate_rules.php

@@ -0,0 +1,34 @@
+<?php
+
+use app\model\AdminMenuModel;
+use app\model\CommonModel;
+use app\model\GroupModel;
+use app\model\RoleModel;
+use app\model\ThemeModel;
+
+return [
+    //【通用】
+    'common' => [
+        'keyword|关键字' => 'chsDash|max:100',
+        'page|页码' => 'require|number|gt:0',
+        'size|每页数量' => 'require|number|elt:100',
+        'status|状态' => 'number|in:' . CommonModel::$status_normal . ',' . CommonModel::$status_disable,
+        'company_id|企业' => 'number|gt:0',
+        'card_id|卡类型' => 'number|gt:0',
+    ],
+
+    //【启禁用】
+    'status' => [
+        'id' => 'require|number|gt:0',
+        'status|状态' => 'require|number|in:' . CommonModel::$status_normal . ',' . CommonModel::$status_disable,
+    ],
+
+    //【登录】
+    'login' => [
+        'username|卡号' => 'require|max:255',
+        'password|密码' => 'require|max:255',
+    ],
+
+
+
+];

+ 1 - 10
app/model/AdminModel.php

@@ -13,16 +13,7 @@ class AdminModel extends Model
     protected $pk = 'id';
     protected $autoWriteTimestamp = 'datetime';
 
-    protected $hidden=['nickname','mobile'];
-
-    //是否删除
-    public static $del_normal=0;//未删除
-    public static $del_deleted=1;//已删除
-
-    //状态
-    public static $status_normal=1;//启用
-    public static $status_disable=0;//禁用
-
+    protected $hidden = ['nickname', 'mobile'];
 
 }