feat: 基础设置
新增基础设置维护功能,包括基础设置获取和更新
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
package com.adc.da.eo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author ThinkBook
|
||||||
|
* @TableName ts_config
|
||||||
|
*/
|
||||||
|
@TableName(value ="ts_config")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ConfigEntity implements Serializable {
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.INPUT)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置名
|
||||||
|
*/
|
||||||
|
@TableField(value = "config_key")
|
||||||
|
private String configKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置信息
|
||||||
|
*/
|
||||||
|
@TableField(value = "config_value")
|
||||||
|
private String configValue;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.adc.da.sys.controller;
|
||||||
|
|
||||||
|
import com.adc.da.eo.ConfigEntity;
|
||||||
|
import com.adc.da.sys.service.iservice.IConfigService;
|
||||||
|
import com.adc.da.util.http.ResponseMessage;
|
||||||
|
import com.adc.da.util.http.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Caihaohan
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/${restPath}/sys/config")
|
||||||
|
@Api(tags = {"Sys-基础设置"})
|
||||||
|
public class ConfigController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IConfigService iConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一个基本设置项
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取一个基本设置项")
|
||||||
|
@GetMapping("/{key}")
|
||||||
|
public ResponseMessage findConfig(@NotNull @PathVariable String key) {
|
||||||
|
try {
|
||||||
|
return Result.success(iConfigService.query().eq("config_key", key).one());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取一个基本设置项失败", e);
|
||||||
|
return Result.error("获取失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有基本设置项
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取所有基本设置项")
|
||||||
|
@GetMapping("/all")
|
||||||
|
public ResponseMessage findAllConfig() {
|
||||||
|
try {
|
||||||
|
return Result.success(iConfigService.list());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取所有基本设置项", e);
|
||||||
|
return Result.error("获取失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存基本设置项
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "保存/更新 基本设置项")
|
||||||
|
@PostMapping("/save")
|
||||||
|
public ResponseMessage saveConfig(@RequestBody ConfigEntity configEntity) {
|
||||||
|
try {
|
||||||
|
iConfigService.saveOrUpdate(configEntity);
|
||||||
|
return Result.success("保存成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("保存基本设置项失败", e);
|
||||||
|
return Result.error("保存失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存所有基本设置项
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "批量 保存/更新 基本设置项")
|
||||||
|
@PostMapping("/saveAll")
|
||||||
|
public ResponseMessage saveAllConfig(@RequestBody List<ConfigEntity> configEntityList) {
|
||||||
|
try {
|
||||||
|
iConfigService.saveOrUpdateBatch(configEntityList);
|
||||||
|
return Result.success("保存成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("保存所有基本设置项失败", e);
|
||||||
|
return Result.error("保存失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.adc.da.sys.dao.mysql;
|
||||||
|
|
||||||
|
|
||||||
|
import com.adc.da.eo.ConfigEntity;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ThinkBook
|
||||||
|
* @description 针对表【ts_config】的数据库操作Mapper
|
||||||
|
* @createDate 2023-05-04 09:45:30
|
||||||
|
* @Entity generator.eo.ConfigEntity
|
||||||
|
*/
|
||||||
|
public interface ConfigDao extends BaseMapper<ConfigEntity> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.adc.da.sys.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.adc.da.eo.ConfigEntity;
|
||||||
|
import com.adc.da.sys.service.iservice.IConfigService;
|
||||||
|
import com.adc.da.sys.dao.mysql.ConfigDao;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ThinkBook
|
||||||
|
* @description 针对表【ts_config】的数据库操作Service实现
|
||||||
|
* @createDate 2023-05-04 09:45:30
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ConfigServiceImpl extends ServiceImpl<ConfigDao, ConfigEntity>
|
||||||
|
implements IConfigService {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.adc.da.sys.service.iservice;
|
||||||
|
|
||||||
|
import com.adc.da.eo.ConfigEntity;
|
||||||
|
import com.adc.da.util.http.ResponseMessage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ThinkBook
|
||||||
|
* @description 针对表【ts_config】的数据库操作Service
|
||||||
|
* @createDate 2023-05-04 09:45:30
|
||||||
|
*/
|
||||||
|
public interface IConfigService extends IService<ConfigEntity> {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user