feat:增加系统配置
This commit is contained in:
@@ -15,8 +15,8 @@ platform:
|
|||||||
|
|
||||||
tiesheng:
|
tiesheng:
|
||||||
token:
|
token:
|
||||||
list:
|
ignores:
|
||||||
"1111":
|
"1111":
|
||||||
id: "1111"
|
id: "1111"
|
||||||
global:
|
global:
|
||||||
version: 2
|
version: 2
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.tiesheng.core.controller.config;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreConfigSystem;
|
||||||
|
import com.tiesheng.core.pojos.dto.PageDTO;
|
||||||
|
import com.tiesheng.core.pojos.dto.config.ConfigSystemDTO;
|
||||||
|
import com.tiesheng.core.service.CoreConfigService;
|
||||||
|
import com.tiesheng.util.exception.ApiException;
|
||||||
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/config")
|
||||||
|
public class ConfigController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CoreConfigService coreConfigService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统配置列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/system/page")
|
||||||
|
@TokenIgnore
|
||||||
|
public ApiResp<List<CoreConfigSystem>> systemPage(PageDTO dto) {
|
||||||
|
|
||||||
|
QueryWrapper<CoreConfigSystem> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_deleted", 0);
|
||||||
|
dto.likeColumns(queryWrapper, "config_key", "remark");
|
||||||
|
|
||||||
|
Page<CoreConfigSystem> page = dto.pageObj();
|
||||||
|
coreConfigService.page(page, queryWrapper);
|
||||||
|
|
||||||
|
return ApiResp.respOK(page.getRecords(), page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑配置
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/system/update")
|
||||||
|
public ApiResp<String> systemUpdate(@RequestBody ConfigSystemDTO dto) {
|
||||||
|
|
||||||
|
CoreConfigSystem configKey = coreConfigService.getOneByColumn("config_key", dto.getConfigKey());
|
||||||
|
if (configKey == null) {
|
||||||
|
throw new ApiException("该配置不存在,请检查");
|
||||||
|
}
|
||||||
|
configKey.setConfigVal(dto.getConfigVal());
|
||||||
|
configKey.setRemark(dto.getRemark());
|
||||||
|
configKey.setExtra(dto.getExtra());
|
||||||
|
coreConfigService.updateById(configKey);
|
||||||
|
|
||||||
|
return ApiResp.respOK("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.tiesheng.core.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreConfigSystem;
|
||||||
|
|
||||||
|
public interface CoreConfigSystemMapper extends BaseMapper<CoreConfigSystem> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
package com.tiesheng.core.pojos.dao;
|
||||||
|
|
||||||
|
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 com.tiesheng.core.pojos.DaoBase;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置-系统
|
||||||
|
*/
|
||||||
|
@TableName(value = "core_config_system")
|
||||||
|
public class CoreConfigSystem extends DaoBase {
|
||||||
|
@TableField(value = "config_key")
|
||||||
|
private String configKey;
|
||||||
|
|
||||||
|
@TableField(value = "config_val")
|
||||||
|
private String configVal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型:0-文本,1-图片,2-文件
|
||||||
|
*/
|
||||||
|
@TableField(value = "config_type")
|
||||||
|
private Integer configType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 说明
|
||||||
|
*/
|
||||||
|
@TableField(value = "remark")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额外配置
|
||||||
|
*/
|
||||||
|
@TableField(value = "extra")
|
||||||
|
private String extra;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0-否,1-是
|
||||||
|
*/
|
||||||
|
@TableField(value = "read_only")
|
||||||
|
private Integer readOnly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return config_key
|
||||||
|
*/
|
||||||
|
public String getConfigKey() {
|
||||||
|
return configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param configKey
|
||||||
|
*/
|
||||||
|
public void setConfigKey(String configKey) {
|
||||||
|
this.configKey = configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return config_val
|
||||||
|
*/
|
||||||
|
public String getConfigVal() {
|
||||||
|
return configVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param configVal
|
||||||
|
*/
|
||||||
|
public void setConfigVal(String configVal) {
|
||||||
|
this.configVal = configVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取类型:0-文本,1-图片,2-文件
|
||||||
|
*
|
||||||
|
* @return config_type - 类型:0-文本,1-图片,2-文件
|
||||||
|
*/
|
||||||
|
public Integer getConfigType() {
|
||||||
|
return configType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置类型:0-文本,1-图片,2-文件
|
||||||
|
*
|
||||||
|
* @param configType 类型:0-文本,1-图片,2-文件
|
||||||
|
*/
|
||||||
|
public void setConfigType(Integer configType) {
|
||||||
|
this.configType = configType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取说明
|
||||||
|
*
|
||||||
|
* @return remark - 说明
|
||||||
|
*/
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置说明
|
||||||
|
*
|
||||||
|
* @param remark 说明
|
||||||
|
*/
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取额外配置
|
||||||
|
*
|
||||||
|
* @return extra - 额外配置
|
||||||
|
*/
|
||||||
|
public String getExtra() {
|
||||||
|
return extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置额外配置
|
||||||
|
*
|
||||||
|
* @param extra 额外配置
|
||||||
|
*/
|
||||||
|
public void setExtra(String extra) {
|
||||||
|
this.extra = extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取0-否,1-是
|
||||||
|
*
|
||||||
|
* @return read_only - 0-否,1-是
|
||||||
|
*/
|
||||||
|
public Integer getReadOnly() {
|
||||||
|
return readOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置0-否,1-是
|
||||||
|
*
|
||||||
|
* @param readOnly 0-否,1-是
|
||||||
|
*/
|
||||||
|
public void setReadOnly(Integer readOnly) {
|
||||||
|
this.readOnly = readOnly;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.tiesheng.core.pojos.dto.config;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
public class ConfigSystemDTO {
|
||||||
|
|
||||||
|
@NotEmpty(message = "请输入key")
|
||||||
|
private String configKey;
|
||||||
|
private String configVal;
|
||||||
|
private String remark;
|
||||||
|
private String extra;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getConfigKey() {
|
||||||
|
return configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigKey(String configKey) {
|
||||||
|
this.configKey = configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfigVal() {
|
||||||
|
return configVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigVal(String configVal) {
|
||||||
|
this.configVal = configVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExtra() {
|
||||||
|
return extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExtra(String extra) {
|
||||||
|
this.extra = extra;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.tiesheng.core.service;
|
||||||
|
|
||||||
|
import com.tiesheng.core.mapper.CoreConfigSystemMapper;
|
||||||
|
import com.tiesheng.core.pojos.dao.CoreConfigSystem;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CoreConfigService extends TsServiceBase<CoreConfigSystemMapper, CoreConfigSystem> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.tiesheng.core.service;
|
package com.tiesheng.core.service;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.tiesheng.core.config.token.TokenParse;
|
import com.tiesheng.core.config.token.TokenParse;
|
||||||
import com.tiesheng.core.config.web.TieshengWebConfigurer;
|
import com.tiesheng.core.config.web.TieshengWebConfigurer;
|
||||||
import com.tiesheng.core.config.web.bean.CurrentWebUser;
|
import com.tiesheng.core.config.web.bean.CurrentWebUser;
|
||||||
@@ -14,7 +13,7 @@ import org.springframework.stereotype.Service;
|
|||||||
* @author hao
|
* @author hao
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class CoreLogService extends ServiceImpl<CoreLogOperationMapper, CoreLogOperation> {
|
public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> {
|
||||||
|
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
TieshengWebConfigurer tieshengWebConfigurer;
|
TieshengWebConfigurer tieshengWebConfigurer;
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.tiesheng.core.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础Service
|
||||||
|
*
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
public class TsServiceBase<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过属性获取一个对象
|
||||||
|
*
|
||||||
|
* @param column
|
||||||
|
* @param val
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public T getOneByColumn(String column, Object val) {
|
||||||
|
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("is_deleted", 0);
|
||||||
|
queryWrapper.eq(column, val);
|
||||||
|
queryWrapper.last("limit 1");
|
||||||
|
return getOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,8 +26,8 @@ CREATE TABLE `core_config_system`
|
|||||||
`update_time` datetime NOT NULL,
|
`update_time` datetime NOT NULL,
|
||||||
`is_deleted` int(4) NOT NULL DEFAULT '0',
|
`is_deleted` int(4) NOT NULL DEFAULT '0',
|
||||||
`config_key` varchar(255) NOT NULL,
|
`config_key` varchar(255) NOT NULL,
|
||||||
`config_val` text NOT NULL,
|
`config_val` text,
|
||||||
`config_type` int(6) NOT NULL DEFAULT '0' COMMENT '类型:0-文本,1-图片,2-文件',
|
`config_type` int(6) NOT NULL DEFAULT '0' COMMENT '类型:0-文本,1-图片,2-开关',
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '说明',
|
`remark` varchar(500) DEFAULT NULL COMMENT '说明',
|
||||||
`extra` varchar(255) DEFAULT NULL COMMENT '额外配置',
|
`extra` varchar(255) DEFAULT NULL COMMENT '额外配置',
|
||||||
`read_only` int(6) NOT NULL DEFAULT '0' COMMENT '0-否,1-是',
|
`read_only` int(6) NOT NULL DEFAULT '0' COMMENT '0-否,1-是',
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.tiesheng.core.mapper.CoreConfigSystemMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.tiesheng.core.pojos.dao.CoreConfigSystem">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
<!--@Table core_config_system-->
|
||||||
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
|
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
|
||||||
|
<result column="config_key" jdbcType="VARCHAR" property="configKey" />
|
||||||
|
<result column="config_val" jdbcType="LONGVARCHAR" property="configVal" />
|
||||||
|
<result column="config_type" jdbcType="INTEGER" property="configType" />
|
||||||
|
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||||
|
<result column="extra" jdbcType="VARCHAR" property="extra" />
|
||||||
|
<result column="read_only" jdbcType="INTEGER" property="readOnly" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
id, create_time, update_time, is_deleted, config_key, config_val, config_type, remark,
|
||||||
|
extra, read_only
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user