| | |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class ConfigController extends BaseController { |
| | | |
| | | @Autowired |
| | |
| | | return R.ok().add(configService.getById(id)); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('system:config:list')") |
| | | @GetMapping("/config/flag/{flag}") |
| | | public R getByFlag(@PathVariable("flag") String flag) { |
| | | return R.ok().add(configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, flag))); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('system:config:save')") |
| | | @OperationLog("Create Config") |
| | | @PostMapping("/config/save") |
| | |
| | | config.setUpdateTime(new Date()); |
| | | if (!configService.save(config)) { |
| | | return R.error("Save Fail"); |
| | | } else { |
| | | ConfigServiceImpl.CONFIG_CACHE.put(config.getFlag(), config); |
| | | } |
| | | ConfigServiceImpl.CONFIG_CACHE.put(config.getFlag(), config); |
| | | configService.evictSysConfigRedis(config.getFlag()); |
| | | return R.ok("Save Success").add(config); |
| | | } |
| | | |
| | |
| | | config.setUpdateTime(new Date()); |
| | | if (!configService.updateById(config)) { |
| | | return R.error("Update Fail"); |
| | | } else { |
| | | ConfigServiceImpl.CONFIG_CACHE.put(config.getFlag(), config); |
| | | } |
| | | ConfigServiceImpl.CONFIG_CACHE.put(config.getFlag(), config); |
| | | configService.evictSysConfigRedis(config.getFlag()); |
| | | return R.ok("Update Success").add(config); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:config:update')") |
| | | @OperationLog("Update Config") |
| | | @PostMapping("/config/byFlag") |
| | | public R updateByFlag(@RequestBody Config config) { |
| | | if (Objects.isNull(config)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return configService.modiftyStatus(config); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:config:remove')") |
| | |
| | | } |
| | | if (!configService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | } else { |
| | | for (String flag : flagList) { |
| | | ConfigServiceImpl.CONFIG_CACHE.remove(flag); |
| | | } |
| | | } |
| | | for (String flag : flagList) { |
| | | ConfigServiceImpl.CONFIG_CACHE.remove(flag); |
| | | configService.evictSysConfigRedis(flag); |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | } |