瀏覽代碼

IRS请求转发

master
PoffyZhang 1 年之前
父節點
當前提交
b0f7b34a7b
共有 5 個檔案被更改,包括 76 行新增0 行删除
  1. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/constant/BizConst.java
  2. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java
  3. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/controller/IrsController.java
  4. +26
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/ForwardDTO.java
  5. +38
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/IrsManage.java

+ 1
- 0
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 = "保存失败";
}

+ 10
- 0
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;



+ 1
- 0
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;


+ 26
- 0
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<String,Object> data;
}

+ 38
- 0
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<String> 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<String, Object> source){
return Joiner.on("&")
// 用指定符号代替空值,key 或者value 为null都会被替换
.useForNull("")
.withKeyValueSeparator("=")
.join(source);
}
}

Loading…
取消
儲存