一.完善仓储为服务:
1.配置:
1)配置 服务注册与发现:
spring:
cloud:
nacos:
discovery:
server-addr: 114.215.173.88:8848
2)配置配置中心:( bootstrap.properties )
spring.application.name=gulimail-ware
spring.cloud.nacos.config.server-addr=114.215.173.88:8848
spring.cloud.nacos.config.namespace=475cbd56-fa01-49c2-8d78-a11f9e1ab115
3)启动类添加注解:
a.开启服务注册与发现注解:
b.开启 mapperScan 扫描注解:
c:开启事务管理注解:
@EnableTransactionManagement
@EnableDiscoveryClient
@MapperScan(value = "com.guigu.gulimail.ware.dao")
2.新增仓库地址:
1)已经自动生成了 新增方法:
3.仓库检索方法:
1)根据 id name address areacode:进行检索或者模糊查询。
@Service("wareInfoService")
public class WareInfoServiceImpl extends ServiceImpl<WareInfoDao, WareInfoEntity> implements WareInfoService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
QueryWrapper<WareInfoEntity> wareInfoEntityQueryWrapper = new QueryWrapper<>();
String key = (String) params.get("key");
if (!StringUtils.isEmpty(key)) {
wareInfoEntityQueryWrapper.eq("id", key)
.or().like("name", key)
.or().like("address", key)
.or().like("areacode", key);
}
IPage<WareInfoEntity> page = this.page(
new Query<WareInfoEntity>().getPage(params),
wareInfoEntityQueryWrapper
);
return new PageUtils(page);
}
}
2)添加日志sql 日志功能:
logging:
level:
com.guigu.gulimail.ware.dao: debug
3)生成的 SQL :
-- 2 2021-03-21 18:54:54.930 DEBUG 3814 --- [io-12000-exec-2] c.g.g.ware.dao.WareInfoDao.selectPage : ==>
SELECT id,name,address,areacode
FROM wms_ware_info
WHERE (id = '仓库' OR name LIKE '%仓库%' OR address LIKE '%仓库%' OR areacode LIKE '%仓库%');
-- ==> Total: 1