package com.engine.salary.entity.sicategory.bo;

import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.sicategory.dto.ICategoryFormDTO;
import com.engine.salary.entity.sicategory.po.ICategoryPO;
import com.engine.salary.enums.sicategory.DataTypeEnum;
import com.engine.salary.util.SalaryEnumUtil;
import com.engine.salary.util.db.IdGenerator;

import java.util.Date;
import java.util.Objects;

/**
 * @Author weaver_cl
 * 
 * @Date 2022/3/10
 * @Version V1.0
 **/
public class ICategoryBO {

    public static ICategoryPO convertToInsuranceCategoryPO(ICategoryFormDTO dto, Long employeeId) {
        if (Objects.isNull(dto)) {
            return null;
        }
        return ICategoryPO.builder()
                .id(IdGenerator.generate())
                .paymentScope(SalaryEnumUtil.enumArrToString(dto.getPaymentScope()))
                .welfareType(dto.getWelfareType().getValue())
                .insuranceName(dto.getInsuranceName())
                .isUse(0)
                .dataType(DataTypeEnum.CUSTOM.getValue())
                .createTime(new Date())
                .updateTime(new Date())
                .creator(employeeId)
                .deleteType(0)
                .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
                .build();

    }
}
