多单位版国产化地质资料管理系统
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.zbooksoft.gdmis.controller;
 
 
import com.ruili.wcp.common.CustomConfigUtil;
import com.ruili.wcp.web.model.AjaxResponse;
import com.ruili.wcp.web.model.ErrorInfo;
import com.zbooksoft.gdmis.config.ArchivesCustomConfig;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
@Controller
@RequestMapping("/archivesCustomConfig")
public class ArchivesCustomConfigController {
    @Autowired
    public CustomConfigUtil customConfigUtil;
    private static final Logger logger = LoggerFactory.getLogger(ArchivesCustomConfigController.class);
 
    /**
     * 自定义配置页面
     *
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/archivesCustomConfigIndex")
    @RequiresUser
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ArchivesCustomConfig archivesCustomConfig = customConfigUtil.getConfigObj(ArchivesCustomConfig.class);
        ModelAndView mav = new ModelAndView("gh/config/customConfigIndex");
        mav.addObject("archivesCustomConfig", archivesCustomConfig);
        return mav;
    }
 
    /**
     * 保存配置
     *
     * @return
     */
    @RequestMapping(value = "/saveCustomConfig", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    @RequiresUser
    public Object saveCustomConfig(@RequestBody ArchivesCustomConfig archivesCustomConfig) {
        try {
            customConfigUtil.setConfigObj(archivesCustomConfig);
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
}