<?php

namespace  App\Http\Requests\OpenWork\External;

use App\Http\Requests\BaseRequest;

/**
 * 客户标签接口校验规则
 * @author  唐远望
 * @date    2025-04-02
 * */
class Tag extends BaseRequest
{

    /**
     *
     * @return  array
     */
    public  function  rules()
    {
        // 规则
        return [
            'corpid'              => 'required',
            'crowd_packid'         => 'required',
            'add_tag'         => 'required',
            'remove_tag'         => 'required',
            'limit'         => 'required',
            'tag'         => 'required|array',
            'tag.*'         => 'required',
            'tag.*.name'         => 'required',
            'tag.*.order'         => 'required|integer',
            'tag_group_data'         => 'required|array',
            'tag_group_data.group_name'         => 'required',
            'tag_group_data.group_id'         => 'required',
            'tag_group_data.order'         => 'required|integer',
            'tag_data.*.tag_name'         => 'required',
            'tag_data.*.order'         => 'required|integer',
            'tag_data.*.action'         => 'required|in:add,edit,del',
            'user_list'          => 'required|array',
            'user_list.*.userid'         => 'required',
            'user_list.*.extid'         => 'required',
            'page'         => 'required|integer',
        ];
    }

    // 场景列表
    protected   $scenes         = [
        'batch_mark_tags'                      => ['corpid', 'crowd_packid', 'add_tag'],
        'mark_tags'                      => ['corpid', 'userid', 'external_userid'],
        'sync_get_list'                      => ['corpid'],
        'get_list'                      => ['limit'],
        'add'                      => ['corpid', 'tag', 'tag.*.name', 'tag.*.order'],
        'batch_action_tags'                      => [
            'corpid',
            'tag_group_data',
            'tag_group_data.group_name',
            'tag_group_data.group_id',
            'tag_group_data.order',
            'tag_data.*.tag_name',
            'tag_data.*.tag_id',
            'tag_data.*.order',
            'tag_data.*.action',
        ],
        'batch_edit_tags'   => ['corpid', 'user_list', 'user_list.*.userid', 'user_list.*.extid'],
        'get_mark_tag_log_list' => ['corpid','page', 'limit'],
    ];

    /**
     *
     * @return  array
     */
    public  function  messages()
    {
        return [
            'crowd_packid.required'     => '人群包ID不能为空',
            'add_tag.required'     => '新增标签不能为空',
            'remove_tag.required'     => '删除标签不能为空',
            'corpid.required'     => '授权方corpid不能为空',
            'crowd_packid.required'     => '人群包ID不能为空',
            'limit.required'     => '获取数量不能为空',
            'tag.required'     => '标签不能为空',
            'tag.*.name.required'     => '标签名称不能为空',
            'tag.*.order.required'     => '标签排序不能为空',
            'tag_group_data.required'     => '标签分组不能为空',
            'tag_group_data.group_name.required'     => '标签分组名称不能为空',
            'tag_group_data.group_id.required'     => '标签分组ID不能为空',
            'tag_group_data.order.required'     => '标签分组排序不能为空',
            'tag_data.*.tag_name.required'     => '标签名称不能为空',
            'tag_data.*.order.required'     => '标签排序不能为空',
            'tag_data.*.action.required'     => '标签操作不能为空',
            'tag_data.*.action.in'     => '标签操作不正确',
            'user_list.required'     => '用户列表不能为空',
            'user_list.*.userid.required'     => '用户ID不能为空',
            'user_list.*.extid.required'     => '外部联系人ID不能为空',
        ];
    }
}
