自定义mybatis枚举转换,原理是如果用户没有定义自己的枚举转换工具,mybatis在解析枚举类时会自动获取mybatis的BaseTypeHandler,来转换枚举类,我们只需要重写这个枚举转换器,并将它指定为默认的转换器就好了 首先,定义一个通用接口BaseEnum: import java.util.Arrays; import java.util.Optional; public interface BaseEnum<T>{ T getDictKey(); default T get
解析字符串 filterModel1 and filterModel2 and (filterModel3 or filterModel4) 1.转换成mongo的筛选条件 /// <summary> /// where转换成mongo的查询条件 /// </summary> /// <param name="str"></param> /// <returns></returns> public static s
原查询 select sum(case when age<=16 then 1 else 0 end ) age1, sum(case when age>16 and age<=25 then 1 else 0 end ) age2, sum(case when age>25 and age<=35 then 1 else 0 end ) age3, sum(case when age>35 and age<=45 then 1 else 0 end ) age4