Merge branch 'master' of https://codeup.aliyun.com/64d9c5feeceb191898f636d7/honor-dd-light-ds-java
commit
3c1e018649
@ -0,0 +1,36 @@
|
||||
package com.ms.api.spi.callback;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.jinritemai.cloud.base.api.BaseRequest;
|
||||
import com.jinritemai.cloud.base.api.BaseResponse;
|
||||
import com.jinritemai.cloud.base.api.ExtensionService;
|
||||
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
|
||||
import com.ms.api.common.R;
|
||||
import com.ms.api.common.SPIBaseService;
|
||||
import com.ms.api.dto.auth.PlatformAuthCallBackRequestDTO;
|
||||
import com.ms.api.tool.CommonTool;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 1688分销采购单消息
|
||||
*/
|
||||
@ExtensionService("dsMessageCallback")
|
||||
@Slf4j
|
||||
public class DsMessageCallbackService extends SPIBaseService implements ExtensionServiceHandler<PlatformAuthCallBackRequestDTO, Map<String, String>> {
|
||||
|
||||
@Override
|
||||
public BaseResponse<Map<String, String>> handle(BaseRequest<PlatformAuthCallBackRequestDTO> req) {
|
||||
// ----参数校验----
|
||||
PlatformAuthCallBackRequestDTO fields = req.getData();
|
||||
log.info("receive callback: " + JSON.toJSONString(fields));
|
||||
|
||||
// ----逻辑校验----
|
||||
|
||||
// ----业务处理----
|
||||
|
||||
// ----结果返回----
|
||||
return R.ok(CommonTool.successResult());
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.ms.api.spi.callback;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.jinritemai.cloud.base.api.BaseRequest;
|
||||
import com.jinritemai.cloud.base.api.BaseResponse;
|
||||
import com.jinritemai.cloud.base.api.ExtensionService;
|
||||
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
|
||||
import com.ms.api.common.R;
|
||||
import com.ms.api.common.SPIBaseService;
|
||||
import com.ms.api.dto.auth.PlatformAuthCallBackRequestDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 抖店消息推送,固定的key:CloudOpenMsgConsumer
|
||||
*/
|
||||
@ExtensionService("CloudOpenMsgConsumer")
|
||||
@Slf4j
|
||||
public class OpenMsgConsumerService extends SPIBaseService implements ExtensionServiceHandler<List<String>, Void> {
|
||||
|
||||
@Override
|
||||
public BaseResponse<Void> handle(BaseRequest<List<String>> req) {
|
||||
// ----参数校验----
|
||||
|
||||
// ----逻辑校验----
|
||||
|
||||
// ----业务处理----
|
||||
return R.ok();
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.ms.api.spi.callback;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.doudian.open.api.token_create.TokenCreateRequest;
|
||||
import com.doudian.open.api.token_create.TokenCreateResponse;
|
||||
import com.doudian.open.api.token_create.data.TokenCreateData;
|
||||
import com.doudian.open.api.token_create.param.TokenCreateParam;
|
||||
import com.jinritemai.cloud.base.api.BaseRequest;
|
||||
import com.jinritemai.cloud.base.api.BaseResponse;
|
||||
import com.jinritemai.cloud.base.api.ExtensionService;
|
||||
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
|
||||
import com.ms.api.common.R;
|
||||
import com.ms.api.common.SPIBaseService;
|
||||
import com.ms.api.dto.auth.PlatformAuthCallBackRequestDTO;
|
||||
import com.ms.api.service.ShopService;
|
||||
import com.ms.api.tool.CommonTool;
|
||||
import com.ms.dal.entity.Shop;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 抖店授权回调地址
|
||||
*/
|
||||
@ExtensionService("shopAuthCallback")
|
||||
@Slf4j
|
||||
public class ShopAuthCallbackService extends SPIBaseService implements ExtensionServiceHandler<Object, Map<String, String>> {
|
||||
|
||||
@Autowired
|
||||
private ShopService shopService;
|
||||
|
||||
@Override
|
||||
public BaseResponse<Map<String, String>> handle(BaseRequest<Object> req) {
|
||||
// ----参数校验----
|
||||
log.info("receive callback: " + JSON.toJSONString(req));
|
||||
Object fields = req.getData();
|
||||
log.info("receive callback: " + JSON.toJSONString(fields));
|
||||
|
||||
|
||||
// ----逻辑校验----
|
||||
TokenCreateRequest request = new TokenCreateRequest();
|
||||
TokenCreateParam param = request.getParam();
|
||||
param.setCode("df020f1c-37ed-41b5-8341-85d3d3b02250");
|
||||
param.setGrantType("authorization_code");
|
||||
log.info("receive callback: " + JSON.toJSONString(param));
|
||||
TokenCreateResponse response = request.execute();
|
||||
TokenCreateData data = new TokenCreateData();
|
||||
data = response.getData();
|
||||
Long shopId = data.getShopId();
|
||||
String accessToken = data.getAccessToken();
|
||||
Long expiresIn = data.getExpiresIn();
|
||||
String shopName = data.getShopName();
|
||||
String refreshToken = data.getRefreshToken();
|
||||
Shop shop = shopService.getDetailById(shopId);
|
||||
if (shop == null) {
|
||||
shop = new Shop();
|
||||
shop.setShopId(shopId);
|
||||
// shop.setAccessToken(accessToken); // 加密
|
||||
// shop.setRefreshToken(refreshToken); // 加密
|
||||
shop.setExpiresIn(expiresIn.toString());
|
||||
shop.setShopName(shopName);
|
||||
shopService.insert(shop);
|
||||
} else {
|
||||
// shop.setAccessToken(accessToken); // 加密
|
||||
// shop.setRefreshToken(refreshToken); // 加密
|
||||
shopService.updateByPrimaryKey(shop);
|
||||
}
|
||||
|
||||
|
||||
// log.info("receive callback: " + JSON.toJSONString(response.getData()));
|
||||
// ----业务处理----
|
||||
|
||||
// ----结果返回----
|
||||
return R.ok(CommonTool.successResult());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue