feat(service): 向WMS请求添加Authorization头
- 引入StpUtil获取Token - 在请求头中添加Authorization字段 - 确保向WMS系统发送的POST请求携带用户认证信息 - 优化日志记录,保持业务描述和请求数据完整
This commit is contained in:
parent
bae76d6707
commit
771fc37fe4
|
|
@ -1,7 +1,9 @@
|
||||||
package com.nflg.qms.admin.service;
|
package com.nflg.qms.admin.service;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.nflg.wms.common.pojo.ApiResult;
|
import com.nflg.wms.common.pojo.ApiResult;
|
||||||
|
import com.nflg.wms.common.util.UserUtil;
|
||||||
import com.nflg.wms.common.util.VUtil;
|
import com.nflg.wms.common.util.VUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
@ -33,7 +35,6 @@ public class WmsApiService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向WMS系统发送POST请求
|
* 向WMS系统发送POST请求
|
||||||
*
|
|
||||||
* @param path 接口路径
|
* @param path 接口路径
|
||||||
* @param body 请求体
|
* @param body 请求体
|
||||||
* @param bizDesc 业务描述,用于日志和异常提示
|
* @param bizDesc 业务描述,用于日志和异常提示
|
||||||
|
|
@ -45,6 +46,7 @@ public class WmsApiService {
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
headers.add("Authorization", StpUtil.getTokenValue());
|
||||||
HttpEntity<T> requestEntity = new HttpEntity<>(body, headers);
|
HttpEntity<T> requestEntity = new HttpEntity<>(body, headers);
|
||||||
|
|
||||||
log.info("{},URL: {},数据: {}", bizDesc, fullUrl, JSONUtil.toJsonStr(body));
|
log.info("{},URL: {},数据: {}", bizDesc, fullUrl, JSONUtil.toJsonStr(body));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue