记得上下班打卡 | git大法好,push需谨慎

Commit 20d74a74 authored by jiangxiulong's avatar jiangxiulong

开通同步通知 完善

parent 160f4415
......@@ -31,14 +31,14 @@ public class GoblinRscController {
@ApiImplicitParams({
@ApiImplicitParam(type = "form", dataType = "String", name = "userId", value = "用户ID", example = "1", required = true),
})
public ResponseDto<Boolean> syncNotice(
public ResponseDto syncNotice(
@RequestParam("userId") @NotBlank(message = "用户ID不能为空") String userId
) {
Boolean notice = accountService.syncNotice(userId);
if (notice) {
return ResponseDto.success();
return ResponseDto.success("同步成功");
} else {
return ResponseDto.failure();
return ResponseDto.failure("未获取到数据");
}
}
......
package com.liquidnet.service.goblin.service.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.adam.dto.vo.AdamUserBizAcctVo;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
@Service
@Slf4j
......@@ -12,11 +21,26 @@ public class GoblinNftNumAccountServiceImpl {
@Autowired
private GoblinRedisUtils goblinRedisUtils;
@Value("${liquidnet.service.adam.url}")
private String adamUrl;
public Boolean syncNotice(String userId) {
// TODO: jxl 2022/4/6 请求adam
// 请求adam
MultiValueMap<String, String> headers = CollectionUtil.linkedMultiValueMapStringString();
headers.add("Accept", MediaType.APPLICATION_JSON_UTF8_VALUE);
headers.set("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
String returnData = HttpUtil.getByUri(adamUrl.concat("/adam/rsc/inquire/bizacc?bizCode=NFT_ZX&uid=".concat(userId)), headers);
ResponseDto<AdamUserBizAcctVo> rsp = JsonUtils.fromJson(returnData, new TypeReference<ResponseDto<AdamUserBizAcctVo>>() {
});
AdamUserBizAcctVo rspData = rsp.getData();
if (null != rspData) {
// 写入redis
goblinRedisUtils.setNftNumAccount(userId);
return true;
} else {
log.info("同步数字账号失败,信息不存在 [userId:{}]", userId);
return false;
}
}
}
......@@ -1399,7 +1399,7 @@ public class GoblinRedisUtils {
//
public void setNftNumAccount(String userId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT.concat(userId);
// redisUtil.set(redisKey, 1);
redisUtil.set(redisKey, 1);
}
/* ---------------------------------------- ---------------------------------------- */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment