package cn.wisenergy.model.app;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * @Authotr:陈奇
 * @QQ1799796883
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="WorkType", description="项目类型类")
public class WorkType implements Serializable, Comparable{

    private final static Integer[] TYPE_ORDER = {1,3,2};
    private static final long serialVersionUID = 8842083047098059912L;

    @ApiModelProperty(name = "id",value = "主键id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(name = "name",value = "类型名")
    private String name;

    @ApiModelProperty(name = "reviewer",value = "检查者:1:该项目负责人 2:系统自动 3:部门或中心负责人")
    private Integer reviewer;

    @ApiModelProperty(name = "isDelete",value = "0：正常 1：删除")
    private Integer isDelete;


    @Override
    public int compareTo(Object o) {
        WorkType workType = (WorkType) o;
        int thisI = 0;
        int oI = 0;
        for (int i = 0; i < TYPE_ORDER.length; i++) {
            if (reviewer.equals(TYPE_ORDER[i])) {
                thisI = i;
            }
            if (workType.getReviewer().equals(TYPE_ORDER[i])) {
                oI = i;
            }
        }
        return thisI - oI;
    }
}
