|
@@ -0,0 +1,77 @@
|
|
|
+package com.ym.mec.web.controller;
|
|
|
+
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.ym.mec.biz.dal.entity.SysConfig;
|
|
|
+import com.ym.mec.biz.service.SysConfigService;
|
|
|
+import com.ym.mec.common.controller.BaseController;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 系统配置控制层
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@Api(tags = "系统参数设置")
|
|
|
+@RequestMapping(value = "sysConfig")
|
|
|
+public class SysConfigController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "参数列表")
|
|
|
+ @GetMapping(value = "list")
|
|
|
+ public Object configList() {
|
|
|
+ List<SysConfig> configs = sysConfigService.findAll(null);
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ if (configs != null && configs.size() > 0) {
|
|
|
+ for (SysConfig config : configs) {
|
|
|
+ map.put(config.getParamName(), config.getParanValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return succeed(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改参数")
|
|
|
+ @PostMapping(value = "update")
|
|
|
+ public Object update(SysConfig config) {
|
|
|
+ config.setModifyOn(new Date());
|
|
|
+ sysConfigService.update(config);
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "新增参数")
|
|
|
+ @PostMapping(value = "add")
|
|
|
+ public Object addConfig(SysConfig config) {
|
|
|
+ if (config == null)
|
|
|
+ return failed("参数无效");
|
|
|
+ if (StringUtils.isBlank(config.getParamName())) {
|
|
|
+ return failed("参数名称不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(config.getParanValue())) {
|
|
|
+ return failed("参数值不能为空");
|
|
|
+ }
|
|
|
+ config.setCreateOn(new Date());
|
|
|
+ config.setModifyOn(new Date());
|
|
|
+ return sysConfigService.insert(config) > 0 ? succeed() : failed("添加失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询参数")
|
|
|
+ @GetMapping(value = "get")
|
|
|
+ public Object getConfig(Long id) {
|
|
|
+ if (id == null || id <= 0)
|
|
|
+ return failed("请检查输入的ID");
|
|
|
+ return succeed(sysConfigService.get(id));
|
|
|
+ }
|
|
|
+}
|