Compare commits

...

6 Commits

Author SHA1 Message Date
b1efeb8b31 管理员新增agent_id字段显示 2026-03-10 11:46:30 +08:00
275f94f96d 配置接口lang请求头 2026-03-10 11:42:39 +08:00
9452fd28e2 SystemUser新增agent_id字段 2026-03-10 10:54:40 +08:00
7716929447 移除渠道ChannelManage 2026-03-10 10:45:23 +08:00
a6d87d5c0d 修改渠道ChannelManage关联部门SystemDepart 2026-03-10 10:09:35 +08:00
e94ebd3fe6 优化页面样式 2026-03-10 09:59:24 +08:00
28 changed files with 272 additions and 1001 deletions

View File

@@ -1,7 +1,7 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title>SaiAdmin</title> <title>Dafuweng-Dice</title>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta <meta

View File

@@ -38,7 +38,7 @@ import { headerBarConfig } from './modules/headerBar'
const appConfig: SystemConfig = { const appConfig: SystemConfig = {
// 系统信息 // 系统信息
systemInfo: { systemInfo: {
name: 'SaiAdmin' // 系统名称 name: 'Dafuweng-Dice' // 系统名称
}, },
// 系统主题 // 系统主题
systemThemeStyles: { systemThemeStyles: {

View File

@@ -150,8 +150,8 @@
}, },
"login": { "login": {
"leftView": { "leftView": {
"title": "A backend system of beauty and efficiency", "title": "Monopoly Game Management",
"subTitle": "A sleek and practical interface for a great user experience" "subTitle": "Monopoly Game Management"
}, },
"title": "Welcome back", "title": "Welcome back",
"subTitle": "Please enter your account and password to login", "subTitle": "Please enter your account and password to login",

View File

@@ -150,8 +150,8 @@
}, },
"login": { "login": {
"leftView": { "leftView": {
"title": "一款兼具设计美学与高效开发的后台系统", "title": "大富翁游戏管理",
"subTitle": "美观实用的界面,经过视觉优化,确保卓越的用户体验" "subTitle": "大富翁游戏管理"
}, },
"title": "欢迎回来", "title": "欢迎回来",
"subTitle": "输入您的账号和密码登录", "subTitle": "输入您的账号和密码登录",

View File

@@ -1,85 +0,0 @@
import request from '@/utils/http'
/**
* 渠道 API接口
*/
export default {
/**
* 获取数据列表
* @param params 搜索参数
* @returns 数据列表
*/
list(params: Record<string, any>) {
return request.get<Api.Common.ApiPage>({
url: '/channel/manage/ChannelManage/index',
params
})
},
/**
* 读取数据
* @param id 数据ID
* @returns 数据详情
*/
read(id: number | string) {
return request.get<Api.Common.ApiData>({
url: '/channel/manage/ChannelManage/read?id=' + id
})
},
/**
* 创建数据
* @param params 数据参数
* @returns 执行结果
*/
save(params: Record<string, any>) {
return request.post<any>({
url: '/channel/manage/ChannelManage/save',
data: params
})
},
/**
* 更新数据
* @param params 数据参数
* @returns 执行结果
*/
update(params: Record<string, any>) {
return request.put<any>({
url: '/channel/manage/ChannelManage/update',
data: params
})
},
/**
* 删除数据
* @returns 执行结果
* @param params
*/
delete(params: Record<string, any>) {
return request.del<any>({
url: '/channel/manage/ChannelManage/destroy',
data: params
})
},
/**
* 仅更新状态(列表内开关用)
*/
updateStatus(params: { id: number | string; status: number }) {
return request.put<any>({
url: '/channel/manage/ChannelManage/updateStatus',
data: params
})
},
/**
* 获取管理员下拉列表SystemUser 的 id、username、realname
* @returns 管理员列表
*/
getAdminList() {
return request.get<Api.Common.ApiData>({
url: '/channel/manage/ChannelManage/getAdminList'
})
}
}

View File

@@ -1,178 +0,0 @@
<template>
<div class="art-full-height">
<!-- 搜索面板 -->
<TableSearch v-model="searchForm" @search="handleSearch" @reset="resetSearchParams" />
<ElCard class="art-table-card" shadow="never">
<!-- 表格头部 -->
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
<template #left>
<ElSpace wrap>
<ElButton
v-permission="'channel:manage:index:save'"
@click="showDialog('add')"
v-ripple
>
<template #icon>
<ArtSvgIcon icon="ri:add-fill" />
</template>
新增
</ElButton>
<ElButton
v-permission="'channel:manage:index:destroy'"
:disabled="selectedRows.length === 0"
@click="deleteSelectedRows(api.delete, refreshData)"
v-ripple
>
<template #icon>
<ArtSvgIcon icon="ri:delete-bin-5-line" />
</template>
删除
</ElButton>
</ElSpace>
</template>
</ArtTableHeader>
<!-- 表格 -->
<ArtTable
ref="tableRef"
rowKey="id"
:loading="loading"
:data="data"
:columns="columns"
:pagination="pagination"
@sort-change="handleSortChange"
@selection-change="handleSelectionChange"
@pagination:size-change="handleSizeChange"
@pagination:current-change="handleCurrentChange"
>
<!-- 状态开关直接修改 -->
<template #status="{ row }">
<ElSwitch
v-permission="'channel:manage:index:update'"
:model-value="row.status === 1"
:loading="row._statusLoading"
@change="(v: string | number | boolean) => handleStatusChange(row, v ? 1 : 0)"
/>
</template>
<!-- 操作列 -->
<template #operation="{ row }">
<div class="flex gap-2">
<SaButton
v-permission="'channel:manage:index:update'"
type="secondary"
@click="showDialog('edit', row)"
/>
<SaButton
v-permission="'channel:manage:index:destroy'"
type="error"
@click="deleteRow(row, api.delete, refreshData)"
/>
</div>
</template>
</ArtTable>
</ElCard>
<!-- 编辑弹窗 -->
<EditDialog
v-model="dialogVisible"
:dialog-type="dialogType"
:data="dialogData"
@success="refreshData"
/>
</div>
</template>
<script setup lang="ts">
import { useTable } from '@/hooks/core/useTable'
import { useSaiAdmin } from '@/composables/useSaiAdmin'
import api from '../../api/manage/index'
import TableSearch from './modules/table-search.vue'
import EditDialog from './modules/edit-dialog.vue'
// 搜索表单
const searchForm = ref({
name: undefined,
title: undefined,
status: undefined,
total_recharge: undefined,
total_withdrawal: undefined,
total_profit: undefined
})
// 搜索处理
const handleSearch = (params: Record<string, any>) => {
Object.assign(searchParams, params)
getData()
}
// 表格配置
const {
columns,
columnChecks,
data,
loading,
getData,
searchParams,
pagination,
resetSearchParams,
handleSortChange,
handleSizeChange,
handleCurrentChange,
refreshData
} = useTable({
core: {
apiFn: api.list,
columnsFactory: () => [
{ type: 'selection' },
{ prop: 'title', label: '标题' },
{ prop: 'status', label: '状态', useSlot: true },
{
prop: 'admin_id',
label: '管理员',
formatter: (row: Record<string, any>) => {
const admin = row.admin
if (!admin) return row.admin_id ?? '-'
return (
(admin.realname && String(admin.realname).trim()) || admin.username || `#${admin.id}`
)
}
},
{ prop: 'game_url', label: '游戏地址' },
{ prop: 'image', label: '图标', saiType: 'image' },
{ prop: 'agent', label: '代理agent' },
{ prop: 'ip_white', label: 'IP白名单' },
{ prop: 'total_recharge', label: '总充值' },
{ prop: 'total_withdrawal', label: '总提现' },
{ prop: 'total_profit', label: '总盈利' },
{ prop: 'player_count', label: '玩家数量' },
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
]
}
})
// 状态开关切换(列表内直接修改)
const handleStatusChange = async (row: Record<string, any>, status: number) => {
row._statusLoading = true
try {
await api.updateStatus({ id: row.id, status })
row.status = status
} catch {
refreshData()
} finally {
row._statusLoading = false
}
}
// 编辑配置
const {
dialogType,
dialogVisible,
dialogData,
showDialog,
deleteRow,
deleteSelectedRows,
handleSelectionChange,
selectedRows
} = useSaiAdmin()
</script>

View File

@@ -1,202 +0,0 @@
<template>
<el-dialog
v-model="visible"
:title="dialogType === 'add' ? '新增渠道' : '编辑渠道'"
width="600px"
align-center
:close-on-click-modal="false"
@close="handleClose"
>
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
<el-form-item label="名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入名称" />
</el-form-item>
<el-form-item label="标题" prop="title">
<el-input v-model="formData.title" placeholder="请输入标题" />
</el-form-item>
<el-form-item label="状态" prop="status">
<sa-switch v-model="formData.status" />
</el-form-item>
<el-form-item label="管理员" prop="admin_id">
<el-select
v-model="formData.admin_id"
placeholder="请选择管理员"
clearable
filterable
style="width: 100%"
:loading="adminOptionsLoading"
>
<el-option
v-for="item in adminOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="游戏地址" prop="game_url">
<el-input v-model="formData.game_url" placeholder="请输入游戏地址" />
</el-form-item>
<el-form-item label="图标" prop="image">
<sa-image-upload v-model="formData.image" :limit="1" :multiple="false" />
</el-form-item>
<el-form-item label="IP白名单" prop="ip_white">
<el-input v-model="formData.ip_white" placeholder="请输入IP白名单" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="handleSubmit">提交</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import api from '../../../api/manage/index'
import { ElMessage } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
interface Props {
modelValue: boolean
dialogType: string
data?: Record<string, any>
}
interface Emits {
(e: 'update:modelValue', value: boolean): void
(e: 'success'): void
}
const props = withDefaults(defineProps<Props>(), {
modelValue: false,
dialogType: 'add',
data: undefined
})
const emit = defineEmits<Emits>()
const formRef = ref<FormInstance>()
/**
* 弹窗显示状态双向绑定
*/
const visible = computed({
get: () => props.modelValue,
set: (value) => emit('update:modelValue', value)
})
/**
* 表单验证规则
*/
const rules = reactive<FormRules>({
name: [{ required: true, message: '名称必需填写', trigger: 'blur' }],
title: [{ required: true, message: '标题必需填写', trigger: 'blur' }],
admin_id: [{ required: true, message: '管理员必需填写', trigger: 'blur' }],
game_url: [{ required: true, message: '游戏地址必需填写', trigger: 'blur' }],
image: [{ required: true, message: '图标必需填写', trigger: 'blur' }]
})
/**
* 初始数据
*/
const initialFormData = {
id: null,
name: '',
title: '',
status: 1,
admin_id: null,
game_url: '',
image: '',
ip_white: ''
}
/**
* 表单数据
*/
const formData = reactive({ ...initialFormData })
/**
* 监听弹窗打开,初始化表单数据
*/
watch(
() => props.modelValue,
(newVal) => {
if (newVal) {
initPage()
}
}
)
/** 管理员下拉选项value=SystemUser.id, label=SystemUser.name远程关联 */
const adminOptions = ref<Array<{ id: number; name: string }>>([])
const adminOptionsLoading = ref(false)
const fetchAdminList = async () => {
adminOptionsLoading.value = true
try {
// 接口返回的已是 data 解包后的数组value=SystemUser.id, name=展示名)
const list = await api.getAdminList()
adminOptions.value = Array.isArray(list) ? list : []
} catch {
adminOptions.value = []
} finally {
adminOptionsLoading.value = false
}
}
/**
* 初始化页面数据
*/
const initPage = async () => {
// 先重置为初始值
Object.assign(formData, initialFormData)
await fetchAdminList()
// 如果有数据,则填充数据
if (props.data) {
await nextTick()
initForm()
}
}
/**
* 初始化表单数据
*/
const initForm = () => {
if (props.data) {
for (const key in formData) {
if (props.data[key] != null && props.data[key] != undefined) {
;(formData as any)[key] = props.data[key]
}
}
}
}
/**
* 关闭弹窗并重置表单
*/
const handleClose = () => {
visible.value = false
formRef.value?.resetFields()
}
/**
* 提交表单
*/
const handleSubmit = async () => {
if (!formRef.value) return
try {
await formRef.value.validate()
if (props.dialogType === 'add') {
await api.save(formData)
ElMessage.success('新增成功')
} else {
await api.update(formData)
ElMessage.success('修改成功')
}
emit('success')
handleClose()
} catch (error) {
console.log('表单验证失败:', error)
}
}
</script>

View File

@@ -1,92 +0,0 @@
<template>
<sa-search-bar
ref="searchBarRef"
v-model="formData"
label-width="100px"
:showExpand="false"
@reset="handleReset"
@search="handleSearch"
@expand="handleExpand"
>
<el-col v-bind="setSpan(6)">
<el-form-item label="名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入名称" clearable />
</el-form-item>
</el-col>
<el-col v-bind="setSpan(6)">
<el-form-item label="标题" prop="title">
<el-input v-model="formData.title" placeholder="请输入标题" clearable />
</el-form-item>
</el-col>
<el-col v-bind="setSpan(6)">
<el-form-item label="状态" prop="status">
<el-input v-model="formData.status" placeholder="请输入状态" clearable />
</el-form-item>
</el-col>
<el-col v-bind="setSpan(6)">
<el-form-item label="总充值" prop="total_recharge">
<el-input v-model="formData.total_recharge" placeholder="请输入总充值" clearable />
</el-form-item>
</el-col>
<el-col v-bind="setSpan(6)">
<el-form-item label="总提现" prop="total_withdrawal">
<el-input v-model="formData.total_withdrawal" placeholder="请输入总提现" clearable />
</el-form-item>
</el-col>
<el-col v-bind="setSpan(6)">
<el-form-item label="总盈利" prop="total_profit">
<el-input v-model="formData.total_profit" placeholder="请输入总盈利" clearable />
</el-form-item>
</el-col>
</sa-search-bar>
</template>
<script setup lang="ts">
interface Props {
modelValue: Record<string, any>
}
interface Emits {
(e: 'update:modelValue', value: Record<string, any>): void
(e: 'search', params: Record<string, any>): void
(e: 'reset'): void
}
const props = defineProps<Props>()
const emit = defineEmits<Emits>()
// 展开/收起
const isExpanded = ref<boolean>(false)
// 表单数据双向绑定
const searchBarRef = ref()
const formData = computed({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val)
})
// 重置
function handleReset() {
searchBarRef.value?.ref.resetFields()
emit('reset')
}
// 搜索
async function handleSearch() {
emit('search', formData.value)
}
// 展开/收起
function handleExpand(expanded: boolean) {
isExpanded.value = expanded
}
// 栅格占据的列数
const setSpan = (span: number) => {
return {
span: span,
xs: 24, // 手机:满宽显示
sm: span >= 12 ? span : 12, // 平板大于等于12保持否则用半宽
md: span >= 8 ? span : 8, // 中等屏幕大于等于8保持否则用三分之一宽
lg: span,
xl: span
}
}
</script>

View File

@@ -11,7 +11,7 @@ export default {
*/ */
list(params: Record<string, any>) { list(params: Record<string, any>) {
return request.get<Api.Common.ApiPage>({ return request.get<Api.Common.ApiPage>({
url: '/dice/player_wallet_record/DicePlayerWalletRecord/index', url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/index',
params params
}) })
}, },
@@ -23,7 +23,7 @@ export default {
*/ */
read(id: number | string) { read(id: number | string) {
return request.get<Api.Common.ApiData>({ return request.get<Api.Common.ApiData>({
url: '/dice/player_wallet_record/DicePlayerWalletRecord/read?id=' + id url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/read?id=' + id
}) })
}, },
@@ -34,7 +34,7 @@ export default {
*/ */
save(params: Record<string, any>) { save(params: Record<string, any>) {
return request.post<any>({ return request.post<any>({
url: '/dice/player_wallet_record/DicePlayerWalletRecord/save', url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/save',
data: params data: params
}) })
}, },
@@ -46,7 +46,7 @@ export default {
*/ */
update(params: Record<string, any>) { update(params: Record<string, any>) {
return request.put<any>({ return request.put<any>({
url: '/dice/player_wallet_record/DicePlayerWalletRecord/update', url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/update',
data: params data: params
}) })
}, },
@@ -58,7 +58,7 @@ export default {
*/ */
delete(params: Record<string, any>) { delete(params: Record<string, any>) {
return request.del<any>({ return request.del<any>({
url: '/dice/player_wallet_record/DicePlayerWalletRecord/destroy', url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/destroy',
data: params data: params
}) })
}, },
@@ -68,7 +68,7 @@ export default {
*/ */
getPlayerOptions() { getPlayerOptions() {
return request.get<{ id: number; username: string }[]>({ return request.get<{ id: number; username: string }[]>({
url: '/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerOptions' url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerOptions'
}) })
}, },
@@ -77,7 +77,7 @@ export default {
*/ */
getPlayerWalletBefore(playerId: number | string) { getPlayerWalletBefore(playerId: number | string) {
return request.get<{ wallet_before: number }>({ return request.get<{ wallet_before: number }>({
url: '/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerWalletBefore', url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerWalletBefore',
params: { player_id: playerId } params: { player_id: playerId }
}) })
}, },
@@ -93,7 +93,7 @@ export default {
remark?: string remark?: string
}) { }) {
return request.post<any>({ return request.post<any>({
url: '/dice/player_wallet_record/DicePlayerWalletRecord/adminOperate', url: '/core/dice/player_wallet_record/DicePlayerWalletRecord/adminOperate',
data: params data: params
}) })
} }

View File

@@ -11,7 +11,7 @@ export default {
*/ */
list(params: Record<string, any>) { list(params: Record<string, any>) {
return request.get<Api.Common.ApiPage>({ return request.get<Api.Common.ApiPage>({
url: '/dice/reward_config/DiceRewardConfig/index', url: '/core/dice/reward_config/DiceRewardConfig/index',
params params
}) })
}, },
@@ -23,7 +23,7 @@ export default {
*/ */
read(id: number | string) { read(id: number | string) {
return request.get<Api.Common.ApiData>({ return request.get<Api.Common.ApiData>({
url: '/dice/reward_config/DiceRewardConfig/read?id=' + id url: '/core/dice/reward_config/DiceRewardConfig/read?id=' + id
}) })
}, },
@@ -34,7 +34,7 @@ export default {
*/ */
save(params: Record<string, any>) { save(params: Record<string, any>) {
return request.post<any>({ return request.post<any>({
url: '/dice/reward_config/DiceRewardConfig/save', url: '/core/dice/reward_config/DiceRewardConfig/save',
data: params data: params
}) })
}, },
@@ -46,7 +46,7 @@ export default {
*/ */
update(params: Record<string, any>) { update(params: Record<string, any>) {
return request.put<any>({ return request.put<any>({
url: '/dice/reward_config/DiceRewardConfig/update', url: '/core/dice/reward_config/DiceRewardConfig/update',
data: params data: params
}) })
}, },
@@ -58,7 +58,7 @@ export default {
*/ */
delete(params: Record<string, any>) { delete(params: Record<string, any>) {
return request.del<any>({ return request.del<any>({
url: '/dice/reward_config/DiceRewardConfig/destroy', url: '/core/dice/reward_config/DiceRewardConfig/destroy',
data: params data: params
}) })
} }

View File

@@ -190,8 +190,15 @@
saiSecond: 'email' saiSecond: 'email'
}, },
{ prop: 'phone', label: '手机号', width: 120 }, { prop: 'phone', label: '手机号', width: 120 },
{ prop: 'depts.name', label: '部门', minWidth: 150 }, {
prop: 'dept_id',
label: '部门',
minWidth: 150,
sortable: true,
formatter: (row: any) => row.depts?.name ?? ''
},
{ prop: 'status', label: '状态', width: 80, saiType: 'dict', saiDict: 'data_status' }, { prop: 'status', label: '状态', width: 80, saiType: 'dict', saiDict: 'data_status' },
{ prop: 'agent_id', label: '代理ID', width: 120, showOverflowTooltip: true },
{ prop: 'dashboard', label: '首页', width: 100, saiType: 'dict', saiDict: 'dashboard' }, { prop: 'dashboard', label: '首页', width: 100, saiType: 'dict', saiDict: 'dashboard' },
{ prop: 'login_time', label: '上次登录', width: 170, sortable: true }, { prop: 'login_time', label: '上次登录', width: 170, sortable: true },
{ {

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace app\api\controller;
use app\api\util\ApiLang;
use plugin\saiadmin\basic\OpenController;
use support\Response;
/**
* API 控制器基类:根据请求头 langen=英文zh=中文)对返回 message 做双语适配
*/
class BaseController extends OpenController
{
/**
* 成功返回message 按请求头 langen/zh翻译
*/
public function success(array|string $data = [], string $msg = 'success', int $option = JSON_UNESCAPED_UNICODE): Response
{
if (is_string($data)) {
$msg = $data;
$data = [];
}
$msg = ApiLang::translate((string) $msg);
return parent::success($data, $msg, $option);
}
/**
* 失败返回message 按 lang 翻译
*/
public function fail(string $msg = 'fail', int $code = 400): Response
{
$msg = ApiLang::translate($msg);
return parent::fail($msg, $code);
}
}

View File

@@ -13,13 +13,14 @@ use app\dice\model\config\DiceConfig;
use app\dice\model\play_record\DicePlayRecord; use app\dice\model\play_record\DicePlayRecord;
use app\dice\model\player\DicePlayer; use app\dice\model\player\DicePlayer;
use app\dice\model\reward_config\DiceRewardConfig; use app\dice\model\reward_config\DiceRewardConfig;
use plugin\saiadmin\basic\OpenController; use app\api\controller\BaseController;
use app\api\util\ApiLang;
use plugin\saiadmin\exception\ApiException; use plugin\saiadmin\exception\ApiException;
/** /**
* 游戏相关接口(购买抽奖券等) * 游戏相关接口(购买抽奖券等)
*/ */
class GameController extends OpenController class GameController extends BaseController
{ {
/** /**
* 获取游戏配置(按 group 分组) * 获取游戏配置(按 group 分组)
@@ -115,7 +116,8 @@ class GameController extends OpenController
$minCoin = abs($minEv + 100); $minCoin = abs($minEv + 100);
$coin = (float) $player->coin; $coin = (float) $player->coin;
if ($coin < $minCoin) { if ($coin < $minCoin) {
return $this->success([], '当前玩家余额'.$coin.'小于'.$minCoin.'无法继续游戏'); $msg = ApiLang::translateParams('当前玩家余额%s小于%s无法继续游戏', [$coin, $minCoin], $request);
return $this->success([], $msg);
} }
try { try {

View File

@@ -10,13 +10,13 @@ use app\api\logic\UserLogic;
use app\api\util\ReturnCode; use app\api\util\ReturnCode;
use app\dice\model\play_record\DicePlayRecord; use app\dice\model\play_record\DicePlayRecord;
use app\dice\model\player_wallet_record\DicePlayerWalletRecord; use app\dice\model\player_wallet_record\DicePlayerWalletRecord;
use plugin\saiadmin\basic\OpenController; use app\api\controller\BaseController;
/** /**
* API 用户登录等 * API 用户登录等
* 登录接口 /api/user/Login 无需 token其余接口需在请求头携带 tokenbase64(username.-.time)),由 TokenMiddleware 鉴权并注入 request->player_id / request->player * 登录接口 /api/user/Login 无需 token其余接口需在请求头携带 tokenbase64(username.-.time)),由 TokenMiddleware 鉴权并注入 request->player_id / request->player
*/ */
class UserController extends OpenController class UserController extends BaseController
{ {
/** /**
* 登录form-data 参数) * 登录form-data 参数)

View File

@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace app\api\controller\v1; namespace app\api\controller\v1;
use app\api\cache\AuthTokenCache; use app\api\cache\AuthTokenCache;
use app\api\controller\BaseController;
use app\api\util\ReturnCode; use app\api\util\ReturnCode;
use plugin\saiadmin\basic\OpenController;
use support\Request; use support\Request;
use support\Response; use support\Response;
use Tinywan\Jwt\JwtToken; use Tinywan\Jwt\JwtToken;
@@ -16,7 +16,7 @@ use Tinywan\Jwt\JwtToken;
* GET 参数signature, secret, time, agent_id * GET 参数signature, secret, time, agent_id
* 签名signature = md5(agent_id.secret.time) * 签名signature = md5(agent_id.secret.time)
*/ */
class AuthTokenController extends OpenController class AuthTokenController extends BaseController
{ {
/** /**
* 获取 auth-token * 获取 auth-token

View File

@@ -10,7 +10,7 @@ use app\dice\model\play_record\DicePlayRecord;
use app\dice\model\player_wallet_record\DicePlayerWalletRecord; use app\dice\model\player_wallet_record\DicePlayerWalletRecord;
use app\dice\model\player_ticket_record\DicePlayerTicketRecord; use app\dice\model\player_ticket_record\DicePlayerTicketRecord;
use support\think\Db; use support\think\Db;
use plugin\saiadmin\basic\OpenController; use app\api\controller\BaseController;
use support\Request; use support\Request;
use support\Response; use support\Response;
@@ -18,7 +18,7 @@ use support\Response;
* 平台 v1 游戏接口 * 平台 v1 游戏接口
* 请求头auth-token * 请求头auth-token
*/ */
class GameController extends OpenController class GameController extends BaseController
{ {
/** /**
* 获取游戏地址 * 获取游戏地址

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
/**
* API 英文文案(请求头 lang=en 时使用)
* key 为中文原文value 为英文
*/
return [
'success' => 'Success',
'fail' => 'Fail',
'username、password 不能为空' => 'username and password are required',
'请携带 token' => 'Please provide token',
'token 无效' => 'Invalid or expired token',
'已退出登录' => 'Logged out successfully',
'用户不存在' => 'User not found',
'username 不能为空' => 'username is required',
'密码错误' => 'Wrong password',
'账号已被禁用,无法登录' => 'Account is disabled and cannot log in',
'购买抽奖券错误' => 'Invalid lottery ticket purchase',
'平台币不足' => 'Insufficient balance',
'direction 必须为 0 或 1' => 'direction must be 0 or 1',
'当前玩家余额%s小于%s无法继续游戏' => 'Balance %s is less than %s, cannot continue',
'服务超时,' => 'Service timeout: ',
'没有原因' => 'Unknown reason',
'缺少参数agent_id、secret、time、signature 不能为空' => 'Missing parameters: agent_id, secret, time, signature are required',
'服务端未配置 API_AUTH_TOKEN_SECRET' => 'API_AUTH_TOKEN_SECRET is not configured',
'密钥错误' => 'Invalid secret',
'时间戳已过期或无效,请同步时间' => 'Timestamp expired or invalid, please sync time',
'签名验证失败' => 'Signature verification failed',
'生成 token 失败' => 'Failed to generate token',
'coin 不能为空' => 'coin is required',
'coin 不能为 0' => 'coin cannot be 0',
'余额不足,无法转出' => 'Insufficient balance to transfer',
'操作失败:' => 'Operation failed: ',
'服务超时,没有原因' => 'Service timeout: Unknown reason',
// PlayStartLogic / GameLogic
'抽奖券不足' => 'Insufficient lottery tickets',
'奖池配置不存在' => 'Lottery config not found',
'该方向下暂无可用路径配置' => 'No path config available for this direction',
// UserLogic
'手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789' => 'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)',
// TokenMiddleware / Auth (api/user/*, api/game/*)
'请携带 auth-token' => 'Please provide auth-token',
'auth-token 已过期' => 'auth-token expired',
'auth-token 无效' => 'auth-token invalid',
'auth-token 格式无效' => 'auth-token format invalid',
'auth-token 无效或已失效' => 'auth-token invalid or expired',
'token 已过期,请重新登录' => 'Token expired, please login again',
'token 格式无效' => 'Token format invalid',
'请注册' => 'Please register',
'请重新登录' => 'Please login again',
'请重新登录(当前账号已在其他处登录)' => 'Please login again (account logged in elsewhere)',
];

View File

@@ -0,0 +1,72 @@
<?php
declare(strict_types=1);
namespace app\api\util;
use support\Request;
/**
* API 多语言:根据请求头 langen=英文zh=中文)翻译返回文案
*/
class ApiLang
{
private const LANG_HEADER = 'lang';
private const LANG_EN = 'en';
private const LANG_ZH = 'zh';
/** @var array<string, string>|null */
private static ?array $enMap = null;
/**
* 从请求中获取语言lang 请求头 en=英文zh=中文,默认 zh
*/
public static function getLang(?Request $request = null): string
{
$request = $request ?? (function_exists('request') ? request() : null);
if ($request === null) {
return self::LANG_ZH;
}
$lang = $request->header(self::LANG_HEADER);
if ($lang !== null && $lang !== '') {
$lang = strtolower(trim((string) $lang));
if ($lang === self::LANG_EN) {
return self::LANG_EN;
}
if ($lang === self::LANG_ZH || $lang === 'chs') {
return self::LANG_ZH;
}
}
return self::LANG_ZH;
}
/**
* 翻译文案:当前请求语言为 en 时返回英文,否则返回原文(中文)
* @param string $message 中文或原文
* @param Request|null $request 当前请求,不传则自动取 request()
*/
public static function translate(string $message, ?Request $request = null): string
{
$lang = self::getLang($request);
if ($lang !== self::LANG_EN) {
return $message;
}
if (self::$enMap === null) {
$path = dirname(__DIR__) . '/lang/en.php';
self::$enMap = is_file($path) ? (require $path) : [];
}
return self::$enMap[$message] ?? $message;
}
/**
* 带占位符的翻译,如 translateParams('当前玩家余额%s小于%s无法继续游戏', [$coin, $minCoin])
* 先翻译再替换en 文案使用 %s 占位)
*/
public static function translateParams(string $message, array $params = [], ?Request $request = null): string
{
$translated = self::translate($message, $request);
if ($params !== []) {
$translated = sprintf($translated, ...$params);
}
return $translated;
}
}

View File

@@ -1,217 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\channel\controller\manage;
use plugin\saiadmin\basic\BaseController;
use app\channel\logic\manage\ChannelManageLogic;
use app\channel\validate\manage\ChannelManageValidate;
use plugin\saiadmin\app\model\system\SystemUser;
use plugin\saiadmin\service\Permission;
use support\Request;
use support\Response;
/**
* 渠道控制器
*/
class ChannelManageController extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->logic = new ChannelManageLogic();
$this->validate = new ChannelManageValidate;
parent::__construct();
}
/**
* 数据列表
* @param Request $request
* @return Response
*/
#[Permission('渠道列表', 'channel:manage:index:index')]
public function index(Request $request): Response
{
$where = $request->more([
['name', ''],
['title', ''],
['status', ''],
['total_recharge', ''],
['total_withdrawal', ''],
['total_profit', ''],
]);
$query = $this->logic->search($where);
// 不使用 with('admin')SystemUser 为 Think 模型,与 Eloquent 混用会触发 getConnectionName 报错,改为手动填充
$data = $this->logic->getList($query);
$data['data'] = $this->attachAdminToRows($data['data'] ?? []);
return $this->success($data);
}
/**
* 读取数据
* @param Request $request
* @return Response
*/
#[Permission('渠道读取', 'channel:manage: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('渠道添加', 'channel:manage:index:save')]
public function save(Request $request): Response
{
$data = $request->post();
$data['agent'] = md5((string)($data['name'] ?? '') . (string)($data['admin_id'] ?? ''));
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
} else {
return $this->fail('添加失败');
}
}
/**
* 更新数据
* @param Request $request
* @return Response
*/
#[Permission('渠道修改', 'channel:manage:index:update')]
public function update(Request $request): Response
{
$data = $request->post();
$data['agent'] = md5((string)($data['name'] ?? '') . (string)($data['admin_id'] ?? ''));
$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('渠道管理-更新状态', 'channel:manage:index:update')]
public function updateStatus(Request $request): Response
{
$id = $request->input('id');
$status = $request->input('status');
if ($id === null || $id === '') {
return $this->fail('缺少 id');
}
if ($status === null || $status === '') {
return $this->fail('缺少 status');
}
$this->logic->edit($id, ['status' => (int) $status]);
return $this->success('修改成功');
}
/**
* 删除数据
* @param Request $request
* @return Response
*/
#[Permission('渠道删除', 'channel:manage: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('删除失败');
}
}
/**
* 获取管理员下拉列表(远程关联 SystemUservalue=id, label=name
* @param Request $request
* @return Response
*/
#[Permission('渠道管理员列表', 'channel:manage:index:index')]
public function getAdminList(Request $request): Response
{
$list = SystemUser::where('status', 1)
->field('id, username, realname')
->select();
$rows = $list->toArray();
$data = array_map(function ($row) {
$name = !empty($row['realname']) && trim($row['realname']) !== ''
? trim($row['realname'])
: ($row['username'] ?? '#' . $row['id']);
return [
'id' => $row['id'],
'name' => $name,
];
}, $rows);
return $this->success($data);
}
/**
* 为列表行附加管理员信息(避免 Eloquent with(Think 模型) 触发 getConnectionName 报错)
* @param array $rows 列表行,可为 Eloquent 模型或数组
* @return array 已附加 admin 的列表
*/
protected function attachAdminToRows(array $rows): array
{
if (empty($rows)) {
return $rows;
}
$adminIds = [];
foreach ($rows as $row) {
$id = is_array($row) ? ($row['admin_id'] ?? null) : $row->admin_id;
if ($id !== null && $id !== '') {
$adminIds[(string) $id] = true;
}
}
$adminIds = array_keys($adminIds);
if (empty($adminIds)) {
return $rows;
}
$admins = SystemUser::whereIn('id', $adminIds)
->field('id, username, realname')
->select()
->toArray();
$map = [];
foreach ($admins as $a) {
$map[(string) ($a['id'] ?? '')] = $a;
}
foreach ($rows as &$row) {
$aid = is_array($row) ? ($row['admin_id'] ?? null) : $row->admin_id;
$admin = $map[(string) ($aid ?? '')] ?? null;
if (is_array($row)) {
$row['admin'] = $admin;
} else {
$row->setAttribute('admin', $admin);
}
}
unset($row);
return $rows;
}
}

View File

@@ -1,27 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\channel\logic\manage;
use plugin\saiadmin\basic\eloquent\BaseLogic;
use plugin\saiadmin\exception\ApiException;
use plugin\saiadmin\utils\Helper;
use app\channel\model\manage\ChannelManage;
/**
* 渠道逻辑层
*/
class ChannelManageLogic extends BaseLogic
{
/**
* 构造函数
*/
public function __construct()
{
$this->model = new ChannelManage();
}
}

View File

@@ -1,103 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\channel\model\manage;
use plugin\saiadmin\app\model\system\SystemUser;
use plugin\saiadmin\basic\eloquent\BaseModel;
/**
* 渠道模型
*
* channel_manage 渠道
* @property $id ID
* @property $name 名称
* @property $title 标题
* @property $status 状态
* @property $admin_id 管理员
* @property $game_url 游戏地址
* @property $image 图标
* @property $agent 代理agent
* @property $ip_white IP白名单
* @property $total_recharge 总充值
* @property $total_withdrawal 总提现
* @property $total_profit 总盈利
* @property $player_count 玩家数量
* @property $create_time 创建时间
* @property $update_time 更新时间
*/
class ChannelManage extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $primaryKey = 'id';
/**
* 数据库表名称
* @var string
*/
protected $table = 'channel_manage';
/**
* 属性转换
*/
protected function casts(): array
{
return array_merge(parent::casts(), [
]);
}
/**
* 名称 搜索
*/
public function searchNameAttr($query, $value)
{
$query->where('name', 'like', '%'.$value.'%');
}
/**
* 标题 搜索
*/
public function searchTitleAttr($query, $value)
{
$query->where('title', 'like', '%'.$value.'%');
}
/**
* 总充值 搜索
*/
public function searchTotalRechargeAttr($query, $value)
{
$query->where('total_recharge', '>=', $value);
}
/**
* 总提现 搜索
*/
public function searchTotalWithdrawalAttr($query, $value)
{
$query->where('total_withdrawal', '>=', $value);
}
/**
* 总盈利 搜索
*/
public function searchTotalProfitAttr($query, $value)
{
$query->where('total_profit', '>=', $value);
}
/**
* 管理员
* 关联模型 systemUser
*/
public function admin(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(SystemUser::class, 'admin_id', 'id');
}
}

View File

@@ -1,58 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\channel\validate\manage;
use plugin\saiadmin\basic\BaseValidate;
/**
* 渠道验证器
*/
class ChannelManageValidate extends BaseValidate
{
/**
* 定义验证规则
*/
protected $rule = [
'name' => 'require',
'title' => 'require',
'admin_id' => 'require',
'game_url' => 'require',
'image' => 'require',
];
/**
* 定义错误信息
*/
protected $message = [
'name' => '名称必须填写',
'title' => '标题必须填写',
'admin_id' => '管理员必须填写',
'game_url' => '游戏地址必须填写',
'image' => '图标必须填写',
];
/**
* 定义场景agent 由后端按 md5(name.admin_id) 自动生成,无需校验)
*/
protected $scene = [
'save' => [
'name',
'title',
'admin_id',
'game_url',
'image',
],
'update' => [
'name',
'title',
'admin_id',
'game_url',
'image',
],
];
}

View File

@@ -117,7 +117,10 @@ class SystemDeptLogic extends BaseLogic
public function accessDept(array $where = []): array public function accessDept(array $where = []): array
{ {
$query = $this->search($where); $query = $this->search($where);
$query->auth($this->adminInfo['deptList']); // 超级管理员(id=1)可查看全部部门,普通管理员按部门权限过滤
if (isset($this->adminInfo['id']) && $this->adminInfo['id'] > 1) {
$query->auth($this->adminInfo['deptList'] ?? []);
}
$query->field('id, id as value, name as label, parent_id'); $query->field('id, id as value, name as label, parent_id');
$query->order('sort', 'desc'); $query->order('sort', 'desc');
$data = $this->getAll($query); $data = $this->getAll($query);

View File

@@ -40,7 +40,10 @@ class SystemUserLogic extends BaseLogic
{ {
$query = $this->search($where); $query = $this->search($where);
$query->with(['depts']); $query->with(['depts']);
$query->auth($this->adminInfo['deptList']); // 超级管理员(id=1)可查看全部用户,普通管理员按部门权限过滤
if (isset($this->adminInfo['id']) && $this->adminInfo['id'] > 1) {
$query->auth($this->adminInfo['deptList'] ?? []);
}
return $this->getList($query); return $this->getList($query);
} }
@@ -132,9 +135,11 @@ class SystemUserLogic extends BaseLogic
return $this->transaction(function () use ($data, $id) { return $this->transaction(function () use ($data, $id) {
$role_ids = $data['role_ids'] ?? []; $role_ids = $data['role_ids'] ?? [];
$post_ids = $data['post_ids'] ?? []; $post_ids = $data['post_ids'] ?? [];
// 仅可修改当前部门和子部门的用户 // 超级管理员可修改任意用户,普通管理员仅可修改当前部门和子部门的用户
$query = $this->model->where('id', $id); $query = $this->model->where('id', $id);
$query->auth($this->adminInfo['deptList']); if (isset($this->adminInfo['id']) && $this->adminInfo['id'] > 1) {
$query->auth($this->adminInfo['deptList'] ?? []);
}
$user = $query->findOrEmpty(); $user = $query->findOrEmpty();
if ($user->isEmpty()) { if ($user->isEmpty()) {
throw new ApiException('没有权限操作该数据'); throw new ApiException('没有权限操作该数据');
@@ -182,7 +187,10 @@ class SystemUserLogic extends BaseLogic
throw new ApiException('超级管理员禁止删除'); throw new ApiException('超级管理员禁止删除');
} }
$query = $this->model->where('id', $ids); $query = $this->model->where('id', $ids);
$query->auth($this->adminInfo['deptList']); // 超级管理员可删除任意用户,普通管理员仅可删除当前部门和子部门的用户
if (isset($this->adminInfo['id']) && $this->adminInfo['id'] > 1) {
$query->auth($this->adminInfo['deptList'] ?? []);
}
$user = $query->findOrEmpty(); $user = $query->findOrEmpty();
if ($user->isEmpty()) { if ($user->isEmpty()) {
throw new ApiException('没有权限操作该数据'); throw new ApiException('没有权限操作该数据');

View File

@@ -42,11 +42,14 @@ class SystemDept extends BaseModel
*/ */
public function scopeAuth($query, $value) public function scopeAuth($query, $value)
{ {
if (!empty($value)) { if (!empty($value) && isset($value['id'])) {
$deptIds = [$value['id']]; $deptIds = [$value['id']];
$deptLevel = $value['level'] . $value['id'] . ','; $level = $value['level'] ?? '';
$ids = static::whereLike('level', $deptLevel . '%')->column('id'); if ($level !== '' && $level !== null) {
$deptIds = array_merge($deptIds, $ids); $deptLevel = $level . $value['id'] . ',';
$ids = static::whereLike('level', $deptLevel . '%')->column('id');
$deptIds = array_merge($deptIds, $ids);
}
$query->whereIn('id', $deptIds); $query->whereIn('id', $deptIds);
} }
} }

View File

@@ -14,6 +14,7 @@ use plugin\saiadmin\basic\think\BaseModel;
* sa_system_user 用户表 * sa_system_user 用户表
* *
* @property $id * @property $id
* @property $agent_id 代理标识md5(id)唯一
* @property $username 登录账号 * @property $username 登录账号
* @property $password 加密密码 * @property $password 加密密码
* @property $realname 真实姓名 * @property $realname 真实姓名
@@ -49,6 +50,30 @@ class SystemUser extends BaseModel
*/ */
protected $table = 'sa_system_user'; protected $table = 'sa_system_user';
/**
* 插入后:自动填充 agent_id = md5(id),保证唯一
*/
public static function onAfterInsert($model): void
{
$id = $model->getAttr('id');
if ($id !== null && $id !== '') {
$agentId = md5((string) $id);
(new static())->where('id', $id)->update(['agent_id' => $agentId]);
}
}
/**
* 获取 agent_id若未存储则返回 md5(id)
*/
public function getAgentIdAttr($value, $data)
{
if ($value !== null && $value !== '') {
return $value;
}
$id = $data['id'] ?? null;
return $id !== null ? md5((string) $id) : '';
}
public function searchKeywordAttr($query, $value) public function searchKeywordAttr($query, $value)
{ {
if ($value) { if ($value) {

View File

@@ -82,6 +82,25 @@ Route::group('/core', function () {
Route::get("/server/cache", [\plugin\saiadmin\app\controller\system\SystemServerController::class, 'cache']); Route::get("/server/cache", [\plugin\saiadmin\app\controller\system\SystemServerController::class, 'cache']);
Route::post("/server/clear", [\plugin\saiadmin\app\controller\system\SystemServerController::class, 'clear']); Route::post("/server/clear", [\plugin\saiadmin\app\controller\system\SystemServerController::class, 'clear']);
// 大富翁 Dice 模块
fastRoute('dice/config/DiceConfig', \app\dice\controller\config\DiceConfigController::class);
fastRoute('dice/player/DicePlayer', \app\dice\controller\player\DicePlayerController::class);
Route::put('/dice/player/DicePlayer/updateStatus', [\app\dice\controller\player\DicePlayerController::class, 'updateStatus']);
Route::get('/dice/player/DicePlayer/getLotteryConfigOptions', [\app\dice\controller\player\DicePlayerController::class, 'getLotteryConfigOptions']);
fastRoute('dice/play_record/DicePlayRecord', \app\dice\controller\play_record\DicePlayRecordController::class);
Route::get('/dice/play_record/DicePlayRecord/getPlayerOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getPlayerOptions']);
Route::get('/dice/play_record/DicePlayRecord/getLotteryConfigOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getLotteryConfigOptions']);
Route::get('/dice/play_record/DicePlayRecord/getRewardConfigOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getRewardConfigOptions']);
fastRoute('dice/player_wallet_record/DicePlayerWalletRecord', \app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class);
Route::get('/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerOptions', [\app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class, 'getPlayerOptions']);
Route::get('/dice/player_wallet_record/DicePlayerWalletRecord/getPlayerWalletBefore', [\app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class, 'getPlayerWalletBefore']);
Route::post('/dice/player_wallet_record/DicePlayerWalletRecord/adminOperate', [\app\dice\controller\player_wallet_record\DicePlayerWalletRecordController::class, 'adminOperate']);
fastRoute('dice/player_ticket_record/DicePlayerTicketRecord', \app\dice\controller\player_ticket_record\DicePlayerTicketRecordController::class);
Route::get('/dice/player_ticket_record/DicePlayerTicketRecord/getPlayerOptions', [\app\dice\controller\player_ticket_record\DicePlayerTicketRecordController::class, 'getPlayerOptions']);
fastRoute('dice/reward_config/DiceRewardConfig', \app\dice\controller\reward_config\DiceRewardConfigController::class);
fastRoute('dice/lottery_config/DiceLotteryConfig', \app\dice\controller\lottery_config\DiceLotteryConfigController::class);
Route::get('/dice/lottery_config/DiceLotteryConfig/getOptions', [\app\dice\controller\lottery_config\DiceLotteryConfigController::class, 'getOptions']);
// 数据表维护 // 数据表维护
Route::get("/database/index", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'index']); Route::get("/database/index", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'index']);
Route::get("/database/recycle", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'recycle']); Route::get("/database/recycle", [\plugin\saiadmin\app\controller\system\DataBaseController::class, 'recycle']);

View File

@@ -17,6 +17,11 @@ class ApiException extends BusinessException
{ {
public function render(Request $request): ?Response public function render(Request $request): ?Response
{ {
return json(['code' => $this->getCode() ?: 500, 'message' => $this->getMessage()]); $message = $this->getMessage();
$path = $request->path();
if (str_contains($path, 'api/')) {
$message = \app\api\util\ApiLang::translate($message, $request);
}
return json(['code' => $this->getCode() ?: 500, 'message' => $message]);
} }
} }