| | |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.controller.AbstractBaseController; |
| | | import com.zy.asrs.domain.param.ConfigUpdateBatchParam; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @RequestMapping(value = "/config/refreshCache") |
| | | @ManagerAuth |
| | | public R refreshCache(){ |
| | | HashMap<String, String> systemConfigMap = new HashMap<>(); |
| | | List<Config> configList = configService.selectList(new EntityWrapper<>()); |
| | | for (Config config : configList) { |
| | | systemConfigMap.put(config.getCode(), config.getValue()); |
| | | } |
| | | redisUtil.set(RedisKeyType.SYSTEM_CONFIG_MAP.key, systemConfigMap); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/config/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | return R.ok(configService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/config/listAll/auth") |
| | | @ManagerAuth |
| | | public R listAll(){ |
| | | EntityWrapper<Config> wrapper = new EntityWrapper<>(); |
| | | wrapper.orderBy("id", false); |
| | | return R.ok(configService.selectList(wrapper)); |
| | | } |
| | | |
| | | private void convert(Map<String, Object> map, EntityWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/config/updateBatch") |
| | | @ManagerAuth |
| | | public R updateBatch(@RequestBody List<ConfigUpdateBatchParam> params){ |
| | | for (ConfigUpdateBatchParam param : params) { |
| | | String code = param.getCode(); |
| | | String value = param.getValue(); |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", code)); |
| | | if (config == null) { |
| | | continue; |
| | | } |
| | | |
| | | config.setValue(value); |
| | | configService.updateById(config); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/config/edit/auth") |
| | | @ManagerAuth |
| | | public R edit(Config config) { |