<?php

namespace app\api\validate;

use think\Validate;

class ModelValidate extends Validate
{

    protected $rule = [
        'pageNum' => ['require','integer','gt:0'],//页码,gt在内置规则：https://www.kancloud.cn/manual/thinkphp6_0/1037629#_232
        'pageSize' => ['require','integer','gt:0'],//每页显示数量
        'type_id'=>['require','in:1,2,3,4'],//模型所属行业：1.种植业 2.畜牧业 3.渔业 4.其他
        'task_id' => ['require', 'gt:0'],//任务id
        'test_model_id' => ['require', 'gt:0'],//ccjc绑定模型id
        'endtime_cydsb' => ['require', 'date'],//抽样单上报截止日期
        'is_divide' => ['require', 'in:0,1'],//抽检分离状态：0分离，1不分离
        'id' => ['require','integer','gt:0'],//模型id

    ];

    protected $message = [
        'pageNum' => [
            'require' => ['0' => 500101, '1' => '页码错误'],//关联任务id
            'integer' => ['0' => 500102, '1' => '页码错误'],
            'gt' => ['0' => 500103, '1' => '页码错误'],
        ],
        'pageSize' => [
            'require' => ['0' => 500104, '1' => '页码错误'],//关联任务id
            'integer' => ['0' => 500105, '1' => '页码错误'],
            'gt' => ['0' => 500106, '1' => '页码错误'],
        ],
        'type_id'=>[
            'require' => ['0' => 500201, '1' => '行业错误'],
            'in' => ['0' => 500202, '1' => '行业范围错误'],
        ],
        'endtime_cydsb' => [
            'require' => ['0' => 500301, '1' => '请选择截止日期'],
            'date' => ['0' => 500302, '1' => '截至日期格式错误'],
        ],
        'is_divide' => [
            'require' => ['0' => 500401, '1' => '请选择抽检是否分离'],
            'in' => ['0' => 500402, '1' => '抽检分离错误'],
        ],
        'test_model_id' => [
            'require' => ['0' => 500501, '1' => '任务绑定模型错误'],
            'gt' => ['0' => 500502, '1' => '任务绑定模型错误'],
        ],
        'task_id'=>[
            'require' => ['0' => 500601, '1' => '任务信息异常'],
            'gt' => ['0' => 500602, '1' => '任务信息异常'],
        ],
        'id' => [
            'require' => ['0' => 500701, '1' => '模型选择信息错误'],//模型id
            'integer' => ['0' => 500702, '1' => '模型选择信息错误'],
            'gt' => ['0' => 500703, '1' => '模型选择信息错误'],
        ],


    ];

    public function sceneSelectQtModelList()
    {
        return $this->only(['pageNum', 'pageSize', 'type_id'])
            ->remove('type_id', 'require');
    }

    public function sceneBindModel()
    {
        return $this->only(['endtime_cydsb', 'is_divide', 'test_model_id', 'task_id']);
    }

    //获取模型信息
    public function sceneGetModelInfo()
    {
        return $this->only(['id']);
    }
}