[色子游戏]奖池配置-优化样式
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\reward_config;
|
||||
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use app\dice\logic\reward_config\DiceRewardConfigLogic;
|
||||
use app\dice\validate\reward_config\DiceRewardConfigValidate;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 奖励配置控制器
|
||||
*/
|
||||
class DiceRewardConfigController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = new DiceRewardConfigLogic();
|
||||
$this->validate = new DiceRewardConfigValidate;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置列表', 'dice:reward_config:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
['grid_number_min', ''],
|
||||
['grid_number_max', ''],
|
||||
['ui_text', ''],
|
||||
['real_ev_min', ''],
|
||||
['real_ev_max', ''],
|
||||
['tier', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$data = $this->logic->getList($query);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置读取', 'dice:reward_config:index:read')]
|
||||
public function read(Request $request): Response
|
||||
{
|
||||
$id = $request->input('id', '');
|
||||
$model = $this->logic->read($id);
|
||||
if ($model) {
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
return $this->success($data);
|
||||
} else {
|
||||
return $this->fail('未查找到信息');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置添加', 'dice:reward_config:index:save')]
|
||||
public function save(Request $request): Response
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('添加成功');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置修改', 'dice:reward_config: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->success('修改成功');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('奖励配置删除', 'dice:reward_config:index:destroy')]
|
||||
public function destroy(Request $request): Response
|
||||
{
|
||||
$ids = $request->post('ids', '');
|
||||
if (empty($ids)) {
|
||||
return $this->fail('请选择要删除的数据');
|
||||
}
|
||||
$result = $this->logic->destroy($ids);
|
||||
if ($result) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\logic\reward_config;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseLogic;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use plugin\saiadmin\utils\Helper;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
|
||||
/**
|
||||
* 奖励配置逻辑层
|
||||
*/
|
||||
class DiceRewardConfigLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DiceRewardConfig();
|
||||
}
|
||||
|
||||
}
|
||||
86
server/app/dice/model/reward_config/DiceRewardConfig.php
Normal file
86
server/app/dice/model/reward_config/DiceRewardConfig.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\reward_config;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
|
||||
/**
|
||||
* 奖励配置模型
|
||||
*
|
||||
* dice_reward_config 奖励配置
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $grid_number 色子点数
|
||||
* @property $ui_text 前端显示文本
|
||||
* @property $real_ev 真实资金结算
|
||||
* @property $tier 所属档位
|
||||
* @property $remark 备注
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
*/
|
||||
class DiceRewardConfig extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 数据库表名称
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'dice_reward_config';
|
||||
|
||||
/** 色子点数下限 */
|
||||
public function searchGridNumberMinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('grid_number', '>=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 色子点数上限 */
|
||||
public function searchGridNumberMaxAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('grid_number', '<=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 前端显示文本模糊 */
|
||||
public function searchUiTextAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('ui_text', 'like', '%' . $value . '%');
|
||||
}
|
||||
}
|
||||
|
||||
/** 真实资金结算下限 */
|
||||
public function searchRealEvMinAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('real_ev', '>=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 真实资金结算上限 */
|
||||
public function searchRealEvMaxAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('real_ev', '<=', $value);
|
||||
}
|
||||
}
|
||||
|
||||
/** 所属档位 */
|
||||
public function searchTierAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
$query->where('tier', '=', $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\validate\reward_config;
|
||||
|
||||
use plugin\saiadmin\basic\BaseValidate;
|
||||
|
||||
/**
|
||||
* 奖励配置验证器
|
||||
*/
|
||||
class DiceRewardConfigValidate extends BaseValidate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'grid_number' => 'require',
|
||||
'ui_text' => 'require',
|
||||
'real_ev' => 'require',
|
||||
'tier' => 'require',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
*/
|
||||
protected $message = [
|
||||
'grid_number' => '色子点数必须填写',
|
||||
'ui_text' => '前端显示文本必须填写',
|
||||
'real_ev' => '真实资金结算必须填写',
|
||||
'tier' => '所属档位必须填写',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'save' => [
|
||||
'grid_number',
|
||||
'ui_text',
|
||||
'real_ev',
|
||||
'tier',
|
||||
],
|
||||
'update' => [
|
||||
'grid_number',
|
||||
'ui_text',
|
||||
'real_ev',
|
||||
'tier',
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user