|
@@ -19,6 +19,50 @@ class GameGroupLogic extends BaseLogic
|
|
|
$this->model = new GameGroup();
|
|
$this->model = new GameGroup();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 读取列表
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getList($query): mixed
|
|
|
|
|
+ {
|
|
|
|
|
+ $page = request()->input('page') ? request()->input('page') : 1;
|
|
|
|
|
+ $limit = request()->input('limit') ? request()->input('limit') : 10;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $list = $this->model->order('sort', 'desc')->paginate($limit, false, ['page' => $page])->toArray();
|
|
|
|
|
+
|
|
|
|
|
+ $gameList = Db::connect('db_center')->table('pf_game')->column('name', 'id');
|
|
|
|
|
+ foreach ($gameList as $id => &$name) {
|
|
|
|
|
+ $name = '[' . $id . ']' . $name;
|
|
|
|
|
+ }
|
|
|
|
|
+ $gameList = array_column($gameList, null, 'id');
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($list['data'] as $key => $value) {
|
|
|
|
|
+ $gameIds = explode(',', $value['game_list']);
|
|
|
|
|
+ foreach ($gameIds as $gameId) {
|
|
|
|
|
+ $list['data'][$key]['children'][] = [
|
|
|
|
|
+ 'id' => $gameId,
|
|
|
|
|
+ 'name' => $gameList[$gameId],
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $total = $this->model->count();
|
|
|
|
|
+ $last_page = ceil($total/$limit);
|
|
|
|
|
+ $startIndex = ($page - 1) * $limit;
|
|
|
|
|
+ $pageData = array_slice($list['data'], $startIndex, $limit);
|
|
|
|
|
+
|
|
|
|
|
+ return [
|
|
|
|
|
+ 'data' => $pageData,
|
|
|
|
|
+ 'current_page' => $page,
|
|
|
|
|
+ 'per_page' => $limit,
|
|
|
|
|
+ 'last_page' => $last_page,
|
|
|
|
|
+ 'total' => $total,
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ // return $this->model->order('sort', 'desc')->paginate($limit, false, ['page' => $page])->toArray();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 读取数据
|
|
* 读取数据
|
|
|
* @param $id
|
|
* @param $id
|