From b37275dba6b782bf3bb3817c4504f6cdef1bef7c Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 18 三月 2021 18:38:51 +0800 Subject: [PATCH] APP首页顶部标签兼容 --- src/main/java/com/yeshi/buwan/controller/admin/api/ConfigController.java | 64 +++++++++++++++++++------------ 1 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/controller/admin/api/ConfigController.java b/src/main/java/com/yeshi/buwan/controller/admin/api/ConfigController.java index 3b4f011..3ed11a1 100644 --- a/src/main/java/com/yeshi/buwan/controller/admin/api/ConfigController.java +++ b/src/main/java/com/yeshi/buwan/controller/admin/api/ConfigController.java @@ -5,6 +5,9 @@ import javax.annotation.Resource; +import com.yeshi.buwan.util.EHCacheManager; +import com.yeshi.buwan.util.JsonUtil; +import com.yeshi.buwan.util.StringUtil; import com.yeshi.buwan.util.SystemUtil; import org.json.JSONArray; import org.json.JSONObject; @@ -12,51 +15,62 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import com.yeshi.buwan.domain.Config; -import com.yeshi.buwan.service.imp.ConfigService; +import com.yeshi.buwan.domain.system.DetailSystemConfig; +import com.yeshi.buwan.service.imp.DetailSystemConfigService; @Controller @RequestMapping("admin/new/api/config") public class ConfigController { @Resource - private ConfigService configService; + private DetailSystemConfigService configService; + + @Resource + private EHCacheManager ehCacheManager; @RequestMapping("configList") - public void configList(PrintWriter out) { - - List<Config> list = configService.getConfig(SystemUtil.getDetailSystemId(), SystemUtil.getDefaultVersion()); + public void configList(Long detailSystemId, String key, PrintWriter out) { + key = StringUtil.isNullOrEmpty(key) ? "" : key.trim(); + List<DetailSystemConfig> list = configService.listConfig(detailSystemId, key); JSONObject json = new JSONObject(); json.put("code", "0"); JSONArray listJson = new JSONArray(list); json.put("configList", listJson); - - System.out.println("Json--" + json); - System.out.println("JsonS--" + json.toString()); - out.print(json); - return; } @RequestMapping(value = "updateConfig", method = RequestMethod.POST) - public void updateConfig(String vals, PrintWriter out) { - List<Config> list = configService.getConfig(SystemUtil.getDetailSystemId(), SystemUtil.getDefaultVersion()); + public void updateConfig(String id, String value, PrintWriter out) { + DetailSystemConfig config = configService.getConfig(Integer.parseInt(id)); + JSONObject json = new JSONObject(); - System.out.println("vals----" + vals); - JSONObject json = new JSONObject(vals); - for (Config cf : list) { - String key = cf.getKey(); - cf.setValue(json.getString(key)); -// configService.updateConfig(cf); - } - boolean b = configService.updateConfigList(list); - if (b) { - out.print("yes"); + if (config == null) { + json.put("code", 1); + json.put("msg", "閰嶇疆涓嶅瓨鍦�"); } else { - out.print("no"); + config.setValue(value); + configService.saveConfig(config); + json.put("code", 0); } + out.print(json); + return; + } - + /** + * 娓呴櫎缂撳瓨 + * + * @param cache + * @param out + */ + @RequestMapping(value = "clearCache", method = RequestMethod.POST) + public void clearCache(String cache, PrintWriter out) { + //娓呴櫎鍏ㄩ儴缂撳瓨 + if (StringUtil.isNullOrEmpty(cache)) { + ehCacheManager.removeAllCache(); + } else { + ehCacheManager.clearCacheByCacheName(cache); + } + out.print(JsonUtil.loadTrueAdmin("")); return; } -- Gitblit v1.8.0