<?php

namespace App\Http\Requests\Company\Tag;

use App\Http\Requests\BaseRequest;

/**
 * 标签组接口验证
 * @author 唐远望
 * @version 1.0
 * @date 2025-07-15
 * 
 */
class Group 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',
            'group_name'        => 'required',
            'order'             => 'required|integer',
            'edit_tag_data'          => 'required|array',
            'edit_tag_data.*.id'     => 'required|integer|gt:0',
            'edit_tag_data.*.tag_name'  => 'required',
            'edit_tag_data.*.order'   => 'required|integer',
        ];
    }


    // 场景列表
    protected   $scenes         = [
        'detail'             => ['id'],
        'list'               => ['page', 'limit'],
        'add'                      => ['group_name', 'order'],
        'edit'                  => ['id','group_name', 'order'],
        'set_status'              => ['id', 'status'],
        'delete'                  => ['id'],
        'edit_tag_data'              => ['id','group_name', 'order','edit_tag_data','edit_tag_data.*.id','edit_tag_data.*.tag_name','edit_tag_data.*.order'],
        'syncWechatTag'             =>[],
        'cancelSync'   =>[],
    ];

    /**
     * 获取已定义验证规则的错误消息
     *
     * @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'         => '每页数量格式错误',
            'group_name.required'   => '标签组名称必填',
            'order.required'    => '排序未知',
            'order.integer'     => '排序格式错误',
            'edit_tag_data.required' => '标签数据未知',
            'edit_tag_data.array'    => '标签数据格式错误',
            'edit_tag_data.*.id.required' => '标签ID未知',
            'edit_tag_data.*.id.integer' => '标签ID格式错误',
            'edit_tag_data.*.tag_name.required' => '标签名称未知',
            'edit_tag_data.*.order.required' => '标签排序未知',
            'edit_tag_data.*.order.integer' => '标签排序格式错误',
        ];
    }
}
