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

import com.engine.organization.entity.scheme.param.GradeSearchParam;
import com.engine.organization.entity.scheme.po.GradePO;
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 GradeDTO {
    /**
     * 主键
     */
    private long id;
    /**
     * 编号
     */
    private String gradeNo;
    /**
     * 名称
     */
    private String gradeName;
    /**
     * 描述说明
     */
    private String description;
    /**
     * 等级方案
     */
    private long schemeId;
    /**
     * 职等
     */
    private String levelId;
    /**
     * 禁用标记
     */
    private int forbiddenTag;

    /**
     *
     */
    private Long creator;
    /**
     *
     */
    private int deleteType;
    /**
     *
     */
    private Date createTime;
    /**
     *
     */
    private Date updateTime;

    public static GradePO convertParamToPO(GradeSearchParam param, Long employeeId) {
        if (param == null) {
            return null;
        }
        return GradePO.builder()
                .id(param.getId() == null ? 0 : param.getId())
                .gradeNo(param.getGradeNo() == null ? null : param.getGradeNo())
                .gradeName(param.getGradeName() == null ? null : param.getGradeName())
                .description(param.getDescription() == null ? null : param.getDescription())
                .schemeId(param.getSchemeId() == null ? 0 : param.getSchemeId())
                .levelId(param.getLevelId() == null ? null : param.getLevelId())
                .forbiddenTag(param.getForbiddenTag() == null ? 0 : param.getForbiddenTag() ? 0 : 1)
                .deleteType(0)
                .createTime(new Date())
                .updateTime(new Date())
                .creator(employeeId)
                .build();
    }

}
