init
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ruoyi.cai.controller.admin;
|
||||
|
||||
import com.ruoyi.cai.dto.admin.SystemConfigResponse;
|
||||
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||
import com.ruoyi.cai.enums.SystemConfigGroupEnum;
|
||||
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -18,23 +19,53 @@ import java.util.Map;
|
||||
public class SystemConfigController {
|
||||
@Autowired
|
||||
private SystemConfigManager systemConfigManager;
|
||||
@GetMapping("/all")
|
||||
public R<List<SystemConfigResponse>> all(){
|
||||
@GetMapping("/business/all")
|
||||
public R<List<SystemConfigResponse>> businessAll(){
|
||||
List<SystemConfigResponse> responses = new ArrayList<>();
|
||||
Map<String, String> allSystemConfig = systemConfigManager.getAllSystemConfig();
|
||||
SystemConfigEnum[] values = SystemConfigEnum.values();
|
||||
for (SystemConfigEnum value : values) {
|
||||
SystemConfigResponse sys = new SystemConfigResponse();
|
||||
sys.setKey(value.getKey());
|
||||
sys.setValue(allSystemConfig.getOrDefault(value.getKey(),value.getDefaultValue()));
|
||||
sys.setDesc(value.getDesc());
|
||||
responses.add(sys);
|
||||
if(value.getGroup() == SystemConfigGroupEnum.BUSINESS){
|
||||
SystemConfigResponse sys = new SystemConfigResponse();
|
||||
sys.setKey(value.getKey());
|
||||
sys.setValue(allSystemConfig.getOrDefault(value.getKey(),value.getDefaultValue()));
|
||||
sys.setDesc(value.getDesc());
|
||||
responses.add(sys);
|
||||
}
|
||||
}
|
||||
return R.ok(responses);
|
||||
}
|
||||
|
||||
@GetMapping("/update")
|
||||
public R<Boolean> update(String key,String value){
|
||||
@GetMapping("/business/update")
|
||||
public R<Boolean> businessUpdate(String key,String value){
|
||||
SystemConfigEnum[] values = SystemConfigEnum.values();
|
||||
for (SystemConfigEnum config : values) {
|
||||
if (config.getGroup() == SystemConfigGroupEnum.BUSINESS && config.getKey().equals(key)) {
|
||||
systemConfigManager.set(key,value);
|
||||
}
|
||||
}
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@GetMapping("/system/all")
|
||||
public R<List<SystemConfigResponse>> systemAll(){
|
||||
List<SystemConfigResponse> responses = new ArrayList<>();
|
||||
Map<String, String> allSystemConfig = systemConfigManager.getAllSystemConfig();
|
||||
SystemConfigEnum[] values = SystemConfigEnum.values();
|
||||
for (SystemConfigEnum value : values) {
|
||||
if(value.getGroup() == SystemConfigGroupEnum.SYSTEM){
|
||||
SystemConfigResponse sys = new SystemConfigResponse();
|
||||
sys.setKey(value.getKey());
|
||||
sys.setValue(allSystemConfig.getOrDefault(value.getKey(),value.getDefaultValue()));
|
||||
sys.setDesc(value.getDesc());
|
||||
responses.add(sys);
|
||||
}
|
||||
}
|
||||
return R.ok(responses);
|
||||
}
|
||||
|
||||
@GetMapping("/system/update")
|
||||
public R<Boolean> systemUpdate(String key,String value){
|
||||
systemConfigManager.set(key,value);
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user