当前位置:网站首页>Commodity management system -- integrate warehouse services and obtain warehouse list

Commodity management system -- integrate warehouse services and obtain warehouse list

2020-11-09 07:35:38 osc_kiub62pt

One   The configuration file application.yml

#  Registration center address and project name 
cloud:
  nacos:
    discovery:
      server-addr: 127.0.0.1:8848
application:
  name: gulimall-ware

Two   Turn on the service registration discovery function

@EnableFeignClients
//  Turn on the service registration discovery function 
@EnableDiscoveryClient
@SpringBootApplication
public class GulimallWareApplication {
    public static void main(String[] args) {
        SpringApplication.run(GulimallWareApplication.class, args);
    }
}

3、 ... and   Gateway microservice configuration

#  Configure inventory system routing 
- id: ware_route
  uri: lb://gulimall-ware
  predicates:
    - Path=/api/ware/**
  filters:
    - RewritePath=/api/(?<segment>.*),/$\{segment}

Four   controller

    /**
     *  Function description : Warehouse information paging query 
     *
     * @param params  Paging conditions 
     * @return R  Data returned to the front end 
     * @author cakin
     * @date 2020/11/8
     * @description:
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = wareInfoService.queryPage(params);
        return R.ok().put("page", page);
    }

5、 ... and   Service layer

    /**
     *  Function description : Warehouse information paging query 
     *
     * @param params  Pagination filter conditions 
     * @return PageUtils  Paging information 
     * @author cakin
     * @date 2020/11/8
     */
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //  Query criteria 
        QueryWrapper<WareInfoEntity> wareInfoEntityQueryWrapper = new QueryWrapper<>();
        //  Keyword search 
        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);
        }
        //  Paging query 
        IPage<WareInfoEntity> page = this.page(new Query<WareInfoEntity>().getPage(params), wareInfoEntityQueryWrapper);
        return new PageUtils(page);
    }

6、 ... and   test

版权声明
本文为[osc_kiub62pt]所创,转载请带上原文链接,感谢