1.新增游戏管理接口和菜单
2.创建对接第三方文档
This commit is contained in:
89
server/app/dice/controller/game/DiceGameController.php
Normal file
89
server/app/dice/controller/game/DiceGameController.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\game;
|
||||
|
||||
use app\dice\logic\game\DiceGameLogic;
|
||||
use app\dice\validate\game\DiceGameValidate;
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 游戏管理控制器
|
||||
*/
|
||||
class DiceGameController extends BaseController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = new DiceGameLogic();
|
||||
$this->validate = new DiceGameValidate();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
#[Permission('游戏管理列表', 'dice:game:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
['provider_code', ''],
|
||||
['game_code', ''],
|
||||
['game_type', ''],
|
||||
['status', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$data = $this->logic->getList($query);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
#[Permission('游戏管理读取', 'dice:game:index:read')]
|
||||
public function read(Request $request): Response
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if (!$model) {
|
||||
return $this->fail('not found');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
#[Permission('游戏管理添加', 'dice:game:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if (!$result) {
|
||||
return $this->fail('add failed');
|
||||
}
|
||||
return $this->success('add success');
|
||||
}
|
||||
|
||||
#[Permission('游戏管理修改', 'dice:game:index:update')]
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('update', $data);
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if (!$result) {
|
||||
return $this->fail('update failed');
|
||||
}
|
||||
return $this->success('update success');
|
||||
}
|
||||
|
||||
#[Permission('游戏管理删除', 'dice:game:index:destroy')]
|
||||
public function destroy(Request $request): Response
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if ($ids === '' || $ids === null) {
|
||||
return $this->fail('please select data to delete');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if (!$result) {
|
||||
return $this->fail('delete failed');
|
||||
}
|
||||
return $this->success('delete success');
|
||||
}
|
||||
}
|
||||
19
server/app/dice/logic/game/DiceGameLogic.php
Normal file
19
server/app/dice/logic/game/DiceGameLogic.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\logic\game;
|
||||
|
||||
use plugin\saiadmin\basic\eloquent\BaseLogic;
|
||||
use app\dice\model\game\DiceGame;
|
||||
|
||||
/**
|
||||
* 游戏管理逻辑层
|
||||
*/
|
||||
class DiceGameLogic extends BaseLogic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DiceGame();
|
||||
}
|
||||
}
|
||||
53
server/app/dice/model/game/DiceGame.php
Normal file
53
server/app/dice/model/game/DiceGame.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\game;
|
||||
|
||||
use plugin\saiadmin\basic\eloquent\BaseModel;
|
||||
|
||||
/**
|
||||
* 游戏管理模型
|
||||
*
|
||||
* dice_game 游戏配置表
|
||||
*/
|
||||
class DiceGame extends BaseModel
|
||||
{
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $table = 'dice_game';
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
public function searchProviderCodeAttr($query, $value): void
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$query->where('provider_code', '=', $value);
|
||||
}
|
||||
|
||||
public function searchGameCodeAttr($query, $value): void
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$query->where('game_code', 'like', '%' . $value . '%');
|
||||
}
|
||||
|
||||
public function searchGameTypeAttr($query, $value): void
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$query->where('game_type', '=', $value);
|
||||
}
|
||||
|
||||
public function searchStatusAttr($query, $value): void
|
||||
{
|
||||
if ($value === '' || $value === null) {
|
||||
return;
|
||||
}
|
||||
$query->where('status', '=', $value);
|
||||
}
|
||||
}
|
||||
61
server/app/dice/validate/game/DiceGameValidate.php
Normal file
61
server/app/dice/validate/game/DiceGameValidate.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\validate\game;
|
||||
|
||||
use plugin\saiadmin\basic\BaseValidate;
|
||||
|
||||
/**
|
||||
* 游戏管理验证器
|
||||
*/
|
||||
class DiceGameValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'provider' => 'require|max:64',
|
||||
'provider_code' => 'require|max:32',
|
||||
'game_code' => 'require|max:64',
|
||||
'game_key' => 'require|max:64',
|
||||
'game_name' => 'require|max:128',
|
||||
'game_name_en' => 'max:128',
|
||||
'game_type' => 'require|max:32',
|
||||
'status' => 'require|in:0,1',
|
||||
'sort' => 'number',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'provider' => 'provider 必填',
|
||||
'provider_code' => 'provider_code 必填',
|
||||
'game_code' => 'game_code 必填',
|
||||
'game_key' => 'game_key 必填',
|
||||
'game_name' => 'game_name 必填',
|
||||
'game_type' => 'game_type 必填',
|
||||
'status' => 'status 仅支持 0 或 1',
|
||||
'sort' => 'sort 必须为数字',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'save' => [
|
||||
'provider',
|
||||
'provider_code',
|
||||
'game_code',
|
||||
'game_key',
|
||||
'game_name',
|
||||
'game_name_en',
|
||||
'game_type',
|
||||
'status',
|
||||
'sort',
|
||||
],
|
||||
'update' => [
|
||||
'provider',
|
||||
'provider_code',
|
||||
'game_code',
|
||||
'game_key',
|
||||
'game_name',
|
||||
'game_name_en',
|
||||
'game_type',
|
||||
'status',
|
||||
'sort',
|
||||
],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user