| 12345678910111213141516171819202122232425262728293031323334353637 |
- package cn.seecoder.paas.web.controller.api;
- import cn.seecoder.paas.service.ConfigService;
- import cn.seecoder.paas.service.EnvironmentService;
- import cn.seecoder.paas.service.model.vo.ConfigVO;
- import cn.seecoder.paas.util.ServiceException;
- import cn.seecoder.paas.util.enums.ConfigBelongsToType;
- import cn.seecoder.paas.web.model.Response;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- @RestController
- @RequestMapping("/api/config")
- public class ConfigController {
- private final ConfigService configService;
- private final EnvironmentService environmentService;
- @Autowired
- public ConfigController(ConfigService configService, EnvironmentService environmentService) {
- this.configService = configService;
- this.environmentService = environmentService;
- }
- @PutMapping("")
- public Response update(@RequestBody ConfigVO configVO,
- @RequestParam(required = false, defaultValue = "false") Boolean hotUpdate) throws ServiceException {
- ConfigVO result = configService.createOrUpdate(configVO);
- // 如果是环境配置且需要热更新
- if (hotUpdate && result.getConfigBelongs() == ConfigBelongsToType.ENVIRONMENT) {
- environmentService.hotUpdateConfig(result.getEntityId());
- }
- return Response.buildSuccess(result);
- }
- }
|