merge
This commit is contained in:
@@ -12,11 +12,11 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 说明: 系统配置控制层
|
||||
@@ -28,31 +28,31 @@ import java.util.Objects;
|
||||
@RestController
|
||||
@RequestMapping("/config/")
|
||||
public class SysConfigControl {
|
||||
private static Logger log = LoggerFactory.getLogger(SysConfigControl.class);
|
||||
@Autowired
|
||||
private final Logger logger = LoggerFactory.getLogger(SysConfigControl.class);
|
||||
@Resource
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
@ApiOperation(value = "新增", notes = "新增系统配置信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "key", value = "配置项的key,长度为1-50", paramType = "query", required = true, dataType = "string"),
|
||||
@ApiImplicitParam(name = "code", value = "配置项的key,长度为1-50", paramType = "query", required = true, dataType = "string"),
|
||||
@ApiImplicitParam(name = "value", value = "配置项的值", paramType = "query", required = true, dataType = "string"),
|
||||
@ApiImplicitParam(name = "isEnable", value = "是否启用,格式为Y|N", paramType = "query", required = true, dataType = "string"),
|
||||
@ApiImplicitParam(name = "enable", value = "是否启用,格式为Y|N", paramType = "query", required = true, dataType = "string"),
|
||||
@ApiImplicitParam(name = "name", value = "配置名称,长度为1-10", paramType = "query", required = true, dataType = "string")
|
||||
})
|
||||
@PostMapping("save")
|
||||
public JSONObject save(@Valid SysConfig sysConfig) {
|
||||
public JSONObject save(@RequestBody @Valid SysConfig sysConfig) {
|
||||
String logMsg = "新增系统配置信息";
|
||||
log.info(logMsg);
|
||||
logger.info(logMsg);
|
||||
RestMessage result = sysConfigService.save(sysConfig);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除", notes = "根据code删除系统配置信息")
|
||||
@ApiImplicitParam(name = "key", value = "配置项的code", paramType = "query", required = true, dataType = "string")
|
||||
@PostMapping("removeByCode/{code}")
|
||||
@ApiImplicitParam(name = "code", value = "配置项的code", paramType = "query", required = true, dataType = "string")
|
||||
@GetMapping("removeByCode/{code}")
|
||||
public JSONObject removeByCode(@PathVariable String code) {
|
||||
String logMsg = "删除系统配置信息";
|
||||
log.info(logMsg + " key:{}", code);
|
||||
logger.info(logMsg + " code:{}", code);
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
return JSONObjResult.toJSONObj("code不能为空");
|
||||
}
|
||||
@@ -60,19 +60,48 @@ public class SysConfigControl {
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改", notes = "修改系统配置信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "code", value = "配置项的key,长度为1-50", paramType = "query", required = true, dataType = "string"),
|
||||
@ApiImplicitParam(name = "value", value = "配置项的值", paramType = "query", required = true, dataType = "string"),
|
||||
@ApiImplicitParam(name = "enable", value = "是否启用,格式为Y|N", paramType = "query", required = true, dataType = "string"),
|
||||
})
|
||||
@PostMapping("update")
|
||||
public JSONObject update(@RequestBody SysConfig sysConfig) {
|
||||
String logMsg = "修改系统配置信息";
|
||||
logger.info(logMsg);
|
||||
if (StringUtils.isEmpty(sysConfig.getCode()))
|
||||
return JSONObjResult.toJSONObj("配置项的code不能为空");
|
||||
RestMessage result = sysConfigService.update(sysConfig);
|
||||
return JSONObjResult.toJSONObj(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查找", notes = "根据key查找系统配置信息")
|
||||
@ApiImplicitParam(name = "key", value = "配置项的code", paramType = "query", required = true, dataType = "string")
|
||||
@PostMapping("findByCode")
|
||||
@ApiImplicitParam(name = "code", value = "配置项的code", paramType = "query", required = true, dataType = "string")
|
||||
@GetMapping("findByCode")
|
||||
public JSONObject findByCode(@RequestParam String code) {
|
||||
String logMsg = "根据code查找系统配置信息";
|
||||
log.info(logMsg + " key:{}", code);
|
||||
logger.info(logMsg + " code:{}", code);
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
return JSONObjResult.toJSONObj("code不能为空");
|
||||
}
|
||||
SysConfig one = sysConfigService.findByKey(code);
|
||||
if (Objects.isNull(one)) {
|
||||
return JSONObjResult.toJSONObj("该对象不存在");
|
||||
SysConfig one = sysConfigService.findByCode(code);
|
||||
if (one == null) {
|
||||
return JSONObjResult.toJSONObj("该配置不存在");
|
||||
}
|
||||
return JSONObjResult.toJSONObj(one, true, "");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查找列表", notes = "根据是否启用查找配置列表")
|
||||
@ApiImplicitParam(name = "enable", value = "是否启用,格式为Y|N", paramType = "query", required = true, dataType = "string")
|
||||
@GetMapping("listByEnable")
|
||||
public JSONObject findByEnable(@RequestParam String enable) {
|
||||
String logMsg = "根据是否启用查找配置列表";
|
||||
logger.info(logMsg + " enable:{}", enable);
|
||||
if (StringUtils.isEmpty(enable)) {
|
||||
return JSONObjResult.toJSONObj("是否启用不能为空");
|
||||
}
|
||||
List<SysConfig> byEnable = sysConfigService.findByEnable(enable);
|
||||
return JSONObjResult.toJSONObj(byEnable, true, "");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user