Переглянути джерело

Merge branch 'dev_wf' of wufeng/fuse into version1.5

wufeng 2 роки тому
батько
коміт
8349c061d7

+ 3 - 4
app/admin/config/validate_rules.php

@@ -120,10 +120,9 @@ return [
     ],
     //运营账号
     'adminAdd' => [
-        'username|账户' => 'require|max:255',
-        'nickname|昵称' => 'require|max:255',
-        'mobile|手机号' => 'require|mobile',
-        'role_id|角色' => 'require|number|gt:0'
+        'username|账号' => 'require|max:255',
+        'role_id|角色' => 'require|number|gt:0',
+        'card_id|卡类型' => 'require|array|max:100',
     ],
     //更改密码
     'adminChangePasswod' => [

+ 3 - 3
app/admin/controller/Admin.php

@@ -14,7 +14,7 @@ class Admin extends BaseController
     //获取运营账号列表
     public function list()
     {
-        $param = $this->request->only(['page' => 1, 'size' => 15, 'username' => '', 'nickname' => '', 'mobile' => '', 'status' => ''], 'post');
+        $param = $this->request->only(['page' => 1, 'size' => 15, 'username' => '','status' => ''], 'post');
 
         return AdminLogic::list($param);
     }
@@ -22,7 +22,7 @@ class Admin extends BaseController
     //添加运营账号
     public function add()
     {
-        $param = $this->request->only(['username', 'nickname', 'mobile', 'role_id'], 'post');
+        $param = $this->request->only(['username', 'role_id','card_id'], 'post');
 
         $val = Validate::rule(Config::get('validate_rules.adminAdd'));
 
@@ -41,7 +41,7 @@ class Admin extends BaseController
     //编辑运营账号
     public function edit()
     {
-        $param = $this->request->only(['id', 'username', 'nickname', 'mobile', 'role_id'], 'post');
+        $param = $this->request->only(['id', 'username', 'role_id','card_id'], 'post');
 
         $val = Validate::rule(array_merge(['id' => 'require|number|gt:0'], Config::get('validate_rules.adminAdd')));
 

+ 8 - 0
app/admin/controller/Card.php

@@ -23,6 +23,14 @@ class Card extends BaseController
         return CardLogic::list($param);
     }
 
+    //获取全部卡类型
+    public function all()
+    {
+        $keyword = $this->request->post('keyword', '');
+
+        return CardLogic::all($keyword);
+    }
+
     //添加卡类型
     public function add()
     {

+ 3 - 1
app/admin/controller/Role.php

@@ -32,7 +32,9 @@ class Role extends BaseController
     //获取全部角色
     public function all()
     {
-        return RoleLogic::all();
+        $keyword = $this->request->post('keyword', '');
+
+        return RoleLogic::all($keyword);
     }
 
     //添加角色

+ 16 - 3
app/admin/logic/AdminLogic.php

@@ -4,6 +4,7 @@ namespace app\admin\logic;
 
 use app\admin\controller\Common;
 use app\model\AdminModel;
+use app\model\CardModel;
 use app\model\CommonModel;
 use think\exception\ValidateException;
 use think\facade\Config;
@@ -19,13 +20,20 @@ class AdminLogic extends BaseLogic
             ->where('a.is_del', CommonModel::$del_normal);
 
         if ($data['username'] != '') $db->whereLike('a.username', '%' . $data['username'] . '%');
-        if ($data['nickname'] != '') $db->whereLike('a.nickname', '%' . $data['nickname'] . '%');
-        if ($data['mobile'] != '') $db->whereLike('a.mobile', '%' . $data['mobile'] . '%');
         if ($data['status'] != '') $db->where('a.status', $data['status']);
 
         $count = $db->count('a.id');
 
-        $list = $db->field('a.id,a.username,a.nickname,a.mobile,a.status,a.addtime,b.name as role_name')
+        $list = $db->field('a.id,a.username,a.status,a.addtime,b.name as role_name,a.card_id')
+            ->append(['card_name'])
+            ->withAttr('card_name', function ($val, $da) {
+                return CardModel::field('id,title,status')
+                    ->whereIn('id', $da['card_id'])
+                    ->where('is_del', CommonModel::$del_normal)
+                    ->order(['id' => 'desc'])
+                    ->select()
+                    ->toArray();
+            })
             ->order(['a.id' => 'desc'])
             ->page($data['page'], $data['size'])
             ->select()
@@ -45,6 +53,7 @@ class AdminLogic extends BaseLogic
             'status' => CommonModel::$status_normal,
             'addtime' => date('Y-m-d H:i:s'),
             'updatetime' => date('Y-m-d H:i:s'),
+            'card_id' => implode(',', $data['card_id'])
         ]);
 
         $rs = AdminModel::create($data)->save();
@@ -57,6 +66,9 @@ class AdminLogic extends BaseLogic
     {
         $rs = AdminModel::where(['id' => $id, 'is_del' => CommonModel::$del_normal])
             ->withoutField('password,salt')
+            ->withAttr('card_id', function ($val) {
+                return explode(',', $val);
+            })
             ->findOrEmpty()
             ->toArray();
 
@@ -67,6 +79,7 @@ class AdminLogic extends BaseLogic
     public static function edit(array $data = []): Json
     {
         $data = array_merge($data, [
+            'card_id' => implode(',', $data['card_id']),
             'updatetime' => date('Y-m-d H:i:s'),
         ]);
 

+ 15 - 0
app/admin/logic/CardLogic.php

@@ -28,6 +28,21 @@ class CardLogic extends BaseLogic
 
     }
 
+    //获取全部卡类型
+    public static function all(string $keyword = ''): Json
+    {
+        $db = CardModel::where('is_del', CommonModel::$del_normal);
+        if ($keyword != '') $db->whereLike('title', '%' . $keyword . '%');
+
+        $list = $db->field('id,title,status')
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+
+        return json_show(CommonModel::$success, '获取卡类型列表成功', $list);
+
+    }
+
     //添加卡类型
     public static function add(array $data = []): Json
     {

+ 7 - 3
app/admin/logic/RoleLogic.php

@@ -30,13 +30,17 @@ class RoleLogic extends BaseLogic
     }
 
     //获取全部角色
-    public static function all(): Json
+    public static function all(string $keyword = ''): Json
     {
-        $list = RoleModel::where('is_del', CommonModel::$del_normal)
+        $db = RoleModel::where('is_del', CommonModel::$del_normal)
             ->field('id,name,level,status')
-            ->order(['id' => 'desc'])
+            ->order(['id' => 'desc']);
+        if ($keyword != '') $db->whereLike('name', '%' . $keyword . '%');
+
+        $list = $db
             ->select()
             ->toArray();
+
         return json_show(CommonModel::$success, '获取获取全部角色成功', $list);
     }
 

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

@@ -55,6 +55,7 @@ Route::rule('videoDelete', 'admin/Video/delete');//删除视频
 
 //【卡类型】
 Route::rule('cardList', 'admin/Card/list');//获取卡类型列表
+Route::rule('cardAll', 'admin/Card/all');//获取全部卡类型
 Route::rule('cardAdd', 'admin/Card/add');//添加卡类型
 Route::rule('cardRead', 'admin/Card/read');//获取卡类型详情
 Route::rule('cardEdit', 'admin/Card/edit');//编辑卡类型

+ 2 - 0
app/model/AdminModel.php

@@ -13,6 +13,8 @@ class AdminModel extends Model
     protected $pk = 'id';
     protected $autoWriteTimestamp = 'datetime';
 
+    protected $hidden=['nickname','mobile'];
+
     //是否删除
     public static $del_normal=0;//未删除
     public static $del_deleted=1;//已删除