Commit 0ae9f55a authored by 赵啸非's avatar 赵啸非

修改操作日志过滤

parent 82b85ea9
......@@ -11502,6 +11502,54 @@ dict|object|字典对象
```
## 微中台
### 获取微中台签名信息
**请求URL:** base/mid/sign
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 获取微中台签名信息
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:------
**请求样例:**
```
{}
```
**响应参数:**
参数名称|参数类型|描述
:---|:---|:------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
 appId|String|应用id
 appKey|String|应用key
 timeStamp|String|时间戳
 nonce|String|随机数
 secretKey|String|密码
 sign|String|签名
**响应消息样例:**
```
{
"code":1,
"data":{
}
}
```
## 字典附录
### isBusiness
......
package com.mortals.xhx.busiz.req;
import lombok.Data;
/**
* 微中台请求接口
* @author:
* @date: 2023/3/2 18:08
*/
@Data
public class MidReq{
private String appId;
private String appKey;
private String timeStamp;
private String nonce;
private String secretKey;
}
package com.mortals.xhx.busiz.rsp;
import lombok.Data;
/**
* @author karlhoo
*/
@Data
public class SignResp {
private String appId;
private String appKey;
private String timeStamp;
private String nonce;
private String secretKey;
private String sign;
}
package com.mortals.xhx.busiz.web;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.busiz.req.MidReq;
import com.mortals.xhx.busiz.rsp.SignResp;
import com.mortals.xhx.common.utils.EncryptionUtils;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.model.MatterQuery;
import com.mortals.xhx.module.matter.service.MatterService;
import com.mortals.xhx.module.site.model.SiteMatterEntity;
import com.mortals.xhx.module.site.model.SiteMatterQuery;
import com.mortals.xhx.module.site.service.SiteMatterService;
import com.mortals.xhx.module.window.model.WindowEntity;
import com.mortals.xhx.module.window.model.WindowMatterEntity;
import com.mortals.xhx.module.window.model.WindowMatterQuery;
import com.mortals.xhx.module.window.model.WindowQuery;
import com.mortals.xhx.module.window.service.WindowMatterService;
import com.mortals.xhx.module.window.service.WindowService;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 微中台签名接口
*
* @author:
* @date: 2023/3/2 18:07
*/
@RestController
@RequestMapping("mid")
@Slf4j
public class MidSignApiController {
@Value("${mid.appId:54749E3AAE10F9BF}")
private String appId;
@Value("${mid.appKey:ab2a0e868bbea35e}")
private String appKey;
@Value("${mid.secretKey:86fd39858e2fe9df}")
private String secretKey;
@PostMapping(value = "sign")
@UnAuth
public Rest<SignResp> midSign() {
SignResp signResp = new SignResp();
try {
Map<String, String> headerMap = new HashMap<>();
headerMap.put("appId", appId);
headerMap.put("appKey", appKey);
String timeStamp = System.currentTimeMillis() + "";
headerMap.put("timeStamp", timeStamp);
String nonce = RandomUtil.randomNumbers(12);
headerMap.put("nonce", nonce);
headerMap.put("appSecret", secretKey);
signResp.setAppId(appId);
signResp.setAppKey(appKey);
signResp.setTimeStamp(timeStamp);
signResp.setNonce(nonce);
signResp.setSecretKey(secretKey);
StringBuilder signSb = new StringBuilder();
for (Map.Entry<String, String> params : headerMap.entrySet()) {
signSb.append(params.getKey()).append("=").append(params.getValue() + "").append("&");
}
String signStr = signSb.substring(0, signSb.length() - 1);
String sign = EncryptionUtils.SHA256(signStr);
signResp.setSign(sign);
return Rest.ok(sign);
} catch (Exception e) {
log.error("签名异常",e);
return Rest.fail("签名异常!");
}
}
}
package com.mortals.xhx.common.utils;
import lombok.extern.slf4j.Slf4j;
import java.security.MessageDigest;
@Slf4j
public class EncryptionUtils {
private enum DigestType{
MD5("MD5"),
SHA("SHA"),
SHA256("SHA-256");
private String name;
private DigestType(String name){
this.name = name;
}
public String getName() {
return name;
}
}
private final static String digest(String sourceStr,DigestType type) {
char hexDigits[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
try {
byte[] btInput = sourceStr.getBytes();
// 获得摘要算法的 MessageDigest 对象
MessageDigest mdInst = MessageDigest.getInstance(type.name);
// 使用指定的字节更新摘要
mdInst.update(btInput);
// 获得密文
byte[] md = mdInst.digest();
// 把密文转换成十六进制的字符串形式
int length = md.length;
char str[] = new char[length * 2];
int k = 0;
for (int i = 0; i < length; i++) {
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str);
} catch (Exception e) {
log.error("签名失败", e);
return "";
}
}
public final static String MD5(String s) {
return digest(s, DigestType.MD5);
}
public final static String SHA(String s) {
return digest(s, DigestType.SHA);
}
public final static String SHA256(String s){
return digest(s, DigestType.SHA256);
}
}
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