[色子游戏]玩家购买抽奖记录
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\controller\player_coin_record;
|
||||
|
||||
use plugin\saiadmin\basic\BaseController;
|
||||
use app\dice\logic\player_coin_record\DicePlayerCoinRecordLogic;
|
||||
use app\dice\validate\player_coin_record\DicePlayerCoinRecordValidate;
|
||||
use plugin\saiadmin\service\Permission;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* 玩家购买抽奖记录控制器
|
||||
*/
|
||||
class DicePlayerCoinRecordController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = new DicePlayerCoinRecordLogic();
|
||||
$this->validate = new DicePlayerCoinRecordValidate;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家购买抽奖记录列表', 'dice:player_coin_record:index:index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$where = $request->more([
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
$query->with([
|
||||
'dicePlayer',
|
||||
]);
|
||||
$data = $this->logic->getList($query);
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取数据
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Permission('玩家购买抽奖记录读取', 'dice:player_coin_record: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:player_coin_record: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:player_coin_record: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:player_coin_record: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\player_coin_record;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseLogic;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
use plugin\saiadmin\utils\Helper;
|
||||
use app\dice\model\player_coin_record\DicePlayerCoinRecord;
|
||||
|
||||
/**
|
||||
* 玩家购买抽奖记录逻辑层
|
||||
*/
|
||||
class DicePlayerCoinRecordLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new DicePlayerCoinRecord();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\model\player_coin_record;
|
||||
|
||||
use plugin\saiadmin\basic\think\BaseModel;
|
||||
|
||||
/**
|
||||
* 玩家购买抽奖记录模型
|
||||
*
|
||||
* dice_player_coin_record 玩家购买抽奖记录
|
||||
*
|
||||
* @property $id ID
|
||||
* @property $player_id 玩家id
|
||||
* @property $use_coins 消耗硬币
|
||||
* @property $total_draw_count 总抽奖次数
|
||||
* @property $paid_draw_count 购买抽奖次数
|
||||
* @property $free_draw_count 赠送抽奖次数
|
||||
* @property $remark 备注
|
||||
* @property $create_time 创建时间
|
||||
* @property $update_time 修改时间
|
||||
*/
|
||||
class DicePlayerCoinRecord extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 数据表主键
|
||||
* @var string
|
||||
*/
|
||||
protected $pk = 'id';
|
||||
|
||||
/**
|
||||
* 数据库表名称
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'dice_player_coin_record';
|
||||
|
||||
/**
|
||||
* 关联模型 dicePlayer
|
||||
*/
|
||||
public function dicePlayer()
|
||||
{
|
||||
return $this->belongsTo(DicePlayer::class, 'player_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | saiadmin [ saiadmin快速开发框架 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: your name
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\dice\validate\player_coin_record;
|
||||
|
||||
use plugin\saiadmin\basic\BaseValidate;
|
||||
|
||||
/**
|
||||
* 玩家购买抽奖记录验证器
|
||||
*/
|
||||
class DicePlayerCoinRecordValidate extends BaseValidate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'player_id' => 'require',
|
||||
'use_coins' => 'require',
|
||||
'total_draw_count' => 'require',
|
||||
'paid_draw_count' => 'require',
|
||||
'free_draw_count' => 'require',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
*/
|
||||
protected $message = [
|
||||
'player_id' => '玩家id必须填写',
|
||||
'use_coins' => '消耗硬币必须填写',
|
||||
'total_draw_count' => '总抽奖次数必须填写',
|
||||
'paid_draw_count' => '购买抽奖次数必须填写',
|
||||
'free_draw_count' => '赠送抽奖次数必须填写',
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'save' => [
|
||||
'player_id',
|
||||
'use_coins',
|
||||
'total_draw_count',
|
||||
'paid_draw_count',
|
||||
'free_draw_count',
|
||||
],
|
||||
'update' => [
|
||||
'player_id',
|
||||
'use_coins',
|
||||
'total_draw_count',
|
||||
'paid_draw_count',
|
||||
'free_draw_count',
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user