# ShiftTypeEnum.java

    package cloud.wconnect.frontoffice.cons.endofshift;

    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.frontoffice.pojo.dto.endofshift.*;

    /**
     * @author lichen
     * @description End Of Shift Report 枚举类
     * @date 2023/3/8 14:42
     */
    public enum ShiftTypeEnum {

        /**
         * Info Sheet
         */
        INFO_SHEET(1,"Info Sheet"),
        /**
         * Issues
         */
        ISSUES(2,"Incidents/Property Issues"),
        /**
         * Enrollment Total
         */
        ENROLLMENT(3,"Enrollment Total"),
        /**
         * Sales Resume
         */
        SALES_RESUME(4,"Sales Resume"),
        /**
         * Pass On
         */
        PASS_ON(5,"Pass On");

        private final int code;
        private final String desc;

        ShiftTypeEnum(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public static int getCodeByObject(Object obj){
            if(obj instanceof ShiftInfoSheetDTO){
                return INFO_SHEET.getCode();
            }else if(obj instanceof ShiftIncidentsPropertyIssuesDTO){
                return ISSUES.getCode();
            }else if(obj instanceof ShiftEnrollmentTotalDTO){
                return ENROLLMENT.getCode();
            }else if(obj instanceof ShiftSalesResumeDTO){
                return SALES_RESUME.getCode();
            }else if(obj instanceof ShiftPassOnDTO){
                return PASS_ON.getCode();
            }else{
                throw new BadRequestException(BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getI18nCode(),
                    BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(),
                    "The obj=" + obj.getClass().getName() + "is not match ShiftTypeEnum");
            }
        }

    }