|
@@ -2,6 +2,7 @@ package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.CacheConstants;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.OladingCommonRequest;
|
|
@@ -10,7 +11,6 @@ import com.qunzhixinxi.hnqz.admin.entity.model.OladingSignUpRequest;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.gig.GigThirdApiService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.gig.OladingInputRecordService;
|
|
|
import com.qunzhixinxi.hnqz.admin.util.HMACSignProvider;
|
|
|
-import com.qunzhixinxi.hnqz.common.core.exception.ValidateCodeException;
|
|
|
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
|
|
|
import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -62,7 +63,8 @@ public class GigThirdApiController {
|
|
|
@Inner(value = false)
|
|
|
@SysLog("自由职家统一请求地址")
|
|
|
@PostMapping("/olading")
|
|
|
- public String oladingRequest(@RequestParam(value = "req", required = false) String reqStr, @RequestParam(required = false) String sign) {
|
|
|
+ public void oladingRequest(@RequestParam(value = "req", required = false) String reqStr,
|
|
|
+ @RequestParam(required = false) String sign, HttpServletResponse response) {
|
|
|
|
|
|
log.info("自由职家请求方法参数:req={}, sign={}", reqStr, sign);
|
|
|
|
|
@@ -70,12 +72,23 @@ public class GigThirdApiController {
|
|
|
OladingCommonRequest.Req req = JSONUtil.toBean(reqStr, OladingCommonRequest.Req.class);
|
|
|
// 请求接口名称
|
|
|
String interfaceName = req.getName();
|
|
|
+ // 请求requestId
|
|
|
+ String requestId = (String) req.getData().get("requestId");
|
|
|
+ if (StrUtil.isBlank(requestId)) {
|
|
|
+ requestId = (String) req.getData().get("request_id");
|
|
|
+ }
|
|
|
|
|
|
- String redisKey = CacheConstants.OLADING_SIGN_UP_NOTIFY_KEY + interfaceName + "_" + req.getData().get("requestId");
|
|
|
+ String redisKey = String.format("%s_%s_%s", CacheConstants.OLADING_SIGN_UP_NOTIFY_KEY, interfaceName, requestId);
|
|
|
Boolean absent = redisTemplate.opsForValue().setIfAbsent(redisKey, reqStr, 30, TimeUnit.MINUTES);
|
|
|
if (!absent) {
|
|
|
- log.error("存在在途操作{}", req.getData().get("request_id"));
|
|
|
- return "SUCCESS";
|
|
|
+ log.error("存在在途操作requestId={}", requestId);
|
|
|
+ try {
|
|
|
+ response.getWriter().write("SUCCESS");
|
|
|
+ response.getWriter().flush();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("response返回异常", e);
|
|
|
+ }
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
// 1.请求记录
|
|
@@ -109,11 +122,13 @@ public class GigThirdApiController {
|
|
|
default:
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ response.getWriter().write("SUCCESS");
|
|
|
+ response.getWriter().flush();
|
|
|
} catch (Exception e) {
|
|
|
log.error("自由职家统一请求异常", e);
|
|
|
}
|
|
|
|
|
|
- return "SUCCESS";
|
|
|
}
|
|
|
|
|
|
}
|