package link.at17.mid.tushare.data.models;

import java.util.ArrayList;
import java.util.List;

import org.springframework.validation.annotation.Validated;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import link.at17.mid.tushare.data.typehandler.UpdateMethodInfoListTypeHandler;
import link.at17.mid.tushare.data.validator.ValidCron;
import link.at17.mid.tushare.data.validator.ValidUpdateMethodInfo;
import lombok.Data;

@Data
@TableName(value="update_plan", autoResultMap = true) // 使用自定义类型转换器必须使 autoResultMap = true
@NotNull
@Validated
public class UpdatePlan {
    
    /**
     * id
     */
    @TableId(type=IdType.AUTO)
    private Integer id;
    
    /**
     * 计划任务表达式
     */
    @ValidCron
    @NotBlank
    private String cronExpr;
    
    /**
     * 计划名称
     */
    @NotBlank
    private String name;
    
    /**
     * 计划内方法列表
     */
    @TableField(typeHandler=UpdateMethodInfoListTypeHandler.class)
    @NotEmpty
    @Valid
    private List<@ValidUpdateMethodInfo UpdateMethodInfo> methods = new ArrayList<>();
    
    /**
     * 是否进行交易日检查
     */
    @NotNull
    private Boolean openDayCheck = false;
    
    /**
     * 是否启用
     */
    @NotNull
    private Boolean enabled = true;
    
    /**
     * 是否有效
     */
    @TableField(exist=false)
    private Boolean valid = true;

}
