package cn.estsh.i3plus.pojo.aps.bean;

import cn.estsh.i3plus.pojo.aps.annotation.FieldAnnotation;
import cn.estsh.i3plus.pojo.aps.common.BaseAPS;
import cn.estsh.i3plus.pojo.aps.common.BeanRelation;
import cn.estsh.i3plus.pojo.aps.holders.EResCalendar;
import cn.estsh.i3plus.pojo.base.enumutil.ApsEnumUtil;
import com.fasterxml.jackson.annotation.JsonBackReference;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;

/**
 * @Description :日历
 * @Reference :
 * @Author : jason.niu
 * @CreateDate : 2019-09-17
 * @Modify:
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "APS_RES_CALENDAR")
@Api("日历")
public class ResCalendar extends BaseAPS {
    private static final long serialVersionUID = 8338930205816433211L;
    @Column(name="RES_CODES")
    @ApiParam(value ="资源编码")
    @FieldAnnotation(editType = ApsEnumUtil.EDIT_TYPE.MULTI_OBJECT, typeName = "Resource", notEmpty = true)
    private String resCodes;

    @Column(name="WEEKS")
    @ApiParam(value ="星期")
    @FieldAnnotation(multiEnumClass = ApsEnumUtil.CALENDAR_WEEK.class)
    private Integer weeks;

    @Column(name="DATES")
    @ApiParam(value ="时间")
    private String dates;

    @Column(name="SHIFT_CODES")
    @ApiParam(value ="班次编码")
    @FieldAnnotation(editType = ApsEnumUtil.EDIT_TYPE.MULTI_OBJECT, typeName = "DayShift", notEmpty = true)
    private String shiftCodes;

    @Column(name="PRIORITY")
    @ApiParam(value ="优先级")
    @FieldAnnotation(defaultValue = "10")
    private Integer priority;

    @JsonBackReference
    public List<DayShift> getDayShifts() {
        return BeanRelation.list(this, EResCalendar.DayShifts);
    }

    @JsonBackReference
    public List<Resource> getResources() {
        return BeanRelation.list(this, EResCalendar.Resources);
    }
}
