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

import com.engine.salary.enums.datacollection.AttendQuoteFieldTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @Description: 数据采集-考勤引用字段
 * @Author: wangxiangzhong
 * @Date: 2021-11-17 14:37
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
//数据采集-考勤引用字段保存参数")
public class AttendQuoteFieldSaveParam {

    //主键")
    private Long id;

    //字段名称")
    private String fieldName;

    //字段类型。1：数值、2：文本")
    private AttendQuoteFieldTypeEnum fieldType;

    //是否启用。false：否、true：是")
    private Boolean enableStatus;

    //备注")
    private String description;

    public static void checkParam(AttendQuoteFieldSaveParam saveParam) {
        if (StringUtils.isEmpty(saveParam.getFieldName())) {
            throw new SalaryRunTimeException("字段名称必填");
        }
        if (saveParam.getFieldType() == null) {
            throw new SalaryRunTimeException("字段类型必传");
        }
        if (saveParam.getEnableStatus() == null) {
            throw new SalaryRunTimeException("是否启用必传");
        }
        if (saveParam.getEnableStatus().equals(0) && saveParam.getEnableStatus().equals(1)) {
            throw new SalaryRunTimeException("是否启用参数有误");
        }
    }
}
