package com.qqwl.gold;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qqwl.gold.pojo.JyStore;
import com.qqwl.gold.service.JyStoreService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import java.util.List;
/**
* 测试类, 用户测试方法
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = AdminApplication.class)
public class ThisTest {
@Autowired
private JyStoreService storeService;
@Test
public void testQueryWarrper(){
//这里使用and()的原因 是加一层括号,防止拼接or 之后sql 失效
List<JyStore> list1 = storeService.list(new QueryWrapper<JyStore>()
.and(qw -> qw.eq("audit_type", "0").or().eq("store_recruitment_type", "0"))
.ne("company_id", 0));
System.out.println(list1);
}
}
这是打印出啦的sql 语法
and() 与or 的的使用 用
SELECT * FROM store WHERE deleted=0 AND (( (audit_type = ? OR store_recruitment_type = ?) ) AND company_id <> ?)
睡觉