package com.chushang.task.entity;

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 com.chushang.common.dict.annotation.DictFormat;
import com.chushang.common.mybatis.annotation.Condition;
import com.chushang.common.mybatis.base.BaseEntity;
import com.chushang.task.enums.ServiceEnum;
import com.chushang.task.enums.TaskStatusEnum;
import lombok.*;
import org.springframework.context.annotation.Conditional;

import java.time.LocalDateTime;

/**
  * @auther: zhao
  * @date: 2024/6/7 18:18
  */
@Data
@EqualsAndHashCode(callSuper=true)
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "tb_task_info")
@Builder
public class TaskInfo extends BaseEntity {
    /**
     * 主键id
     */
    @TableId(value = "task_id", type = IdType.ASSIGN_ID)
    @Condition(name = "task_id")
    private Long taskId;
    /**
     * 后台任务名称
     */
    @TableField(value = "task_name")
    @Condition(name = "task_name", type = Condition.ConditionType.like)
    private String taskName;
    /**
     * 所属服务名
     * 取 ServiceEnum 的 value
     */
    @TableField(value = "application_name")
    @Condition(name = "application_name", type = Condition.ConditionType.like)
    private String applicationName;
    /**
     * 方法名称
     */
    @TableField(value = "method_name")
    @Condition(name = "method_name", type = Condition.ConditionType.like)
    private String methodName;
    /**
     * 类名
     */
    @TableField(value = "class_name")
    @Condition(name = "class_name")
    private String className;
    /**
     * 任务状态
     * 字典表 task_status
     *
     */
    @TableField(value = "task_status")
    @DictFormat(dictType = "task_status")
    @Condition(name = "task_status")
    private Integer taskStatus;
    /**
     * 后台任务类型
     */
    @TableField(value = "task_type")
    @DictFormat(dictType = "task_type")
    @Condition(name = "task_type")
    private Integer taskType;
    /**
     * 后台任务执行参数
     */
    @TableField(value = "params")
    private String params;
    /**
     * 备注信息
     */
    @TableField(value = "remark")
    private String remark;
    /**
     * 最后一次执行时间
     */
    @TableField(value = "last_run_time")
    private LocalDateTime lastRunTime;
    /**
     * 最后一次执行结果
     */
    @TableField("last_run_result")
    private String lastRunResult;
    /**
     * 部门id -- 根据部门查看区分
     */
    @TableField("dept_id")
    private Long deptId;
    /**
     * 当前用户只能查看自己的后台任务
     */
    @TableField("user_id")
    @Condition(name = "user_id")
    private Long userId;
}
