From 399a1db3846dd02ed247343266962ade9c3b988e Mon Sep 17 00:00:00 2001 From: 喻健 <喻健@Admin> Date: 星期三, 21 十一月 2018 16:21:24 +0800 Subject: [PATCH] 后台系统参数调整 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/ConfigAdminController.java | 36 ++++++++++++++++++++++++++++++------ 1 files changed, 30 insertions(+), 6 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/ConfigAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/ConfigAdminController.java index b9a1e7e..ec2eb4e 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/ConfigAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/ConfigAdminController.java @@ -6,6 +6,7 @@ import java.util.Map; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import net.sf.json.JSONObject; @@ -13,10 +14,13 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import com.yeshi.fanli.entity.common.AdminUser; import com.yeshi.fanli.entity.common.Config; +import com.yeshi.fanli.service.AdminUserService; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; +import com.yeshi.fanli.util.annotation.RequestNoLogin; import org.yeshi.utils.JsonUtil; @@ -26,6 +30,10 @@ @Resource private ConfigService configService; + + @Resource + private AdminUserService adminUserService; + @RequestMapping(value = "getConfigList", method = RequestMethod.POST) public void getConfigList(PrintWriter out){ @@ -77,7 +85,10 @@ } int count = configService.getCount(key, pageIndex); - PageEntity pe = new PageEntity(pageIndex, Constant.PAGE_SIZE, count); + + int pageSize = Constant.PAGE_SIZE; + int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); + PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); JSONObject data = new JSONObject(); data.put("pe", pe); @@ -97,8 +108,19 @@ * @param config * @param out */ + @RequestNoLogin() @RequestMapping(value = "saveModify") - public void saveModify(String callback, Config config, PrintWriter out) { + public void saveModify(String callback,Long uid, Config config, HttpServletResponse response, PrintWriter out) { + + response.setHeader("Access-Control-Allow-Origin", "*"); + response.setHeader("Access-Control-Allow-Methods", "*"); + + AdminUser admin = adminUserService.selectByPrimaryKey(uid); + if (admin == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("褰撳墠璐︽埛楠岃瘉澶辫触")); + return; + } + Long id = config.getId(); if (id == null) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID涓嶈兘涓虹┖")); @@ -106,14 +128,16 @@ } try { - Config crentconfig = configService.getConfig(id); - if (crentconfig == null) { + Config resultconfig = configService.getConfig(id); + if (resultconfig == null) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔鏁版嵁宸蹭笉瀛樺湪")); return; } + resultconfig.setName(config.getName()); + resultconfig.setValue(config.getValue()); + // key 涓嶅彲淇敼 - config.setKey(crentconfig.getKey()); - configService.update(config); + configService.update(resultconfig); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("淇敼鎴愬姛")); } catch (Exception e) { -- Gitblit v1.8.0