mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-07-23 09:39:33 +08:00
系统配置隐秘信息mask
This commit is contained in:
parent
f4002b799b
commit
a35a767514
@ -27,11 +27,6 @@ import xyz.playedu.api.service.AppConfigService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
*
|
||||
* @create 2023/3/9 13:29
|
||||
*/
|
||||
@Component
|
||||
public class AppConfigCheck implements ApplicationRunner {
|
||||
|
||||
@ -196,6 +191,7 @@ public class AppConfigCheck implements ApplicationRunner {
|
||||
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_TEXT);
|
||||
setKeyName(CConfig.MINIO_SECRET_KEY);
|
||||
setKeyValue("");
|
||||
setIsPrivate(1);
|
||||
}
|
||||
},
|
||||
new AppConfig() {
|
||||
|
@ -30,4 +30,6 @@ public class SystemConstant {
|
||||
public static final String INTERNAL_IP = "127.0.0.1";
|
||||
|
||||
public static final String INTERNAL_IP_AREA = "内网";
|
||||
|
||||
public static final String CONFIG_MASK = "********";
|
||||
}
|
||||
|
@ -19,12 +19,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import xyz.playedu.api.constant.BPermissionConstant;
|
||||
import xyz.playedu.api.constant.SystemConstant;
|
||||
import xyz.playedu.api.domain.AppConfig;
|
||||
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
|
||||
import xyz.playedu.api.request.backend.AppConfigRequest;
|
||||
import xyz.playedu.api.service.AppConfigService;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -42,13 +45,29 @@ public class AppConfigController {
|
||||
@GetMapping("")
|
||||
public JsonResponse index() {
|
||||
List<AppConfig> configs = configService.allShow();
|
||||
return JsonResponse.data(configs);
|
||||
List<AppConfig> data = new ArrayList<>();
|
||||
for (AppConfig item : configs) {
|
||||
if (item.getIsPrivate() == 1) {
|
||||
item.setKeyValue(SystemConstant.CONFIG_MASK);
|
||||
}
|
||||
data.add(item);
|
||||
}
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.SYSTEM_CONFIG)
|
||||
@PutMapping("")
|
||||
public JsonResponse save(@RequestBody AppConfigRequest req) {
|
||||
configService.saveFromMap(req.getData());
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
req.getData()
|
||||
.forEach(
|
||||
(key, value) -> {
|
||||
if (SystemConstant.CONFIG_MASK.equals(value)) {
|
||||
return;
|
||||
}
|
||||
data.put(key, value);
|
||||
});
|
||||
configService.saveFromMap(data);
|
||||
return JsonResponse.data(null);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user