Skip to content

daixuyang/mp-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyBatis plus 条件构造器

    <dependency>
        <groupId>com.github.daixuyang</groupId>
        <artifactId>mp-util</artifactId>
        <version>1.1.1.RELEASE</version>
    </dependency>
  • 举个栗子
 /**
    * 查询列表数据
    * @param form 参数
    * @return 返回table列表
    */
    @Override
    public CommonTable findList(Dto dto){
        QueryWrapper<Object> wrapper = MpUtil.generateWrapper(dto);
        return xxxxxMapper.findList(wrapper);
    }

说明: 如果form对象里面的某些属性有值,MpUtil.generateWrapper(form, wrapper),这行代码会自动将有值得构建为mybatis plus 的eq条件表达式。

  • 对象属性上也可以通过注解指定查询方式
@MpQuery(type = QueryType.LIKE)
private String fileName;
  • 注解支持的类型
public class QueryType {

    public static final String EQ = "eq";
    public static final String LIKE = "like";
    public static final String LIKE_LEFT = "likeLeft";
    public static final String LIKE_RIGHT = "likeRight";
    /** 小于等于 */
    public static final String LE = "le";
    /** 小于 */
    public static final String LT = "lt";
    /** 大于等于 */
    public static final String GE = "ge";
    /** 大于 */
    public static final String GT = "gt";

    /** 为 null */
    public static final String IS_NULL = "isNull";

    /** 不为 null */
    public static final String IS_NOT_NULL = "isNotNull";

    /** 为空 */
    public static final String IS_EMPTY = "isEmpty";

    /** 不为空 */
    public static final String IS_NOT_EMPTY = "isNotEmpty";

    /** 忽略字段 */
    public static final String IGNORE = "ignore";


}

About

mybatis plus 条件构造工具

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages