Commit 02a25960 by 刘宇峰

封装接口

1 parent d39f9250
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.api.ShopmallBaseDataApiService;
import cn.com.glsx.admin.modules.model.cloudcrane.response.*;
import com.glsx.plat.core.web.Result;
import com.glsx.plat.feign.utils.RestTemplateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.List;
@Slf4j
public class ShopmallBaseDataService {
@Value("${platform.shopmall.url}")
private String serverUrl;
/**
* 获取一级地址列表接口
*
* @return
*/
public List<QueryAddressProvinceResponse> queryAddressProvince() {
Result<List<QueryAddressProvinceResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_ADDRESS_PROVINCE,
new ParameterizedTypeReference<Result<List<QueryAddressProvinceResponse>>>() {
});
return result.getData();
}
/**
* 获取二级地址列表接口
*
* @param parentAddressCode
* @return
*/
public List<QueryAddressCityResponse> queryAddressCity(String parentAddressCode) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("parentAddressCode", parentAddressCode);
Result<List<QueryAddressCityResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_ADDRESS_CITY,
params,
new ParameterizedTypeReference<Result<List<QueryAddressCityResponse>>>() {
});
return result.getData();
}
/**
* 获取三级地址列表接口
*
* @param parentAddressCode
* @return
*/
public List<QueryAddressAreaResponse> queryAddressArea(String parentAddressCode) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("parentAddressCode", parentAddressCode);
Result<List<QueryAddressAreaResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_ADDRESS_AREA,
params,
new ParameterizedTypeReference<Result<List<QueryAddressAreaResponse>>>() {
});
return result.getData();
}
/**
* 获取四级地址列表接口
*
* @param parentAddressCode
* @return
*/
public List<QueryAddressStreetResponse> queryAddressStreet(String parentAddressCode) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("parentAddressCode", parentAddressCode);
Result<List<QueryAddressStreetResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_ADDRESS_STREET,
params,
new ParameterizedTypeReference<Result<List<QueryAddressStreetResponse>>>() {
});
return result.getData();
}
/**
* 获取全部地址列表接口
*
* @return
*/
public List<QueryAddressListResponse> queryAddressList() {
Result<List<QueryAddressListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_ADDRESS_LIST,
new ParameterizedTypeReference<Result<List<QueryAddressListResponse>>>() {
});
return result.getData();
}
/**
* 获取一级分类列表接口
*
* @return
*/
public List<QueryOneCategoryListResponse> queryOneCategoryList() {
Result<List<QueryOneCategoryListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_ONE_CATEGORY_LIST,
new ParameterizedTypeReference<Result<List<QueryOneCategoryListResponse>>>() {
});
return result.getData();
}
/**
* 获取二级分类列表接口
*
* @param parentCategoryCode
* @return
*/
public List<QuerySecondCategoryListResponse> querySecondCategoryList(String parentCategoryCode) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("parentCategoryCode", parentCategoryCode);
Result<List<QuerySecondCategoryListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_SECOND_CATEGORY_LIST,
params,
new ParameterizedTypeReference<Result<List<QuerySecondCategoryListResponse>>>() {
});
return result.getData();
}
/**
* 获取三级分类列表接口
*
* @param parentCategoryCode
* @return
*/
public List<QueryThreeCategoryListResponse> queryThreeCategoryList(String parentCategoryCode) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("parentCategoryCode", parentCategoryCode);
Result<List<QueryThreeCategoryListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_THREE_CATEGORY_LIST,
params,
new ParameterizedTypeReference<Result<List<QueryThreeCategoryListResponse>>>() {
});
return result.getData();
}
/**
* 获取全部分类列表接口
*
* @return
*/
public List<QueryCategoryListResponse> queryCategoryList() {
Result<List<QueryCategoryListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_CATEGORY_LIST, new ParameterizedTypeReference<Result<List<QueryCategoryListResponse>>>() {
});
return result.getData();
}
/**
* 获取品牌列表接口
*
* @return
*/
public List<QueryBrandListResponse> queryBrandList() {
Result<List<QueryBrandListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_BRAND_LIST, new ParameterizedTypeReference<Result<List<QueryBrandListResponse>>>() {
});
return result.getData();
}
/**
* 获取快递公司列表接口
*
* @return
*/
public List<QueryExpressListResponse> queryExpressList() {
Result<List<QueryExpressListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallBaseDataApiService.QUERY_EXPRESS_LIST, new ParameterizedTypeReference<Result<List<QueryExpressListResponse>>>() {
});
return result.getData();
}
}
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.api.ShopmallGoodsApiService;
import cn.com.glsx.admin.modules.model.cloudcrane.request.QueryGoodsListByConditionRequest;
import cn.com.glsx.admin.modules.model.cloudcrane.request.QueryGoodsListRequest;
import cn.com.glsx.admin.modules.model.cloudcrane.response.*;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.Result;
import com.glsx.plat.feign.utils.RestTemplateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@Slf4j
public class ShopmallGoodsService {
@Value("${platform.shopmall.url}")
private String serverUrl;
/**
* 获取商品信息列表接口
*
* @param req
* @return
*/
public PageInfo<GoodsSkuListItem> queryGoodsList(@RequestBody QueryGoodsListRequest req) {
Result<PageInfo<GoodsSkuListItem>> result = RestTemplateUtils.fetchPostJson(serverUrl + ShopmallGoodsApiService.QUERY_GOODS_LIST,
req,
new ParameterizedTypeReference<Result<PageInfo<GoodsSkuListItem>>>() {
});
return result.getData();
}
/**
* 检索商品信息列表接口
*
* @param req
* @return
*/
public PageInfo<GoodsSkuListSearchItem> queryGoodsListByCondition(@RequestBody QueryGoodsListByConditionRequest req) {
Result<PageInfo<GoodsSkuListSearchItem>> result = RestTemplateUtils.fetchPostJson(serverUrl + ShopmallGoodsApiService.QUERY_GOODS_LIST_BY_CONDITION,
req,
new ParameterizedTypeReference<Result<PageInfo<GoodsSkuListSearchItem>>>() {
});
return result.getData();
}
/**
* 获取商品详情信息接口
*
* @param goodsSkuCodes
* @return
*/
public List<QueryGoodsDetailResponse> queryGoodsDetail(@RequestParam("goodsSkuCodes") List<String> goodsSkuCodes) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.putIfAbsent("goodsSkuCodes", goodsSkuCodes);
Result<List<QueryGoodsDetailResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallGoodsApiService.QUERY_GOODS_DETAIL,
params,
new ParameterizedTypeReference<Result<List<QueryGoodsDetailResponse>>>() {
});
return result.getData();
}
/**
* 获取商品图片列表接口
*
* @param goodsSkuCodes
* @return
*/
public List<QueryGoodsImageListResponse> queryGoodsImageList(@RequestParam("goodsSkuCodes") List<String> goodsSkuCodes) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.putIfAbsent("goodsSkuCodes", goodsSkuCodes);
Result<List<QueryGoodsImageListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallGoodsApiService.QUERY_GOODS_IMAGE_LIST,
params,
new ParameterizedTypeReference<Result<List<QueryGoodsImageListResponse>>>() {
});
return result.getData();
}
/**
* 获取商品上下架列表接口
*
* @param goodsSkuCodes
* @return
*/
public List<QueryGoodsShelvesListResponse> queryGoodsShelvesList(@RequestParam("goodsSkuCodes") List<String> goodsSkuCodes) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.putIfAbsent("goodsSkuCodes", goodsSkuCodes);
Result<List<QueryGoodsShelvesListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallGoodsApiService.QUERY_GOODS_SHELVES_LIST,
params,
new ParameterizedTypeReference<Result<List<QueryGoodsShelvesListResponse>>>() {
});
return result.getData();
}
/**
* 获取商品价格列表接口
*
* @param goodsSkuCodes
* @return
*/
public List<QueryGoodsPriceListResponse> queryGoodsPriceList(@RequestParam("goodsSkuCodes") List<String> goodsSkuCodes) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.putIfAbsent("goodsSkuCodes", goodsSkuCodes);
Result<List<QueryGoodsPriceListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallGoodsApiService.QUERY_GOODS_PRICE_LIST,
params,
new ParameterizedTypeReference<Result<List<QueryGoodsPriceListResponse>>>() {
});
return result.getData();
}
/**
* 获取商品库存列表接口
*
* @param goodsSkuCodes
* @return
*/
public List<QueryGoodsStockListResponse> queryGoodsStockList(@RequestParam("goodsSkuCodes") List<String> goodsSkuCodes) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.putIfAbsent("goodsSkuCodes", goodsSkuCodes);
Result<List<QueryGoodsStockListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallGoodsApiService.QUERY_GOODS_STOCK_LIST,
params,
new ParameterizedTypeReference<Result<List<QueryGoodsStockListResponse>>>() {
});
return result.getData();
}
/**
* 获取商品销售区域列表接口
*
* @param goodsSkuCodes
* @return
*/
public List<QueryGoodsSaleLimitListResponse> queryGoodsSaleLimitList(@RequestParam("goodsSkuCodes") List<String> goodsSkuCodes) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.putIfAbsent("goodsSkuCodes", goodsSkuCodes);
Result<List<QueryGoodsSaleLimitListResponse>> result = RestTemplateUtils.fetchGet(serverUrl + ShopmallGoodsApiService.QUERY_GOODS_SALE_LIMIT_LIST,
params,
new ParameterizedTypeReference<Result<List<QueryGoodsSaleLimitListResponse>>>() {
});
return result.getData();
}
}
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.api.ShopmallOrderApiService;
import cn.com.glsx.admin.modules.model.cloudcrane.request.*;
import cn.com.glsx.admin.modules.model.cloudcrane.response.*;
import com.glsx.plat.core.web.Result;
import com.glsx.plat.feign.utils.RestTemplateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.web.bind.annotation.RequestBody;
@Slf4j
public class ShopmallOrderService {
@Value("${platform.shopmall.url}")
private String serverUrl;
/**
* 提交订单接口
*
* @param req
* @return
*/
public CreateOrderResponse createOrder(@RequestBody CreateOrderRequest req) {
Result<CreateOrderResponse> result = RestTemplateUtils.fetchPostJson(serverUrl + ShopmallOrderApiService.CREATE_ORDER,
req,
new ParameterizedTypeReference<Result<CreateOrderResponse>>() {
});
return result.getData();
}
/**
* 预占确认订单接口
*
* @param req
* @return
*/
public ConfirmOrderResponse confirmOrder(@RequestBody ConfirmOrderRequest req) {
Result<ConfirmOrderResponse> result = RestTemplateUtils.fetchPostJson(serverUrl + ShopmallOrderApiService.CONFIRM_ORDER,
req,
new ParameterizedTypeReference<Result<ConfirmOrderResponse>>() {
});
return result.getData();
}
/**
* 取消订单接口
*
* @param req
* @return
*/
public CancelOrderResponse cancelOrder(@RequestBody CancelOrderRequest req) {
Result<CancelOrderResponse> result = RestTemplateUtils.fetchPostJson(serverUrl + ShopmallOrderApiService.CANCEL_ORDER,
req,
new ParameterizedTypeReference<Result<CancelOrderResponse>>() {
});
return result.getData();
}
/**
* 获取订单列表接口
*
* @param req
* @return
*/
public QueryOrderListResponse queryOrderList(@RequestBody QueryOrderListRequest req) {
Result<QueryOrderListResponse> result = RestTemplateUtils.fetchPostJson(serverUrl + ShopmallOrderApiService.QUERY_ORDER_LIST,
req,
new ParameterizedTypeReference<Result<QueryOrderListResponse>>() {
});
return result.getData();
}
/**
* 获取订单详情接口
*
* @param req
* @return
*/
public QueryOrderDetailResponse queryOrderDetail(@RequestBody QueryOrderDetailRequest req) {
Result<QueryOrderDetailResponse> result = RestTemplateUtils.fetchPostJson(serverUrl + ShopmallOrderApiService.QUERY_ORDER_DETAIL,
req,
new ParameterizedTypeReference<Result<QueryOrderDetailResponse>>() {
});
return result.getData();
}
/**
* 获取订单物流接口
*
* @param req
* @return
*/
public QueryOrderLogisticsResponse queryOrderLogistics(@RequestBody QueryOrderLogisticsRequest req) {
Result<QueryOrderLogisticsResponse> result = RestTemplateUtils.fetchPostJson(serverUrl + ShopmallOrderApiService.QUERY_ORDER_LOGISTICS,
req,
new ParameterizedTypeReference<Result<QueryOrderLogisticsResponse>>() {
});
return result.getData();
}
/**
* 获取订单发票接口
*
* @param req
* @return
*/
public QueryOrderInvoiceResponse queryOrderInvoice(@RequestBody QueryOrderInvoiceRequest req) {
Result<QueryOrderInvoiceResponse> result = RestTemplateUtils.fetchPostJson(serverUrl + ShopmallOrderApiService.QUERY_ORDER_INVOICE,
req,
new ParameterizedTypeReference<Result<QueryOrderInvoiceResponse>>() {
});
return result.getData();
}
public void setServerUrl(String serverUrl) {
this.serverUrl = serverUrl;
}
}
...@@ -49,7 +49,8 @@ public class GoodsApiController implements ShopmallGoodsApiService { ...@@ -49,7 +49,8 @@ public class GoodsApiController implements ShopmallGoodsApiService {
@Operation(summary = "获取商品图片列表接口", description = "查询获取云中鹤平台商城商品图片信息列表") @Operation(summary = "获取商品图片列表接口", description = "查询获取云中鹤平台商城商品图片信息列表")
@Override @Override
public List<QueryGoodsImageListResponse> queryGoodsImageList(@NotEmpty @RequestParam("goodsSkuCodes") List<String> goodsSkuCodes) { public List<QueryGoodsImageListResponse> queryGoodsImageList(@NotEmpty @RequestParam("goodsSkuCodes") List<String> goodsSkuCodes) {
return goodsService.queryGoodsImageList(goodsSkuCodes); List<QueryGoodsImageListResponse> list= goodsService.queryGoodsImageList(goodsSkuCodes);
return list;
} }
@Operation(summary = "获取商品上下架列表接口", description = "查询获取云中鹤平台商城商品上下架信息列表") @Operation(summary = "获取商品上下架列表接口", description = "查询获取云中鹤平台商城商品上下架信息列表")
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
type="cn.com.glsx.admin.modules.model.cloudcrane.response.QueryGoodsImageListResponse"> type="cn.com.glsx.admin.modules.model.cloudcrane.response.QueryGoodsImageListResponse">
<result column="goods_sku_code" jdbcType="VARCHAR" property="goodsSkuCode"/> <result column="goods_sku_code" jdbcType="VARCHAR" property="goodsSkuCode"/>
<collection property="imageList" ofType="cn.com.glsx.admin.modules.model.cloudcrane.response.GoodsImageListItem"> <collection property="imageList" ofType="cn.com.glsx.admin.modules.model.cloudcrane.response.GoodsImageListItem">
<result column="goods_sku_code" jdbcType="VARCHAR" property="goodsSkuCode"/>
<result column="img_url" jdbcType="VARCHAR" property="imgUrl"/> <result column="img_url" jdbcType="VARCHAR" property="imgUrl"/>
<result column="img_main" jdbcType="INTEGER" property="imgMain"/> <result column="img_main" jdbcType="INTEGER" property="imgMain"/>
<result column="img_sort" jdbcType="INTEGER" property="imgSort"/> <result column="img_sort" jdbcType="INTEGER" property="imgSort"/>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!