diff --git a/config/autoload/common.php b/config/autoload/common.php new file mode 100644 index 0000000..a3c6c5a --- /dev/null +++ b/config/autoload/common.php @@ -0,0 +1,86 @@ + + * Powered by PhpStorm + * Created on 2022/4/27 + */ + +declare(strict_types=1); + +use function Hyperf\Support\env; + +return [ + // 响应 + 'response' => [ + 'restful' => false, // 若禁用,则状态码永远只为 200 + 'code_name' => 'code', // 错误码名称 + 'message_name' => 'message', // 错误信息名称 + 'data_name' => 'data', // 响应数据字段名称 + ], + + // 鉴权相关 + 'token' => [ + // jwt 必需,否则无效 + 'jwt' => [ + // 过期时间 + 'expire_time' => 30 * 24 * 60 * 60, + + 'private_key' => '', // 用于加密 jwt + 'public_key' => '', // 用于解密 jwt + ], + + // session 必需,否则无效 + 'session' => [ + // 'expire_time' => null, // 始终为 session 的过期时间 + 'forbidden_key' => 'user:last_invalidate_time', // redis 中储存时的 key 名(此时间之前登录的用户都会被 T 掉) + ], + 'app' => [ + 'expire_time' => 30 * 24 * 60 * 60, + 'prefix_key' => 'token:', + ], + ], + + // redis 补充配置 + 'redis' => [ + 'prefix' => sprintf( + "%s:%s:", + env('APP_NAME'), + env('APP_ENV', 'product') + ), // 强烈建议按此格式划分 + ], + + // account http请求配置 + 'http_request' => [ + 'account' => [ + 'api_base_uri' => env('API_BASE_URI', ''), + 'rpc_base_uri' => env('RPC_BASE_URI', ''), + ], + ], + + // 第三方服务 + 'third_party' => [ + 'email' => [ + 'dsn' => 'smtp://noreply@luxcreo.ai:Qfsd8866@smtp.qiye.aliyun.com:465', + 'mailer_sender' => 'noreply@luxcreo.ai', // 发件邮箱 + 'mailer_sender_name' => 'LuxCreo', // 发件人名称 + ], + 'sms' => [ + 'aliyun' => [ + 'access_key_id' => env('ACCESS_KEY_ID', ''), + 'access_key_secret' => env('ACCESS_KEY_SECRET', ''), + 'sign_name' => '', // 短信签名名称 + 'template_code' => '', // 短信模板CODE + ], + ], + 'storage' => [ + 'oss' => [ + 'access_key_id' => env('ACCESS_KEY_ID', ''), + 'access_key_secret' => env('ACCESS_KEY_SECRET', ''), + 'oss_host' => env('OSS_HOST', ''), + 'oss_callback' => env('OSS_CALLBACK'), // 可选 + ], + ], + ], +]; diff --git a/storage/languages/en/common_error.php b/storage/languages/en/common_error.php new file mode 100644 index 0000000..e561b00 --- /dev/null +++ b/storage/languages/en/common_error.php @@ -0,0 +1,166 @@ + 'An internal error is occurred, try again later', + 'program' => [ + 'default' => 'An internal error is occurred, try again later', + 'syntax' => [ + 'default' => 'An internal error is occurred, try again later', + ], + 'sql' => [ + 'default' => 'An internal error is occurred, try again later', + 'column_not_found' => 'An internal error is occurred, try again later', + 'insert' => 'An internal error is occurred, try again later', + 'update' => 'An internal error is occurred, try again later', + 'delete' => 'An internal error is occurred, try again later', + ], + ], + + // 参数校验 + 'params' => [ + 'method' => [ + 'default' => 'Reject request', + ], + // 参数非法 + 'format_error' => 'Format error :param', + + // 数据错误 + 'error' => [ + 'default' => 'Failed verification', + 'user' => [ + 'default' => 'Format error, :reason', + 'sec_email' => [ + 'unique' => 'Oops! This email address is already used', + 'required' => '请传入安全邮箱', + 'undefined' => '请先绑定', + ], + 'sec_phone' => [ + 'unique' => 'Oops! This phone is already used', + 'required' => '请传入安全手机号码', + 'undefined' => '请先绑定', + ], + 'username' => [ + 'unique' => 'Oops! This username is already used', + ], + 'sign_up' => [ + 'default' => 'An account with this email or phone already exists.', + ], + 'action' => [ + 'error' => 'This type of verification code is unexpected', + ], + ], + 'code' => [ + 'error' => 'This verification code is incorrect or expired', + 'timeout' => 'This verification code is incorrect or expired', + 'limit' => [ + 'default' => 'SMS verification code has reached the upper limit today, please come back tomorrow. Any problem, please contact our customer service.', + 'day' => 'SMS verification code has reached the upper limit today, please come back tomorrow. Any problem, please contact our customer service.', + 'hour' => 'SMS verification code has reached the upper limit today, please come back tomorrow. Any problem, please contact our customer service.', + 'minute' => 'Try again later', + ], + ], + 'target' => [ + 'format' => 'Invalid Target URL', + 'missing' => 'Missing Target URL', + ], + ], + ], + + // 鉴权 + 'auth' => [ + 'default' => 'Please login', + 'jwt' => [ + 'default' => 'Please login', + 'iat' => 'Processing, try again later', + 'nbf' => 'Processing, try again later', + 'exp' => 'Please login', + 'iss' => 'Please login', + 'uid' => 'Please login', + ], + 'session' => [ + 'default' => 'Please login', + 'uid' => 'Please login', + 'created_at' => 'Please login', + ], + 'forbidden' => [ + 'default' => 'You don\'t have permission to manipulate this content', + 'read' => [ + 'default' => 'You don\'t have permission to manipulate this content', + ], + 'update' => [ + 'default' => 'You don\'t have permission to manipulate this content', + 'address' => [ + 'unique' => 'You need at least one default shipping address', + ], + ], + 'create' => [ + 'default' => 'You don\'t have permission to manipulate this content', + 'wechat' => [ + 'redundant' => 'Oops! This WeChat is already used', + ], + ], + 'delete' => [ + 'default' => 'You don\'t have permission to manipulate this content', + 'wechat' => [ + 'only' => 'You need to add phone or email before unbind WeChat.', + ], + ], + ], + 'app' => [ + 'default' => 'Please login', + ] + ], + + // 服务出错 + 'server' => [ + 'cache' => [ + 'redis' => [ + 'default' => 'Oops!Something went wrong and it was probably our fault. Please try again, or report the problem to us.', + 'refused' => 'Oops!Something went wrong and it was probably our fault. Please try again, or report the problem to us.', + ], + ], + 'dependency' => [ + 'sms' => [ + 'default' => 'Oops!Something went wrong and it was probably our fault. Please try again, or report the problem to us.', + ], + 'wechat' => [ + 'default' => 'Please refresh the QR code and scan the code again', + 'code' => 'An internal error is occurred, try again later', + 'timeout' => 'An internal error is occurred, try again later', + ], + ], + 'message' => [ + 'email' => [ + 'default' => 'Email send error.', + 'not_found' => 'Incorrect Email', + ], + ], + ], + + 'not_found' => [ + 'route' => [ + 'default' => 'The route does not exist', + ], + ], + // 模型 + 'model' => [ + 'not_found' => 'Resource Error', + 'user' => [ + 'default' => 'Invalid User', + 'not_valid' => 'The username or password is incorrect', + ], + 'document' => [ + 'default' => 'DOC deleted', + ], + ], +]; diff --git a/storage/languages/zh_CN/common_error.php b/storage/languages/zh_CN/common_error.php new file mode 100644 index 0000000..a9490ef --- /dev/null +++ b/storage/languages/zh_CN/common_error.php @@ -0,0 +1,175 @@ + '服务器开小差了,稍后再来试试吧', + 'program' => [ + 'default' => '服务器开小差了,稍后再来试试吧', + 'syntax' => [ + 'default' => '服务器开小差了,稍后再来试试吧', + ], + 'sql' => [ + 'default' => '服务器开小差了,稍后再来试试吧', + 'column_not_found' => '服务器开小差了,稍后再来试试吧', + 'insert' => '服务器开小差了,稍后再来试试吧', + 'update' => '服务器开小差了,稍后再来试试吧', + 'delete' => '服务器开小差了,稍后再来试试吧', + ], + ], + + // 参数校验 + 'params' => [ + 'method' => [ + 'default' => '请求方式错误!支持的请求类型为::METHODS', + ], + // 参数非法 + 'format_error' => '参数 :param 格式错误', + + // 数据错误 + 'error' => [ + 'default' => '校验失败', + 'user' => [ + 'default' => '验证失败,:reason', + 'username' => [ + 'unique' => '用户名已存在', + ], + 'sec_email' => [ + 'unique' => '此邮箱已被绑定', + 'required' => '请传入安全邮箱', + 'undefined' => '请先绑定', + 'error_format' => '请传入正确的邮箱地址', + ], + 'sec_phone' => [ + 'unique' => '此手机号已被绑定', + 'required' => '请传入安全手机号码', + 'undefined' => '请先绑定', + 'error_format' => '请传入正确的手机号码', + ], + 'sign_up' => [ + 'default' => '此账号已注册', + ], + 'action' => [ + 'error' => '验证码类型错误', + ], + ], + 'code' => [ + 'error' => '验证码错误或已过期', + 'timeout' => '验证码错误或已过期', + 'limit' => [ + 'default' => '今日短信验证码已达上限,请明日再试。如有紧急情况,请联系人工客服', + 'day' => '今日短信验证码已达上限,请明日再试。如有紧急情况,请联系人工客服', + 'hour' => '今日短信验证码已达上限,请明日再试。如有紧急情况,请联系人工客服', + 'minute' => '你点的太快啦,稍后再试', + ], + ], + 'target' => [ + 'format' => '跳转目标错误', + 'missing' => '要跳转的目标缺失', + ], + ], + ], + + // 鉴权 + 'auth' => [ + 'default' => '请先登录', + 'jwt' => [ + 'default' => '登录失效,请重新登录', + 'iat' => '账户生效中,请稍后再试', + 'nbf' => '账户生效中,请稍后再试', + 'exp' => '登录失效,请重新登录', + 'iss' => '登录失效,请重新登录', + 'uid' => '登录失效,请重新登录', + ], + 'session' => [ + 'default' => '登录失效,请重新登录', + 'uid' => '登录失效,请重新登录', + 'created_at' => '登录失效,请重新登录', + ], + 'saml' => [ + 'default' => 'SAML 检验失败', + 'params' => [ + 'default' => 'SAML 参数校验失败', + 'saml_request' => 'SAMLRequest 参数不能为空', + ], + ], + 'forbidden' => [ + 'default' => '您无权操作此内容', + 'read' => [ + 'default' => '您无权操作此内容', + ], + 'update' => [ + 'default' => '您无权操作此内容', + 'address' => [ + 'unique' => '您至少需要一个默认收货地址', + ], + ], + 'create' => [ + 'default' => '您无权操作此内容', + 'wechat' => [ + 'redundant' => '此微信已绑定其他账户', + ], + ], + 'delete' => [ + 'default' => '您无权操作此内容', + 'wechat' => [ + 'only' => '你还未关联安全手机号或安全邮箱,解绑后将无法登录', + ], + ], + ], + 'app' => [ + 'default' => '登录失效,请重新登录', + ] + ], + + // 服务出错 + 'server' => [ + 'cache' => [ + 'redis' => [ + 'default' => '服务出了点问题,请稍后再试', + 'refused' => '服务出了点问题,请稍后再试', + ], + ], + 'dependency' => [ + 'sms' => [ + 'default' => '服务出了点问题,请稍后再试', + ], + 'wechat' => [ + 'default' => '请刷新二维码,重新扫码', + 'code' => '服务器开小差了,稍后再来试试吧', + 'timeout' => '服务器开小差了,稍后再来试试吧', + ], + ], + 'message' => [ + 'email' => [ + 'default' => '邮件发送失败', + 'not_found' => '邮箱格式不正确', + ], + ], + ], + + 'not_found' => [ + 'route' => [ + 'default' => '当前路由不存在', + ], + ], + // 模型 + 'model' => [ + 'not_found' => '当前:resource不存在', + 'user' => [ + 'default' => '用户不存在', + 'not_valid' => '用户名或密码错误', + ], + 'document' => [ + 'default' => '文档已删除', + ], + ], +];