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); } } }