xiatian 19 годин тому
батько
коміт
742231b0e8

+ 94 - 0
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/bean/SystemConfigVo.java

@@ -0,0 +1,94 @@
+package cn.com.qmth.stmms.biz.exam.bean;
+
+import java.util.Date;
+
+import cn.com.qmth.stmms.biz.config.model.SystemConfig;
+import cn.com.qmth.stmms.common.enums.ConfigType;
+import io.swagger.annotations.ApiModelProperty;
+
+public class SystemConfigVo {
+
+    private Integer id;
+
+    private ConfigType type;
+
+    @ApiModelProperty(value = "类型")
+    private String name;
+
+    private String description;
+
+    @ApiModelProperty(value = "详情")
+    private String descriptionText;
+
+    private Date updateTime;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public ConfigType getType() {
+        return type;
+    }
+
+    public void setType(ConfigType type) {
+        this.type = type;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescriptionText() {
+        return descriptionText;
+    }
+
+    public void setDescriptionText(String descriptionText) {
+        this.descriptionText = descriptionText;
+    }
+
+    public static SystemConfigVo of(SystemConfig from) {
+        if (from == null) {
+            return null;
+        }
+        SystemConfigVo ret = new SystemConfigVo();
+        ret.setId(from.getId());
+        ret.setType(from.getType());
+        ret.setDescription(from.getDescription());
+        ret.setUpdateTime(from.getUpdateTime());
+        ret.setName(from.getType().getName());
+        if (ConfigType.AUTO_REPORT.equals(from.getType()) || ConfigType.STUDENT_SHEET_COUNT.equals(from.getType())) {
+            if ("on".equals(from.getDescription())) {
+                ret.setDescriptionText("开启");
+            } else {
+                ret.setDescriptionText("关闭");
+            }
+        } else {
+            ret.setDescriptionText(from.getDescription());
+        }
+        return ret;
+    }
+}

+ 2 - 1
stmms-common/src/main/java/cn/com/qmth/stmms/common/enums/ConfigType.java

@@ -2,7 +2,8 @@ package cn.com.qmth.stmms.common.enums;
 
 public enum ConfigType {
 
-    FILE_SERVER("图片服务", 1), MARK_TIME("评卷时长", 2), AUTO_REPORT("自动统计", 3), STUDENT_SHEET_COUNT("计算扫描题卡张数", 4);
+    FILE_SERVER("图片服务", 1), MARK_TIME("评卷时长", 2), AUTO_REPORT("自动统计", 3), STUDENT_SHEET_COUNT("计算扫描题卡张数",
+            4), QUALITY_ANALYSIS("自命题质量分析系统", 5);
 
     private String name;
 

+ 74 - 0
stmms-web/src/main/java/cn/com/qmth/stmms/api/controller/admin/SystemConfigController.java

@@ -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();
+    }
+
+}