This commit is contained in:
张良(004796)
2024-01-02 17:38:12 +08:00
parent c3b9c761af
commit f1b95235d8
8 changed files with 71 additions and 12 deletions

View File

@@ -0,0 +1,41 @@
package com.ruoyi.cai.controller.admin;
import com.ruoyi.cai.dto.admin.SystemConfigResponse;
import com.ruoyi.cai.enums.SystemConfigEnum;
import com.ruoyi.cai.manager.SystemConfigManager;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/cai/systemConfig")
public class SystemConfigController {
@Autowired
private SystemConfigManager systemConfigManager;
@GetMapping("/all")
public R<List<SystemConfigResponse>> all(){
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);
}
return R.ok(responses);
}
@GetMapping("/update")
public R<Boolean> update(String key,String value){
systemConfigManager.set(key,value);
return R.ok(true);
}
}