|
@@ -0,0 +1,74 @@
|
|
|
+package cn.com.qmth.stmms.api.controller.admin;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import cn.com.qmth.stmms.api.controller.BaseApiController;
|
|
|
+import cn.com.qmth.stmms.biz.config.model.SystemConfig;
|
|
|
+import cn.com.qmth.stmms.biz.config.service.SystemConfigService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.bean.ResultMessage;
|
|
|
+import cn.com.qmth.stmms.biz.exam.bean.SystemConfigVo;
|
|
|
+import cn.com.qmth.stmms.biz.exception.StatusException;
|
|
|
+import cn.com.qmth.stmms.common.annotation.Logging;
|
|
|
+import cn.com.qmth.stmms.common.enums.ConfigType;
|
|
|
+import cn.com.qmth.stmms.common.enums.LogType;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+@Api(tags = "配置管理")
|
|
|
+@Controller("adminSystemConfigController")
|
|
|
+@RequestMapping("/api/admin/sys/config")
|
|
|
+public class SystemConfigController extends BaseApiController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SystemConfigService configService;
|
|
|
+
|
|
|
+ @Logging(menu = "查询", type = LogType.QUERY)
|
|
|
+ @ApiOperation(value = "配置列表")
|
|
|
+ @RequestMapping(value = "list", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public List<SystemConfigVo> list() {
|
|
|
+ List<SystemConfig> list = configService.findAll();
|
|
|
+ List<SystemConfigVo> ret = new ArrayList<>();
|
|
|
+ for (SystemConfig s : list) {
|
|
|
+ ret.add(SystemConfigVo.of(s));
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "根据id获取配置信息")
|
|
|
+ @RequestMapping(value = "info/id", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public SystemConfig infoId(@RequestParam Integer id) {
|
|
|
+ SystemConfig config = configService.findById(id);
|
|
|
+ if (config != null) {
|
|
|
+ return config;
|
|
|
+ } else {
|
|
|
+ throw new StatusException("未找到配置信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "根据类型获取配置")
|
|
|
+ @RequestMapping(value = "info/type", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public String infoType(@RequestParam ConfigType type) {
|
|
|
+ return configService.findByType(type);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Logging(menu = "修改配置", type = LogType.UPDATE)
|
|
|
+ @ApiOperation(value = "修改配置")
|
|
|
+ @RequestMapping(value = "update", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ResultMessage save(SystemConfig config) {
|
|
|
+ configService.update(config.getId(), config.getDescription());
|
|
|
+ return resultOk();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|