新增每日签到与补签卡功能
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:后台签到奖励规则保存请求校验
|
||||
*
|
||||
* 集中校验连续签到天数、奖励数值与身份徽章配置。
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 类功能:校验后台新增和更新签到奖励规则的表单数据。
|
||||
*/
|
||||
class SaveSignInRewardRuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 方法功能:允许已通过后台权限中间件的管理员继续校验。
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:返回签到奖励规则表单的校验规则。
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$ruleId = $this->route('signInRewardRule')?->id;
|
||||
|
||||
return [
|
||||
'streak_days' => [
|
||||
'required',
|
||||
'integer',
|
||||
'min:1',
|
||||
'max:3650',
|
||||
Rule::unique('sign_in_reward_rules', 'streak_days')->ignore($ruleId),
|
||||
],
|
||||
'gold_reward' => ['required', 'integer', 'min:0', 'max:999999999'],
|
||||
'exp_reward' => ['required', 'integer', 'min:0', 'max:999999999'],
|
||||
'charm_reward' => ['required', 'integer', 'min:0', 'max:999999999'],
|
||||
'identity_badge_code' => ['nullable', 'string', 'max:50'],
|
||||
'identity_badge_name' => ['nullable', 'string', 'max:50'],
|
||||
'identity_badge_icon' => ['nullable', 'string', 'max:120'],
|
||||
'identity_badge_color' => ['nullable', 'string', 'max:20'],
|
||||
'identity_duration_days' => ['required', 'integer', 'min:0', 'max:3650'],
|
||||
'sort_order' => ['required', 'integer', 'min:0', 'max:999999'],
|
||||
'is_enabled' => ['nullable', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:返回签到奖励规则表单的中文字段名。
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'streak_days' => '连续签到天数',
|
||||
'gold_reward' => '金币奖励',
|
||||
'exp_reward' => '经验奖励',
|
||||
'charm_reward' => '魅力奖励',
|
||||
'identity_badge_name' => '身份名称',
|
||||
'identity_duration_days' => '身份有效天数',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:前台每日签到请求校验
|
||||
*
|
||||
* 校验用户发起签到时携带的房间参数,避免脏 room_id 写入签到流水和聊天室通知。
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 类功能:校验每日签到领取接口的请求参数。
|
||||
*/
|
||||
class ClaimDailySignInRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 方法功能:允许已登录聊天室用户发起签到请求。
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:返回每日签到领取参数校验规则。
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'room_id' => ['nullable', 'integer', 'exists:rooms,id'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:返回每日签到领取的中文错误提示。
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'room_id.exists' => '当前聊天室不存在,请刷新页面后再签到。',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:前台每日签到日历查询请求校验。
|
||||
*
|
||||
* 校验月份参数,供签到日历按月展示签到状态。
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 类功能:校验用户查询签到日历时传入的月份参数。
|
||||
*/
|
||||
class DailySignInCalendarRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 方法功能:允许已登录用户查询自己的签到日历。
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:返回签到日历查询规则。
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'month' => ['nullable', 'date_format:Y-m'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:返回签到日历查询的中文错误提示。
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'month.date_format' => '月份格式不正确。',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:前台每日签到补签请求校验。
|
||||
*
|
||||
* 校验补签日期和房间参数,确保用户只能补签历史漏签日期。
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* 类功能:校验用户在签到日历中提交的补签请求。
|
||||
*/
|
||||
class MakeupDailySignInRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 方法功能:允许已登录用户提交补签请求。
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:返回补签请求的校验规则。
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'target_date' => ['required', 'date', 'before:today', 'after_or_equal:'.Carbon::today()->startOfMonth()->toDateString()],
|
||||
'room_id' => ['nullable', 'integer', 'exists:rooms,id'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 方法功能:返回补签请求的中文错误提示。
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'target_date.required' => '请选择要补签的日期。',
|
||||
'target_date.date' => '补签日期格式不正确。',
|
||||
'target_date.before' => '只能补签今天之前的漏签日期。',
|
||||
'target_date.after_or_equal' => '补签卡只能补签本月的未签到日期。',
|
||||
'room_id.exists' => '当前聊天室不存在,请刷新页面后再补签。',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user