喻健
2018-11-21 399a1db3846dd02ed247343266962ade9c3b988e
后台系统参数调整
1个文件已修改
36 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/ConfigAdminController.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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) {