package com.engine.salary.entity.salaryBill.param;

import com.engine.salary.entity.salaryBill.dto.SalaryBillAckFeedbackDTO;
import com.engine.salary.enums.salarybill.SalaryTemplateWatermarkTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.util.SalaryI18nUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.Objects;

/**
 * @author Harryxzy
 * @ClassName SalaryBaseSetSaveParam
 * @date 2023/06/09 13:41
 * @description 工资单基础设置保存参数
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SalaryBaseSetSaveParam {

    // 是否启用水印")
    private Boolean watermarkStatus;

    // 水印类型")
    private SalaryTemplateWatermarkTypeEnum watermark;

    // 自定义设置内容")
    private Map<String, Object> wmSetting;

    // 工资单确认反馈设置
    private SalaryBillAckFeedbackDTO ackFeedbackSetting;

    //工资单时效性
    private com.engine.salary.entity.salaryBill.dto.salaryBillViewingLimitSetting salaryBillViewingLimitSetting;

    public static void checkParam(SalaryBaseSetSaveParam saveParam) {
        if (Objects.isNull(saveParam.getWatermarkStatus())) {
            throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(220418, "是否启用水印必传"));
        }
        // 如果开启了
        if (saveParam.getWatermarkStatus()) {
            if (Objects.isNull(saveParam.getWatermark())) {
                throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(220419, "水印类型必传"));
            }
            if (SalaryTemplateWatermarkTypeEnum.CUSTOM.equals(saveParam.getWatermark()) && (Objects.isNull(saveParam.getWmSetting()) || saveParam.getWmSetting().isEmpty())) {
                throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(220419, "自定义水印的设置内容必传"));
            }
        }
        if (Objects.isNull(saveParam.getAckFeedbackSetting()) || StringUtils.isBlank(saveParam.getAckFeedbackSetting().getAckStatus())) {
            throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(220418, "工资单确认反馈信息必传"));
        }

    }

}
