diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java index 5e4f337..59f551e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java @@ -96,5 +96,6 @@ public interface BizConst { String SAVE_SUCCESS = "保存成功"; String OP_SUCCESS = "操作成功"; + String OP_FAIL = "操作失败"; String SAVE_FAIL = "保存失败"; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java b/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java index 89c9f91..8c39157 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java @@ -8,7 +8,9 @@ import com.ningdatech.pmapi.ding.task.EmployeeBatchGetTask; import com.ningdatech.pmapi.ding.task.GovBusinessStripsTask; import com.ningdatech.pmapi.ding.task.OrganizationBatchGetTask; import com.ningdatech.pmapi.irs.manage.AppIrsManage; +import com.ningdatech.pmapi.irs.model.dto.ForwardDTO; import com.ningdatech.pmapi.organization.manage.ProcDefManage; +import com.ningdatech.pmapi.projectdeclared.manage.IrsManage; import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.service.IProjectService; @@ -51,6 +53,8 @@ public class DingInfoPullController { private final ProcDefManage procDefManage; + private final IrsManage irsManage; + @Resource private IRefreshTokenService refreshTokenService; @@ -261,6 +265,12 @@ public class DingInfoPullController { return procDefManage.synchronouOrgBiz(); } + @ApiOperation(value = "转发IRS请求", notes = "转发IRS请求 用于") + @GetMapping("/forward") + public String forward(ForwardDTO dto) { + return irsManage.forward(dto); + } + public static Workbook readExcel(InputStream is, String extString){ Workbook wb = null; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java index 6b92eed..f5b1ed0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java @@ -1,6 +1,7 @@ package com.ningdatech.pmapi.irs.controller; import com.ningdatech.log.annotation.WebLog; +import com.ningdatech.pmapi.irs.model.dto.ForwardDTO; import com.ningdatech.pmapi.projectdeclared.manage.IrsManage; import com.ningdatech.pmapi.projectdeclared.model.vo.IrsApplicationVO; import com.ningdatech.pmapi.projectdeclared.model.vo.PiotTasksVO; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ForwardDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ForwardDTO.java new file mode 100644 index 0000000..47c4075 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ForwardDTO.java @@ -0,0 +1,26 @@ +package com.ningdatech.pmapi.irs.model.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Map; + +/** + * @Classname ForwardDTO + * @Description + * @Date 2023/7/13 18:03 + * @Author PoffyZhang + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ForwardDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String url; + private String secret; + private String appKey; + private Map data; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java index 6e29118..78a1b32 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java @@ -5,11 +5,15 @@ import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.google.common.base.Joiner; import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.util.CryptUtils; import com.ningdatech.pmapi.common.util.HttpUtil; +import com.ningdatech.pmapi.common.util.RefreshKeyUtil; import com.ningdatech.pmapi.irs.manage.AppIrsManage; import com.ningdatech.pmapi.irs.model.dto.ApiApplyDTO; +import com.ningdatech.pmapi.irs.model.dto.ForwardDTO; import com.ningdatech.pmapi.irs.utils.RefreshTokenUtil; import com.ningdatech.pmapi.projectdeclared.model.entity.IrsApplication; import com.ningdatech.pmapi.projectdeclared.model.entity.NdPiotTasks; @@ -19,6 +23,7 @@ import com.ningdatech.pmapi.projectdeclared.service.INdPiotTasksService; import com.ningdatech.pmapi.projectdeclared.service.IrsApplicationService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; @@ -27,6 +32,7 @@ import org.springframework.web.client.RestTemplate; import java.security.NoSuchAlgorithmException; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -102,4 +108,36 @@ public class IrsManage { log.info(forEntity.getBody()); return forEntity.getBody(); } + + /** + * 转发IRS请求 + * @param dto + * @return + */ + public String forward(ForwardDTO dto) { + try{ + String url = dto.getUrl(); + String appkey = dto.getAppKey(); + long timestamp = System.currentTimeMillis(); + String requestSecret = dto.getSecret(); + String sign = CryptUtils.MD5Encode(appkey + requestSecret + timestamp); + url = url + "?requestTime=" + timestamp + "&sign=" + sign + asUrlParams(dto.getData()); + log.info("url :{}",url); + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity forEntity = restTemplate.getForEntity(url, String.class); + log.info(forEntity.getBody()); + return forEntity.getBody(); + }catch (Exception e){ + log.error("e:" + e); + } + return BizConst.OP_FAIL; + } + + public static String asUrlParams(Map source){ + return Joiner.on("&") + // 用指定符号代替空值,key 或者value 为null都会被替换 + .useForNull("") + .withKeyValueSeparator("=") + .join(source); + } }