使用内部枚举类作为外部类的参数的Mybatis的参数该如何判断

新写了一个接口,期望根据不同的参数来给数据库中不同的字段进行传值。这里使用了内部静态枚举类的方式进行传值,在写mybatis动态sql时,如果是普通对象,一般使用,那么使用枚举类,如何判断枚举类的值呢?

Mapper接口

public class SLineSboxesQueryParam {
    private QueryMethod queryMethod;//查询方式的枚举内部类
    private List idList;
    private LocalDateTime startTime;
    private LocalDateTime endTime;

 public SLineSboxesQueryParam() {
    }

//省略getter setter方法

    public void checkHasNecessaryFields() {
        if (this.queryMethod == null) {
            throw new ApiException(ResultCode.PARAMS_ERROR, "queryMethod is missing");
 } else if (CollectionUtils.isEmpty(this.idList)) {
            throw new ApiException(ResultCode.PARAMS_ERROR, "idList is missing");
 } else if (this.startTime == null) {
            throw new ApiException(ResultCode.PARAMS_ERROR, "startTime is missing");
 } else if (this.endTime == null) {
            throw new ApiException(ResultCode.PARAMS_ERROR,"endTime is missing");
 }
    }

    //定义查询方式
 public static enum QueryMethod { //此处定义了内部枚举类
        BySpecIdList, BySLineIdList, ByVplIdList;

 QueryMethod() {
        }

    }
}

mappers.xml配置

//resultMap


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


//sql




你可能感兴趣的:(使用内部枚举类作为外部类的参数的Mybatis的参数该如何判断)