【Mybatis-Plus】or拼接

Mybatis-Plus的or拼接是个坑:
这是需要的结果:

queryWrapper.and(c->c.or(a->a.eq("qcs3.status", "SIGNING")
                        .eq("qcs.status", "SIGNING")).or(b->b.eq("qcs.status","INVALIDING")
                        .eq("qcs3.status","INVALIDING"))).eq("qcs.is_del",0);

执行的sql:

where
	((qcs3.status = 'SIGNING'
		and qcs.status = 'SIGNING')
	or (qcs.status = 'INVALIDING'
		and qcs3.status = 'INVALIDING'))
		and qcs.is_del = 0

但是很容易写成:

     queryWrapper.and(a->a.eq("qcs3.status", "SIGNING")
                        .eq("qcs.status", "SIGNING")).or(b->b.eq("qcs.status","INVALIDING")
                        .eq("qcs3.status","INVALIDING")).eq("qcs.is_del",0);;

执行的sql:

where
	((qcs3.status = 'SIGNING'
		and qcs.status = 'SIGNING')
	or (qcs.status = 'INVALIDING'
		and qcs3.status = 'INVALIDING'))
		and qcs.is_del = 0

or拼接常用的写法:

例1: eq(“id”,1).or().eq(“name”,“老王”)—>id = 1 or name = ‘老王’

例2: or(i -> i.eq(“name”, “李白”).ne(“status”, “活着”))—>or (name = ‘李白’ and status <> ‘活着’)

你可能感兴趣的:(mybatis,java,前端)