Browse Source

1. 产品归属
2. 游戏分组

ith5 6 tháng trước cách đây
mục cha
commit
1b00422df3

+ 62 - 0
app/v1/controller/center/GameGroupController.php

@@ -0,0 +1,62 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\controller\center;
+
+use plugin\saiadmin\basic\BaseController;
+use app\v1\logic\center\GameGroupLogic;
+use app\v1\validate\center\GameGroupValidate;
+use support\Request;
+use support\Response;
+use support\think\Db;
+
+/**
+ * 游戏分组控制器
+ */
+class GameGroupController extends BaseController
+{
+    /**
+     * 构造函数
+     */
+    public function __construct()
+    {
+        $this->logic = new GameGroupLogic();
+        $this->validate = new GameGroupValidate;
+        parent::__construct();
+    }
+
+
+    /**
+     * 数据列表
+     * @param Request $request
+     * @return Response
+     */
+    public function index(Request $request): Response
+    {
+        $where = $request->more([
+            ['name', ''],
+        ]);
+        $query = $this->logic->search($where);
+        $query->order('sort', 'desc');
+        $data = $this->logic->getList($query);
+
+        $allGameList =  Db::connect('db_center')->table('pf_game')->field('id,name')->select()->toArray();
+        $allGameList = array_column($allGameList, 'name', 'id');
+
+        foreach ($data['data'] as $key => $value) {
+            $gameList = [];
+            $game_list = explode(',', $value['game_list']);
+            foreach ($game_list as $game_id) {
+                $gameList[] = $allGameList[$game_id] ?? '';
+            }
+            $data['data'][$key]['game_list_str'] = $gameList;
+          
+        }
+
+        return $this->success($data);
+    }
+
+}

+ 1 - 1
app/v1/controller/center/GameMainController.php

@@ -13,7 +13,7 @@ use support\Request;
 use support\Response;
 
 /**
- * 主包管理控制器
+ * 产品管理控制器
  */
 class GameMainController extends BaseController
 {

+ 47 - 0
app/v1/logic/center/GameGroupLogic.php

@@ -0,0 +1,47 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\logic\center;
+
+use plugin\saiadmin\basic\BaseLogic;
+use plugin\saiadmin\exception\ApiException;
+use plugin\saiadmin\utils\Helper;
+use app\v1\model\center\GameGroup;
+use support\think\Db;
+
+/**
+ * 游戏分组逻辑层
+ */
+class GameGroupLogic extends BaseLogic
+{
+    /**
+     * 构造函数
+     */
+    public function __construct()
+    {
+        $this->model = new GameGroup();
+    }
+    
+    /**
+     * 读取数据
+     * @param $id
+     * @return mixed
+     */
+    public function read($id): mixed
+    {
+        $data = $this->model->where('id', $id)->find();
+        $game_list = explode(',', $data['game_list']);
+        $allGameList =  Db::connect('db_center')->table('pf_game')->field('id,name')->select()->toArray();
+        $allGameList = array_column($allGameList, 'name', 'id');
+        $gameList = [];
+        foreach ($game_list as $game_id) {
+            $gameList[] = $allGameList[$game_id] ?? '';
+        }
+        $data['game_list_str'] = $gameList;
+        return $data;
+    }
+
+}

+ 1 - 1
app/v1/logic/center/GameMainLogic.php

@@ -13,7 +13,7 @@ use app\v1\model\center\GameMain;
 use plugin\saiadmin\app\model\system\SystemUser;
 
 /**
- * 主包管理逻辑层
+ * 产品管理逻辑层
  */
 class GameMainLogic extends BaseLogic
 {

+ 34 - 0
app/v1/model/center/GameGroup.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\model\center;
+
+use plugin\saiadmin\basic\BaseNormalModel;
+
+/**
+ * 游戏分组模型
+ */
+class GameGroup extends BaseNormalModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 数据库表名称
+     * @var string
+     */
+    protected $table = 'game_group';
+
+    /**
+     * 数据库连接
+     * @var string
+     */
+    protected $connection = 'db_center';
+
+}

+ 1 - 1
app/v1/model/center/GameMain.php

@@ -9,7 +9,7 @@ namespace app\v1\model\center;
 use plugin\saiadmin\basic\BaseModel;
 
 /**
- * 主包管理模型
+ * 产品管理模型
  */
 class GameMain extends BaseModel
 {

+ 42 - 0
app/v1/validate/center/GameGroupValidate.php

@@ -0,0 +1,42 @@
+<?php
+// +----------------------------------------------------------------------
+// | saiadmin [ saiadmin快速开发框架 ]
+// +----------------------------------------------------------------------
+// | Author: your name
+// +----------------------------------------------------------------------
+namespace app\v1\validate\center;
+
+use think\Validate;
+
+/**
+ * 游戏分组验证器
+ */
+class GameGroupValidate extends Validate
+{
+    /**
+     * 定义验证规则
+     */
+    protected $rule =   [
+        'name' => 'require',
+    ];
+
+    /**
+     * 定义错误信息
+     */
+    protected $message  =   [
+        'name' => '分组名必须填写',
+    ];
+
+    /**
+     * 定义场景
+     */
+    protected $scene = [
+        'save' => [
+            'name',
+        ],
+        'update' => [
+            'name',
+        ],
+    ];
+
+}

+ 1 - 1
app/v1/validate/center/GameMainValidate.php

@@ -9,7 +9,7 @@ namespace app\v1\validate\center;
 use think\Validate;
 
 /**
- * 主包管理验证器
+ * 产品管理验证器
  */
 class GameMainValidate extends Validate
 {

+ 1 - 1
app/v1/validate/center/GameValidate.php

@@ -30,7 +30,7 @@ class GameValidate extends Validate
      * 定义错误信息
      */
     protected $message  =   [
-        'main_id' => '主包归属ID必须填写',
+        'main_id' => '产品归属ID必须填写',
         'name' => '游戏名称必须填写',
         'os' => '平台必须选择',
         'divide' => '分成比例必须填写',