Files
lotteryLaravel/app/Support/LotteryMessage.php
kang e6cf94af46 refactor: 使用 ApiMessage 统一错误响应格式
- 在多个控制器中引入 ApiMessage,替换原有的 ApiResponse 错误处理逻辑,确保错误信息的一致性与可读性。
- 更新错误返回信息,使用更具语义的键值,提升 API 的可维护性与用户体验。
- 适配相关控制器的请求参数,确保在处理错误时能够正确返回相应的错误信息。
2026-06-01 14:23:48 +08:00

38 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Support;
use App\Lottery\ErrorCode;
use Illuminate\Http\Request;
/**
* 【业务文案翻译辅助类】
*
* 从 lang/{locale}/sso.php 等语言包取字符串,供 JSON 里「msg」字段使用。
* `App\Lottery\ErrorCode` 中玩家 SSO 段80018005的各语言 `msg`。
*
* 依赖 NegotiateLotteryLocale 已写入 lottery_locale若未写则使用 fallback 语言包。
*/
final class LotteryMessage
{
/**
* 取钱包划转类错误的用户可见文案lang/{locale}/wallet.php 键名为数字错误码)。
*
* @param int $code {@see ErrorCode} 钱包段10011010 等与钱包相关的业务码)
*/
public static function wallet(Request $request, int $code): string
{
return ApiMessage::get($request, 'wallet.'.$code);
}
/**
* 取 SSO 鉴权类错误的用户可见文案(与 ApiResponse 的 msg 对应)。
*
* @param int $code {@see ErrorCode} 玩家 SSO 段80018005
*/
public static function sso(Request $request, int $code): string
{
return ApiMessage::get($request, 'sso.'.$code);
}
}