看到代码有个注解@SpringQueryMap,这是啥?百度出来这是openfeign里面(这个后面再说),然而这又是springcloud里面的?项目看了半天,原来它不是springboot,可能?疑似?它是springcloud(ΩДΩ)。内心慌得一比,赶紧百度,它与springboot关联区别。还好,它是基于springboot上发展起来,减少手动配置很多依赖。区别springboot与springcloud项目区别最主要看他的配置文件中是否包含“cloud”关键字配置,有就是springcloud项目,没有就是springboot项目。
现在说下这篇文章最开始说到的@SpringQueryMap,这是什么?
它和@RequestParam,@RequestBody一样,都是用在api上注解。使用场景,api是get请求,参数又多,那么这时参数封装成一个对象,就用@SpringQueryMap,对象参数类型原来是什么就是什么,不需要转换成Map。例如,
@GetMapping("/pdps/skus")
Response<Page<ProductInfo>> getSkus(@SpringQueryMap ProductDetailRequest request);
@Data
public class ProductDetailRequest {
private String language;
private String storeCode;
private Set<String> spuCodes;
private Set<String> skuCodes;
private Set<String> styleCodes;
}