瀏覽代碼

@IPU_FIXBUG_2021@weihf@修复sonar违规

weihf 4 年之前
父節點
當前提交
89545f503f

+ 1 - 1
mybatisplus/src/main/java/com/ai/ipu/mybatisplus/config/MybatisPlusConfig.java

36
@Configuration
36
@Configuration
37
@MapperScan("com.ai.ipu.mybatisplus.mapper")
37
@MapperScan("com.ai.ipu.mybatisplus.mapper")
38
public class MybatisPlusConfig {
38
public class MybatisPlusConfig {
39
	public static ThreadLocal<String> TABLE_NAME = new ThreadLocal<String>();
39
	public static final ThreadLocal<String> TABLE_NAME = new ThreadLocal<String>();
40
	@Autowired
40
	@Autowired
41
	private Mybatisplus mybatisplus;
41
	private Mybatisplus mybatisplus;
42
	
42
	

+ 7 - 4
mybatisplus/src/test/java/com/ai/ipu/mybatisplus/ProductInfoTests.java

19
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
19
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
20
20
21
import lombok.extern.slf4j.Slf4j;
21
import lombok.extern.slf4j.Slf4j;
22
import sun.reflect.misc.ReflectUtil;
22
23
23
@Slf4j
24
@Slf4j
24
@SpringBootTest
25
@SpringBootTest
30
	@Test
31
	@Test
31
	void select() {
32
	void select() {
32
		List<ProductInfo> productInfos = productInfoMapper.selectList(null);
33
		List<ProductInfo> productInfos = productInfoMapper.selectList(null);
33
		productInfos.forEach(System.out::println);
34
		print(productInfos);
34
	}
35
	}
35
	
36
	
36
	@Test
37
	@Test
50
		QueryWrapper<ProductInfo> queryWrapper = new QueryWrapper<ProductInfo>();
51
		QueryWrapper<ProductInfo> queryWrapper = new QueryWrapper<ProductInfo>();
51
		queryWrapper.like("product_Name","社区");
52
		queryWrapper.like("product_Name","社区");
52
		List<ProductInfo> productInfos = productInfoMapper.selectList(queryWrapper);
53
		List<ProductInfo> productInfos = productInfoMapper.selectList(queryWrapper);
53
		productInfos.forEach(System.out::println);
54
		print(productInfos);
54
	}
55
	}
55
	
56
	
56
	@Test
57
	@Test
61
		lambda.eq(ProductInfo::getProductName,"  开源社区  ");
62
		lambda.eq(ProductInfo::getProductName,"  开源社区  ");
62
		//会自动去空格
63
		//会自动去空格
63
		List<ProductInfo> productInfos = productInfoMapper.selectList(lambda);
64
		List<ProductInfo> productInfos = productInfoMapper.selectList(lambda);
64
		productInfos.forEach(System.out::println);
65
		print(productInfos);
65
	}
66
	}
66
	
67
	
67
	@Test
68
	@Test
102
	
103
	
103
    private <T> void print(List<T> list) {
104
    private <T> void print(List<T> list) {
104
        if (!CollectionUtils.isEmpty(list)) {
105
        if (!CollectionUtils.isEmpty(list)) {
105
            list.forEach(System.out::println);
106
            list.forEach(e -> {
107
            	log.info(e.toString());
108
            });
106
        }
109
        }
107
    }
110
    }
108
}
111
}

+ 5 - 3
mybatisplus/src/test/java/com/ai/ipu/mybatisplus/UserInfoTests.java

94
    @Test
94
    @Test
95
    public void selectAll() {
95
    public void selectAll() {
96
    	List<UserInfo> userInfos = userInfoMapper.selectList(null);
96
    	List<UserInfo> userInfos = userInfoMapper.selectList(null);
97
    	userInfos.forEach(System.out::println);
97
    	print(userInfos);
98
    }
98
    }
99
    
99
    
100
    @Test
100
    @Test
126
        map.put("user_name" , "test");
126
        map.put("user_name" , "test");
127
        userQueryWrapper.allEq(map);
127
        userQueryWrapper.allEq(map);
128
		List<UserInfo> userInfos = userInfoMapper.selectList(userQueryWrapper);
128
		List<UserInfo> userInfos = userInfoMapper.selectList(userQueryWrapper);
129
		userInfos.forEach(System.out::println);
129
		print(userInfos);
130
	}
130
	}
131
	
131
	
132
    private <T> void print(List<T> list) {
132
    private <T> void print(List<T> list) {
133
        if (!CollectionUtils.isEmpty(list)) {
133
        if (!CollectionUtils.isEmpty(list)) {
134
            list.forEach(System.out::println);
134
        	list.forEach(e -> {
135
            	log.info(e.toString());
136
            });
135
        }
137
        }
136
    }
138
    }
137
}
139
}