mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-04 15:27:32 +00:00
敏感数据处理
This commit is contained in:
@@ -25,12 +25,14 @@ import org.ruoyi.system.domain.vo.SysUserVo;
|
||||
import org.ruoyi.system.service.ISysModelService;
|
||||
import org.ruoyi.system.service.ISysPackagePlanService;
|
||||
import org.ruoyi.system.service.ISysUserService;
|
||||
import org.ruoyi.system.util.DesensitizationUtil;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统模型
|
||||
@@ -50,7 +52,6 @@ public class SysModelController extends BaseController {
|
||||
|
||||
private final ISysUserService userService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询系统模型列表 - 全部
|
||||
*/
|
||||
@@ -82,6 +83,14 @@ public class SysModelController extends BaseController {
|
||||
List<String> array = new ArrayList<>(Arrays.asList(sysPackagePlanVo.getPlanDetail().split(",")));
|
||||
sysModelVos.removeIf(model -> !array.contains(model.getModelName()));
|
||||
}
|
||||
sysModelVos.stream().map(vo -> {
|
||||
String maskedApiHost = DesensitizationUtil.maskData(vo.getApiHost());
|
||||
String maskedApiKey = DesensitizationUtil.maskData(vo.getApiKey());
|
||||
vo.setApiHost(maskedApiHost);
|
||||
vo.setApiKey(maskedApiKey);
|
||||
return vo;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return R.ok(sysModelVos);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.ruoyi.system.util;
|
||||
|
||||
|
||||
public class DesensitizationUtil {
|
||||
public static String maskData(String data) {
|
||||
if (data == null || data.length() <= 4) {
|
||||
return data;
|
||||
}
|
||||
int start = 2;
|
||||
int end = data.length() - 2;
|
||||
StringBuilder masked = new StringBuilder();
|
||||
masked.append(data, 0, start);
|
||||
for (int i = start; i < end; i++) {
|
||||
masked.append('*');
|
||||
}
|
||||
masked.append(data.substring(end));
|
||||
return masked.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user