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

import com.engine.salary.common.BaseQueryParam;
import com.engine.salary.enums.SalaryOnOffEnum;
import com.engine.salary.enums.SalaryValueTypeEnum;
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Collection;

/**
 * 薪资项目查询参数
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SalaryItemSearchParam extends BaseQueryParam {

    //名称
    private String name;

    //备注
    private String description;


    /**
     * 是否薪资档案引用
     *
     * @see SalaryOnOffEnum
     */
    private Integer useInEmployeeSalary;

    /**
     * 是否默认使用
     *
     * @see SalaryOnOffEnum
     */
    private Integer useDefault;

    /**
     * 取值方式
     *
     * @see SalaryValueTypeEnum
     */
    private Integer valueType;

    /**
     * 字段类型
     *
     * @see SalaryDataTypeEnum
     */
    private Integer dataType;

    //需要排除的系统薪资项目@see
    private Collection<Long> excludeIds;


//    public static String makeSqlWhere(SalaryItemSearchParam searchParam) {
//
//        String sqlWhere = " t.delete_type = 0 ";
//
//        DBType dbType = DBType.get(new RecordSet().getDBType());
//
//        String name = searchParam.getName();
//        if (StringUtils.isNotBlank(name)) {
//            sqlWhere += " AND t.name " + dbType.like(name);
//        }
//        String description = searchParam.getDescription();
//        if (StringUtils.isNotBlank(description)) {
//            sqlWhere += " AND t.description " + dbType.like(description);
//        }
//        Integer useInEmployeeSalary = searchParam.getUseInEmployeeSalary();
//        if (useInEmployeeSalary != null) {
//            sqlWhere += " AND t.use_in_employee_salary = " + useInEmployeeSalary;
//        }
//        Integer useDefault = searchParam.getUseDefault();
//        if (useDefault != null) {
//            sqlWhere += " AND t.use_default = " + useDefault;
//        }
//        Integer valueType = searchParam.getValueType();
//        if (valueType != null) {
//            sqlWhere += " AND t.value_type = " + valueType;
//        }
//        Collection<Long> excludeIds = searchParam.getExcludeIds();
//        if (CollectionUtils.isNotEmpty(excludeIds)) {
//            String idsStr = excludeIds.stream().map(String::valueOf).collect(Collectors.joining(","));
//            sqlWhere += " AND t.id NOT IN (" + idsStr + ")";
//        }
//
//        return sqlWhere;
//    }
}
