package com.engine.organization.entity.staff.bo;

import com.engine.organization.entity.staff.param.StaffPlanSearchParam;
import com.engine.organization.entity.staff.po.StaffPlanPO;
import weaver.common.DateUtil;
import weaver.general.StringUtil;

import java.util.Date;

/**
 * @description:
 * @author:dxfeng
 * @createTime: 2022/05/25
 * @version: 1.0
 */
public class StaffPlanBO {
    public static StaffPlanPO convertParamToPO(StaffPlanSearchParam param, Long employeeId) {
        if (param == null) {
            return null;
        }
        return StaffPlanPO.builder()
                .id(param.getId())
                .planNo(param.getPlanNo())
                .planName(param.getPlanName())
                .planYear(param.getPlanYear())
                .timeStart(StringUtil.isEmpty(param.getTimeStart()) ? null : DateUtil.parseToDateTime(param.getTimeStart()))
                .timeEnd(StringUtil.isEmpty(param.getTimeEnd()) ? null : DateUtil.parseToDateTime(param.getTimeEnd()))
                .companyId(param.getCompanyId())
                .ecCompany(param.getEcCompany())
                .controlDimension(param.getControlDimension())
                .description(param.getDescription())
                .forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1)
                .deleteType(0)
                .createTime(new Date())
                .updateTime(new Date())
                .creator(employeeId)
                .build();
    }


}
