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

import com.engine.organization.entity.scheme.param.LevelSearchParam;
import com.engine.organization.entity.scheme.po.LevelPO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

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

    public static LevelPO convertParamToPO(LevelSearchParam param, Long employeeId) {
        if (param == null) {
            return null;
        }
        return LevelPO.builder()
                .id(param.getId() == null ? 0 : param.getId())
                .levelNo(param.getLevelNo() == null ? null : param.getLevelNo())
                .levelName(param.getLevelName() == null ? null : param.getLevelName())
                .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();
    }

}
