<?php

namespace App\Http\Requests\Community\CommReception;

use App\Http\Requests\BaseRequest;

/**
 * 帖子接口验证
 * @author 唐远望
 * @version 1.0
 * @date 2025-04-17
 * 
 */
class Topic extends BaseRequest
{
    /**
     * 获取应用于请求的规则
     *
     * @return array
     */
    public function rules()
    {
        // 返回结果
        return      [
            'name'                 => 'required',
            'id'                => 'required|integer|gt:0',
            'status'            => 'required|integer|in:0,1',
            'page'              => 'integer|min:1',
            'limit'             => 'integer|min:1',
            'title'             => 'required',
            'content'           => 'required',
            'type_id'           => 'required|integer|gt:0',
            'content_type'      => 'required|integer|in:1,2',
            'topic_id'          => 'required|integer|gt:0',
            'status'            => 'in:5,1',
        ];
    }


    // 场景列表
    protected   $scenes         = [
        'detail'             => ['id'],
        'list'               => ['page', 'limit'],
        'top_list'           => ['page', 'limit'],
        'add'                      => ['title', 'content', 'type_id', 'content_type','status'],
        'edit'                  => ['id','status'],
        'set_status'              => ['id', 'status'],
        'delete'                  => ['id'],
        'set_like'               => ['id'],
        'cancel_like'            => ['id'],
        'set_dislike'            => ['id'],
        'cancel_dislike'         => ['id'],
        'my_list'               => ['page', 'limit'],
    ];

    /**
     * 获取已定义验证规则的错误消息
     *
     * @return array
     */
    public function messages()
    {
        return [
            'name.required'     => '名称必填',
            'id.required'       => 'ID未知',
            'id.integer'        => 'ID格式错误',
            'id.gt'               => 'ID格式错误',
            'status.required'   => '状态未知',
            'status.integer'    => '状态格式错误',
            'status.in'         => '状态格式错误',
            'page.integer'      => '页码格式错误',
            'page.min'          => '页码格式错误',
            'limit.integer'     => '每页数量格式错误',
            'limit.min'         => '每页数量格式错误',
            'title.required'    => '标题必填',
            'content.required'  => '内容必填',
            'type_id.required'  => '分类未知',
            'type_id.integer'   => '分类格式错误',
            'type_id.gt'        => '分类格式错误',
            'content_type.required'  => '内容类型未知',
            'content_type.integer'   => '内容类型格式错误',
            'content_type.in'        => '内容类型格式错误',
            'topic_id.required'  => '帖子ID未知',
            'topic_id.integer'   => '帖子ID格式错误',
            'topic_id.gt'        => '帖子ID格式错误'
        ];
    }
}
