package com.engine.organization.entity.sequence.dto;

import com.engine.organization.entity.sequence.param.SequenceSearchParam;
import com.engine.organization.entity.sequence.po.SequencePO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @Author dxfeng
 * @description:
 * @Date 2022/5/11
 * @Version V1.0
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SequenceDTO {
    /**
     * 自增主键
     */
    private long id;
    /**
     * 编号
     */
    private String sequenceNo;
    /**
     * 方案名称
     */
    private String sequenceName;
    /**
     * 方案说明
     */
    private String description;
    /**
     * 等级方案
     */
    private Long schemeId;
    /**
     * 禁用标记
     */
    private int forbiddenTag;

    private Long creator;

    private int deleteType;

    private Date createTime;

    private Date updateTime;

    public static SequencePO convertParamToPO(SequenceSearchParam param, Long employeeId) {
        if (param == null) {
            return null;
        }
        return SequencePO.builder()
                .id(param.getId() == null ? 0 : param.getId())
                .sequenceNo(param.getSequenceNo() == null ? null : param.getSequenceNo())
                .sequenceName(param.getSequenceName() == null ? null : param.getSequenceName())
                .description(param.getDescription() == null ? null : param.getDescription())
                .schemeId(param.getSchemeId() == null ? 0 : param.getSchemeId())
                .forbiddenTag(param.getForbiddenTag() == null ? 0 : param.getForbiddenTag() ? 0 : 1)
                .deleteType(0)
                .createTime(new Date())
                .updateTime(new Date())
                .creator(employeeId)
                .build();
    }

}
