1.将部门修改为渠道,并且所有dice_表关联渠道表
2.将所有配置表,记录表设置关联渠道 3.优化后台页面设置
This commit is contained in:
@@ -53,7 +53,7 @@ class DicePlayRecordController extends BaseController
|
||||
['direction', ''],
|
||||
]);
|
||||
$query = $this->logic->search($where);
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null);
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null, $request->input('dept_id'));
|
||||
$query->with([
|
||||
'dicePlayer',
|
||||
'diceLotteryPoolConfig',
|
||||
@@ -78,7 +78,7 @@ class DicePlayRecordController extends BaseController
|
||||
public function getPlayerOptions(Request $request): Response
|
||||
{
|
||||
$query = DicePlayer::field('id,username');
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null);
|
||||
AdminScopeHelper::applyAdminScope($query, $this->adminInfo ?? null, $request->input('dept_id'));
|
||||
$list = $query->select();
|
||||
$data = $list->map(function ($item) {
|
||||
return ['id' => $item['id'], 'username' => $item['username'] ?? ''];
|
||||
@@ -92,9 +92,15 @@ class DicePlayRecordController extends BaseController
|
||||
#[Permission('玩家抽奖记录列表', 'dice:play_record:index:index')]
|
||||
public function getLotteryConfigOptions(Request $request): Response
|
||||
{
|
||||
$list = DiceLotteryPoolConfig::field('id,name')->select();
|
||||
$query = DiceLotteryPoolConfig::field('id,name')->order('id', 'asc');
|
||||
$requestDeptId = AdminScopeHelper::pickRequestDeptId(
|
||||
$request->input('dept_id'),
|
||||
$request->all()
|
||||
);
|
||||
AdminScopeHelper::applyConfigScope($query, $this->adminInfo ?? null, $requestDeptId);
|
||||
$list = $query->select();
|
||||
$data = $list->map(function ($item) {
|
||||
return ['id' => $item['id'], 'name' => $item['name'] ?? ''];
|
||||
return ['id' => (int) $item['id'], 'name' => (string) ($item['name'] ?? '')];
|
||||
})->toArray();
|
||||
return $this->success($data);
|
||||
}
|
||||
@@ -112,8 +118,7 @@ class DicePlayRecordController extends BaseController
|
||||
if (!$model) {
|
||||
return $this->fail('not found');
|
||||
}
|
||||
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
|
||||
if (!AdminScopeHelper::canAccessDept($this->adminInfo ?? null, $model->dept_id ?? null)) {
|
||||
return $this->fail('no permission to view this record');
|
||||
}
|
||||
$data = is_array($model) ? $model : $model->toArray();
|
||||
@@ -130,6 +135,7 @@ class DicePlayRecordController extends BaseController
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('save', $data);
|
||||
AdminScopeHelper::prepareBusinessSaveData($data, $this->adminInfo ?? null, $request->input('dept_id'), $data);
|
||||
$result = $this->logic->add($data);
|
||||
if ($result) {
|
||||
return $this->success('add success');
|
||||
@@ -148,6 +154,13 @@ class DicePlayRecordController extends BaseController
|
||||
{
|
||||
$data = $request->post();
|
||||
$this->validate('update', $data);
|
||||
$model = $this->logic->read($data['id'] ?? 0);
|
||||
if ($model) {
|
||||
$recordDeptId = is_array($model) ? ($model['dept_id'] ?? null) : ($model->dept_id ?? null);
|
||||
if (! AdminScopeHelper::canAccessDept($this->adminInfo ?? null, $recordDeptId, $request->input('dept_id'))) {
|
||||
return $this->fail('no permission to update this record');
|
||||
}
|
||||
}
|
||||
$result = $this->logic->edit($data['id'], $data);
|
||||
if ($result) {
|
||||
return $this->success('update success');
|
||||
|
||||
Reference in New Issue
Block a user