使用mybatis-flex重构“参数设置”模块代码

This commit is contained in:
dataprince 2023-09-14 22:05:17 +08:00
parent 73f8e9f0e9
commit a2ec2b31e0
45 changed files with 424 additions and 521 deletions

11
pom.xml
View File

@ -18,7 +18,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<spring-boot.version>3.1.3</spring-boot.version>
<mybatis-flex.version>1.6.4</mybatis-flex.version>
<mybatis-flex.version>1.6.5</mybatis-flex.version>
<satoken.version>1.35.0.RC</satoken.version>
<mysql.version>8.0.33</mysql.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
@ -111,6 +111,14 @@
<scope>import</scope>
</dependency>
<!--测试框架-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
@ -358,6 +366,7 @@
<version>${powerjob.version}</version>
</dependency>
<!-- 定时任务-->
<!-- <dependency>-->
<!-- <groupId>com.ruoyi</groupId>-->

View File

@ -16,7 +16,7 @@ mybatis-flex:
autoMappingBehavior: FULL
# MyBatis 自动映射时未知列或未知属性处理策
# NONE不做处理 WARNING打印相关警告 FAILING抛出异常和详细信息
autoMappingUnknownColumnBehavior: NONE
autoMappingUnknownColumnBehavior: WARNING
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl

View File

@ -1,98 +0,0 @@
package com.ruoyi.common.core.core.page;
import cn.hutool.http.HttpStatus;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
/**
* 表格分页数据对象
*
* @author ruoyi
*/
public class TableDataInfo implements Serializable
{
@Serial
private static final long serialVersionUID = 1L;
/** 总记录数 */
private long total;
/** 列表数据 */
private List<?> rows;
/** 消息状态码 */
private int code;
/** 消息内容 */
private String msg;
/**
* 表格数据对象
*/
public TableDataInfo()
{
}
/**
* 分页
*
* @param list 列表数据
* @param total 总记录数
*/
public TableDataInfo(List<?> list, int total)
{
this.rows = list;
this.total = total;
}
public static TableDataInfo build(List<?> list) {
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.HTTP_OK);
rspData.setMsg("查询成功");
rspData.setRows(list);
rspData.setTotal(list.size());
return rspData;
}
public long getTotal()
{
return total;
}
public void setTotal(long total)
{
this.total = total;
}
public List<?> getRows()
{
return rows;
}
public void setRows(List<?> rows)
{
this.rows = rows;
}
public int getCode()
{
return code;
}
public void setCode(int code)
{
this.code = code;
}
public String getMsg()
{
return msg;
}
public void setMsg(String msg)
{
this.msg = msg;
}
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.common.orm.config;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.audit.AuditManager;
import com.mybatisflex.core.audit.ConsoleMessageCollector;
import com.mybatisflex.core.datasource.DataSourceDecipher;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.mybatisflex.core.mybatis.FlexConfiguration;
@ -31,20 +32,6 @@ public class MyBatisFlexConfig implements ConfigurationCustomizer, MyBatisFlexCu
private static final Logger logger = LoggerFactory.getLogger("mybatis-flex-sql");
// /**
// * SQL 打印
// */
// public MyBatisFlexConfig() {
// //开启审计功能
// AuditManager.setAuditEnable(true);
//
// //设置 SQL 审计收集器
// AuditManager.setMessageCollector(auditMessage ->
// logger.info("{},耗费{}ms", auditMessage.getFullSql()
// , auditMessage.getElapsedTime())
// );
// }
/**
* 数据源解密
*/
@ -77,6 +64,13 @@ public class MyBatisFlexConfig implements ConfigurationCustomizer, MyBatisFlexCu
globalConfig.registerInsertListener(new EntityInsertListener(), BaseEntity.class);
globalConfig.registerUpdateListener(new EntityUpdateListener(), BaseEntity.class);
// 开启审计功能
AuditManager.setAuditEnable(true);
// AuditManager.setMessageFactory(new AuditMessageFactory());
// 设置 SQL 审计收集器
AuditManager.setMessageCollector(new ConsoleMessageCollector());
}
//TODO:动态表名

View File

@ -34,6 +34,7 @@ public class BaseEntity implements Serializable {
/**
* 创建部门
*/
@Column(ignore = true)
private Long createDept;
/**
@ -58,11 +59,6 @@ public class BaseEntity implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 备注
*/
private String remark;
/**
* 请求参数
*/

View File

@ -1,15 +1,11 @@
package com.ruoyi.common.orm.core.page;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.sql.SqlUtil;
import cn.hutool.http.HttpStatus;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**

View File

@ -1,6 +1,7 @@
package com.ruoyi.common.orm.core.page;
import cn.hutool.http.HttpStatus;
import com.mybatisflex.core.paginate.Page;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -11,13 +12,11 @@ import java.util.List;
/**
* 表格分页数据对象
*
* @author Lion Li
* @author ruoyi
*/
@Data
@NoArgsConstructor
public class TableDataInfo<T> implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ -41,26 +40,18 @@ public class TableDataInfo<T> implements Serializable {
*/
private String msg;
/**
* 分页
*
* @param list 列表数据
* @param total 总记录数
*/
public TableDataInfo(List<T> list, long total) {
public TableDataInfo(List<T> list, int total) {
this.rows = list;
this.total = total;
}
// public static <T> TableDataInfo<T> build(IPage<T> page) {
// TableDataInfo<T> rspData = new TableDataInfo<>();
// rspData.setCode(HttpStatus.HTTP_OK);
// rspData.setMsg("查询成功");
// rspData.setRows(page.getRecords());
// rspData.setTotal(page.getTotal());
// return rspData;
// }
public static <T> TableDataInfo<T> build(List<T> list) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(HttpStatus.HTTP_OK);
@ -77,4 +68,12 @@ public class TableDataInfo<T> implements Serializable {
return rspData;
}
public static <T> TableDataInfo<T> build(Page<T> page) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(HttpStatus.HTTP_OK);
rspData.setMsg("查询成功");
rspData.setRows(page.getRecords());
rspData.setTotal(page.getTotalRow());
return rspData;
}
}

View File

@ -0,0 +1,12 @@
package com.ruoyi.common.orm.core.service;
import com.mybatisflex.core.service.IService;
import com.ruoyi.common.orm.core.domain.BaseEntity;
/**
* 自定义的服务基类接口
*
* @author dataprince数据小王子
*/
public interface IBaseService<T extends BaseEntity> extends IService<T> {
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.common.orm.core.service.impl;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.spring.service.impl.CacheableServiceImpl;
import com.ruoyi.common.orm.core.domain.BaseEntity;
import com.ruoyi.common.orm.core.service.IBaseService;
/**
* 自定义的缓存服务基类的实现类
*
* @author dataprince数据小王子
*/
public abstract class BaseCacheableServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> extends CacheableServiceImpl<M , T> implements IBaseService<T> {
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.common.orm.core.service.impl;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.ruoyi.common.orm.core.domain.BaseEntity;
import com.ruoyi.common.orm.core.service.IBaseService;
/**
* 自定义的服务基类接口实现
*
* @author dataprince数据小王子
*/
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> extends ServiceImpl<M , T> implements IBaseService<T> {
}

View File

@ -5,8 +5,8 @@ import java.util.Date;
import java.util.List;
import com.ruoyi.common.core.core.page.PageDomain;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.core.page.TableSupport;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder;

View File

@ -3,6 +3,7 @@ package com.ruoyi.demo.controller;
import java.util.List;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
@ -19,8 +20,6 @@ import com.ruoyi.demo.domain.DemoCustomer;
import com.ruoyi.demo.service.IDemoCustomerService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.core.page.TableDataInfo;
/**
* 客户主表(mb)Controller
*

View File

@ -3,6 +3,7 @@ package com.ruoyi.demo.controller;
import java.util.List;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
@ -19,8 +20,6 @@ import com.ruoyi.demo.domain.DemoStudent;
import com.ruoyi.demo.service.IDemoStudentService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.core.page.TableDataInfo;
/**
* 学生信息单表(mb)Controller
*

View File

@ -38,6 +38,11 @@ public class DemoCustomer extends BaseEntity
@Excel(name = "客户生日", width = 30, dateFormat = "yyyy-MM-dd")
private Date birthday;
/**
* 备注
*/
private String remark;
/** 商品子信息 */
private List<DemoGoods> demoGoodsList;
@ -97,6 +102,14 @@ public class DemoCustomer extends BaseEntity
this.demoGoodsList = demoGoodsList;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -46,6 +46,11 @@ public class DemoGoods extends BaseEntity
@Excel(name = "商品种类")
private String type;
/**
* 备注
*/
private String remark;
public void setGoodsId(Long goodsId)
{
this.goodsId = goodsId;
@ -110,6 +115,14 @@ public class DemoGoods extends BaseEntity
return type;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -26,6 +26,11 @@ public class DemoProduct extends TreeEntity
@Excel(name = "产品状态", readConverterExp = "0=正常,1=停用")
private String status;
/**
* 备注
*/
private String remark;
public void setProductId(Long productId)
{
this.productId = productId;
@ -54,6 +59,14 @@ public class DemoProduct extends TreeEntity
return status;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -45,6 +45,11 @@ public class DemoStudent extends BaseEntity
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
private Date studentBirthday;
/**
* 备注
*/
private String remark;
public void setStudentId(Long studentId)
{
this.studentId = studentId;
@ -109,6 +114,14 @@ public class DemoStudent extends BaseEntity
return studentBirthday;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
@ -20,7 +21,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.core.text.Convert;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;

View File

@ -1,6 +1,8 @@
package ${packageName}.controller;
import java.util.List;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
@ -20,7 +22,6 @@ import ${packageName}.service.I${ClassName}Service;
import com.ruoyi.common.core.core.utils.poi.ExcelUtil;
#if($table.crud || $table.sub)
import com.ruoyi.common.core.core.page.TableDataInfo;
#elseif($table.tree)
#end

View File

@ -80,6 +80,12 @@
<artifactId>ruoyi-common-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -6,6 +6,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.constant.GlobalConstants;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.redis.utils.RedisUtils;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,7 +19,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
//import com.ruoyi.framework.web.service.SysPasswordService;
import com.ruoyi.system.domain.SysLogininfor;

View File

@ -5,6 +5,7 @@ import java.util.List;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
@ -17,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.service.ISysOperLogService;

View File

@ -9,6 +9,7 @@ import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.core.utils.StreamUtils;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.redis.utils.RedisUtils;
import com.ruoyi.system.domain.SysUserOnline;
import lombok.RequiredArgsConstructor;
@ -20,7 +21,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.core.domain.dto.UserOnlineDTO;

View File

@ -3,8 +3,13 @@ package com.ruoyi.system.controller.system;
import java.util.List;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.core.domain.R;
import com.ruoyi.common.excel.utils.ExcelUtil;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.system.domain.bo.SysConfigBo;
import com.ruoyi.system.domain.vo.SysConfigVo;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
@ -18,10 +23,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService;
/**
@ -43,11 +44,9 @@ public class SysConfigController extends BaseController
*/
@SaCheckPermission("system:config:list")
@GetMapping("/list")
public TableDataInfo list(SysConfig config)
public TableDataInfo list(SysConfigBo config)
{
startPage();
List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list);
return configService.selectConfigPage(config);
}
/**
@ -56,11 +55,10 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
@SaCheckPermission("system:config:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysConfig config)
public void export(HttpServletResponse response, SysConfigBo config)
{
List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<>(SysConfig.class);
util.exportExcel(response, list, "参数数据");
List<SysConfigVo> list = configService.selectConfigList(config);
ExcelUtil.exportExcel(list, "参数数据", SysConfigVo.class, response);
}
/**
@ -68,9 +66,9 @@ public class SysConfigController extends BaseController
*/
@SaCheckPermission("system:config:query")
@GetMapping(value = "/{configId}")
public AjaxResult getInfo(@PathVariable Long configId)
public R<SysConfigVo> getInfo(@PathVariable Long configId)
{
return success(configService.selectConfigById(configId));
return R.ok(configService.selectConfigById(configId));
}
/**
@ -78,9 +76,9 @@ public class SysConfigController extends BaseController
*/
@SaCheckPermission("system:config:query")
@GetMapping(value = "/configKey/{configKey}")
public AjaxResult getConfigKey(@PathVariable String configKey)
public R<Void> getConfigKey(@PathVariable String configKey)
{
return success(configService.selectConfigByKey(configKey));
return R.ok(configService.selectConfigByKey(configKey));
}
/**
@ -89,13 +87,14 @@ public class SysConfigController extends BaseController
@SaCheckPermission("system:config:add")
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysConfig config)
public R<Void> add(@Validated @RequestBody SysConfigBo config)
{
if (!configService.checkConfigKeyUnique(config))
{
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
return toAjax(configService.insertConfig(config));
configService.insertConfig(config);
return R.ok();
}
/**
@ -104,13 +103,14 @@ public class SysConfigController extends BaseController
@SaCheckPermission("system:config:edit")
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysConfig config)
public R<Void> edit(@Validated @RequestBody SysConfigBo config)
{
if (!configService.checkConfigKeyUnique(config))
{
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
return toAjax(configService.updateConfig(config));
configService.updateConfig(config);
return R.ok();
}
/**
@ -119,10 +119,10 @@ public class SysConfigController extends BaseController
@SaCheckPermission("system:config:remove")
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{configIds}")
public AjaxResult remove(@PathVariable Long[] configIds)
public R<Void> remove(@PathVariable Long[] configIds)
{
configService.deleteConfigByIds(configIds);
return success();
return R.ok();
}
/**
@ -131,9 +131,9 @@ public class SysConfigController extends BaseController
@SaCheckPermission("system:config:remove")
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache()
public R<Void> refreshCache()
{
configService.resetConfigCache();
return success();
return R.ok();
}
}

View File

@ -5,9 +5,9 @@ import java.util.List;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.stp.StpUtil;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.security.utils.LoginHelper;
import com.ruoyi.system.domain.SysDictData;
import jakarta.annotation.Resource;
@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictDataService;

View File

@ -5,12 +5,12 @@ import java.util.List;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.security.utils.LoginHelper;
import com.ruoyi.system.domain.SysDictType;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictTypeService;

View File

@ -5,10 +5,10 @@ import java.util.List;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.security.utils.LoginHelper;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.service.ISysNoticeService;

View File

@ -6,11 +6,11 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.security.utils.LoginHelper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService;

View File

@ -5,6 +5,7 @@ import java.util.List;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.security.utils.LoginHelper;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.SysRole;
@ -12,7 +13,6 @@ import com.ruoyi.system.domain.SysUser;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@ -24,9 +24,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.domain.model.LoginUser;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysDeptService;

View File

@ -1,15 +1,13 @@
package com.ruoyi.system.controller.system;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.secure.BCrypt;
import com.ruoyi.common.core.core.domain.model.LoginUser;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.security.utils.LoginHelper;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.system.domain.SysDept;
@ -33,7 +31,6 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.web.core.BaseController;
import com.ruoyi.common.core.core.domain.AjaxResult;
import com.ruoyi.common.core.core.page.TableDataInfo;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.poi.ExcelUtil;

View File

@ -1,114 +1,45 @@
package com.ruoyi.system.domain;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.annotation.Excel.ColumnType;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.ruoyi.common.orm.core.domain.BaseEntity;
import java.io.Serial;
/**
* 参数配置表 sys_config
*
* @author ruoyi
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Table(value = "sys_config")
public class SysConfig extends BaseEntity
{
@Serial
private static final long serialVersionUID = 1L;
/** 参数主键 */
@Excel(name = "参数主键", cellType = ColumnType.NUMERIC)
// @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId) //TODO:ID主键修改为雪花算法
// @Id(keyType = KeyType.Generator, value = KeyGenerators.flexId)
//@Id
//@Excel(name = "参数主键", cellType = ColumnType.NUMERIC)
@Id(keyType = KeyType.Auto)
private Long configId;
/** 参数名称 */
@Excel(name = "参数名称")
private String configName;
/** 参数键名 */
@Excel(name = "参数键名")
private String configKey;
/** 参数键值 */
@Excel(name = "参数键值")
private String configValue;
/** 系统内置Y是 N否 */
@Excel(name = "系统内置", readConverterExp = "Y=是,N=否")
private String configType;
public Long getConfigId()
{
return configId;
}
public void setConfigId(Long configId)
{
this.configId = configId;
}
@NotBlank(message = "参数名称不能为空")
@Size(min = 0, max = 100, message = "参数名称不能超过100个字符")
public String getConfigName()
{
return configName;
}
public void setConfigName(String configName)
{
this.configName = configName;
}
@NotBlank(message = "参数键名长度不能为空")
@Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符")
public String getConfigKey()
{
return configKey;
}
public void setConfigKey(String configKey)
{
this.configKey = configKey;
}
@NotBlank(message = "参数键值不能为空")
@Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符")
public String getConfigValue()
{
return configValue;
}
public void setConfigValue(String configValue)
{
this.configValue = configValue;
}
public String getConfigType()
{
return configType;
}
public void setConfigType(String configType)
{
this.configType = configType;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("configId", getConfigId())
.append("configName", getConfigName())
.append("configKey", getConfigKey())
.append("configValue", getConfigValue())
.append("configType", getConfigType())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
/** 备注 */
private String remark;
}

View File

@ -51,6 +51,11 @@ public class SysDictData extends BaseEntity
@Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
private String isDefault;
/**
* 备注
*/
private String remark;
public Long getDictCode()
{
return dictCode;
@ -143,6 +148,14 @@ public class SysDictData extends BaseEntity
this.isDefault = isDefault;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -32,6 +32,11 @@ public class SysDictType extends BaseEntity
@Excel(name = "字典类型")
private String dictType;
/**
* 备注
*/
private String remark;
public Long getDictId()
{
return dictId;
@ -66,6 +71,14 @@ public class SysDictType extends BaseEntity
this.dictType = dictType;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -65,6 +65,11 @@ public class SysMenu extends BaseEntity
/** 菜单图标 */
private String icon;
/**
* 备注
*/
private String remark;
/** 子菜单 */
private List<SysMenu> children = new ArrayList<SysMenu>();
@ -235,6 +240,14 @@ public class SysMenu extends BaseEntity
this.children = children;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -34,6 +34,11 @@ public class SysNotice extends BaseEntity
/** 公告状态0正常 1关闭 */
private String status;
/**
* 备注
*/
private String remark;
public Long getNoticeId()
{
return noticeId;
@ -87,6 +92,14 @@ public class SysNotice extends BaseEntity
return status;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -41,6 +41,11 @@ public class SysPost extends BaseEntity
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String status;
/**
* 备注
*/
private String remark;
/** 用户是否存在此岗位标识 默认不存在 */
private boolean flag = false;
@ -109,6 +114,14 @@ public class SysPost extends BaseEntity
this.flag = flag;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -54,6 +54,11 @@ public class SysRole extends BaseEntity
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
/**
* 备注
*/
private String remark;
/** 用户是否存在此角色标识 默认不存在 */
private boolean flag = false;
@ -66,6 +71,14 @@ public class SysRole extends BaseEntity
/** 角色菜单权限 */
private Set<String> permissions;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public SysRole()
{

View File

@ -101,6 +101,11 @@ public class SysUser extends TenantEntity
/** 角色ID */
private Long roleId;
/**
* 备注
*/
private String remark;
public SysUser()
{
@ -329,6 +334,14 @@ public class SysUser extends TenantEntity
this.roleId = roleId;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -4,8 +4,6 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
import com.ruoyi.common.excel.convert.ExcelDictConvert;
import com.ruoyi.system.domain.SysConfig;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import java.io.Serial;
@ -20,7 +18,6 @@ import java.util.Date;
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = SysConfig.class)
public class SysConfigVo implements Serializable {
@Serial

View File

@ -1,76 +1,16 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.mybatisflex.core.BaseMapper;
import com.ruoyi.system.domain.SysConfig;
import org.apache.ibatis.annotations.Mapper;
/**
* 参数配置 数据层
* 参数配置Mapper
*
* @author ruoyi
* @author 数据小王子
*/
public interface SysConfigMapper
@Mapper
public interface SysConfigMapper extends BaseMapper<SysConfig>
{
/**
* 查询参数配置信息
*
* @param config 参数配置信息
* @return 参数配置信息
*/
public SysConfig selectConfig(SysConfig config);
/**
* 通过ID查询配置
*
* @param configId 参数ID
* @return 参数配置信息
*/
public SysConfig selectConfigById(Long configId);
/**
* 查询参数配置列表
*
* @param config 参数配置信息
* @return 参数配置集合
*/
public List<SysConfig> selectConfigList(SysConfig config);
/**
* 根据键名查询参数配置信息
*
* @param configKey 参数键名
* @return 参数配置信息
*/
public SysConfig checkConfigKeyUnique(String configKey);
/**
* 新增参数配置
*
* @param config 参数配置信息
* @return 结果
*/
public int insertConfig(SysConfig config);
/**
* 修改参数配置
*
* @param config 参数配置信息
* @return 结果
*/
public int updateConfig(SysConfig config);
/**
* 删除参数配置
*
* @param configId 参数ID
* @return 结果
*/
public int deleteConfigById(Long configId);
/**
* 批量删除参数信息
*
* @param configIds 需要删除的参数ID
* @return 结果
*/
public int deleteConfigByIds(Long[] configIds);
}

View File

@ -1,22 +1,28 @@
package com.ruoyi.system.service;
import java.util.List;
import com.mybatisflex.core.service.IService;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.domain.bo.SysConfigBo;
import com.ruoyi.system.domain.vo.SysConfigVo;
/**
* 参数配置 服务层
*
* @author ruoyi
*/
public interface ISysConfigService
//public interface ISysConfigService extends IBaseService<SysConfig>
public interface ISysConfigService extends IService<SysConfig>
{
/**
* 查询参数配置信息
*
* @param configId 参数配置ID
* @return 参数配置信息
* @return 参数配置信息Vo
*/
public SysConfig selectConfigById(Long configId);
SysConfigVo selectConfigById(Long configId);
/**
* 根据键名查询参数配置信息
@ -24,14 +30,14 @@ public interface ISysConfigService
* @param configKey 参数键名
* @return 参数键值
*/
public String selectConfigByKey(String configKey);
String selectConfigByKey(String configKey);
/**
* 获取验证码开关
*
* @return true开启false关闭
*/
public boolean selectCaptchaEnabled();
boolean selectCaptchaEnabled();
/**
* 查询参数配置列表
@ -39,7 +45,9 @@ public interface ISysConfigService
* @param config 参数配置信息
* @return 参数配置集合
*/
public List<SysConfig> selectConfigList(SysConfig config);
List<SysConfigVo> selectConfigList(SysConfigBo config);
TableDataInfo<SysConfigVo> selectConfigPage(SysConfigBo config);
/**
* 新增参数配置
@ -47,7 +55,7 @@ public interface ISysConfigService
* @param config 参数配置信息
* @return 结果
*/
public int insertConfig(SysConfig config);
int insertConfig(SysConfigBo config);
/**
* 修改参数配置
@ -55,19 +63,19 @@ public interface ISysConfigService
* @param config 参数配置信息
* @return 结果
*/
public int updateConfig(SysConfig config);
boolean updateConfig(SysConfigBo config);
/**
* 批量删除参数信息
*
* @param configIds 需要删除的参数ID
*/
public void deleteConfigByIds(Long[] configIds);
void deleteConfigByIds(Long[] configIds);
/**
* 重置参数缓存数据
*/
public void resetConfigCache();
void resetConfigCache();
/**
* 校验参数键名是否唯一
@ -75,5 +83,5 @@ public interface ISysConfigService
* @param config 参数信息
* @return 结果
*/
public boolean checkConfigKeyUnique(SysConfig config);
boolean checkConfigKeyUnique(SysConfigBo config);
}

View File

@ -1,19 +1,26 @@
package com.ruoyi.system.service.impl;
import java.util.Collection;
import java.util.List;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.ruoyi.common.core.constant.CacheNames;
import com.ruoyi.common.core.core.page.PageDomain;
import com.ruoyi.common.core.core.page.TableSupport;
import com.ruoyi.common.core.service.ConfigService;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.common.core.utils.sql.SqlUtil;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.redis.utils.CacheUtils;
import jakarta.annotation.PostConstruct;
import com.ruoyi.system.domain.bo.SysConfigBo;
import com.ruoyi.system.domain.vo.SysConfigVo;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.core.text.Convert;
import com.ruoyi.common.core.exception.ServiceException;
@ -22,6 +29,8 @@ import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.service.ISysConfigService;
import static com.ruoyi.system.domain.table.SysConfigTableDef.SYS_CONFIG;
/**
* 参数配置 服务层实现
*
@ -29,11 +38,15 @@ import com.ruoyi.system.service.ISysConfigService;
*/
@RequiredArgsConstructor
@Service
public class SysConfigServiceImpl implements ISysConfigService, ConfigService
{
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService, ConfigService {
@Resource
private SysConfigMapper configMapper;
@Override
public QueryWrapper query() {
return super.query().from(SYS_CONFIG);
}
/**
* 查询参数配置信息
*
@ -41,11 +54,8 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService
* @return 参数配置信息
*/
@Override
public SysConfig selectConfigById(Long configId)
{
SysConfig config = new SysConfig();
config.setConfigId(configId);
return configMapper.selectConfig(config);
public SysConfigVo selectConfigById(Long configId) {
return this.getOneAs(query().where(SYS_CONFIG.CONFIG_ID.eq(configId)),SysConfigVo.class);
}
/**
@ -56,13 +66,9 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService
*/
@Cacheable(cacheNames = CacheNames.SYS_CONFIG, key = "#configKey")
@Override
public String selectConfigByKey(String configKey)
{
SysConfig config = new SysConfig();
config.setConfigKey(configKey);
SysConfig retConfig = configMapper.selectConfig(config);
if (StringUtils.isNotNull(retConfig))
{
public String selectConfigByKey(String configKey) {
SysConfig retConfig = this.getOne(query().where(SYS_CONFIG.CONFIG_KEY.eq(configKey)));
if (StringUtils.isNotNull(retConfig)) {
return retConfig.getConfigValue();
}
return StringUtils.EMPTY;
@ -74,16 +80,49 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService
* @return true开启false关闭
*/
@Override
public boolean selectCaptchaEnabled()
{
public boolean selectCaptchaEnabled() {
String captchaEnabled = selectConfigByKey("sys.account.captchaEnabled");
if (StringUtils.isEmpty(captchaEnabled))
{
if (StringUtils.isEmpty(captchaEnabled)) {
return true;
}
return Convert.toBool(captchaEnabled);
}
/**
* 构造查询条件
* @param config
* @return
*/
private QueryWrapper buildQueryWrapper(SysConfigBo config) {
QueryWrapper queryWrapper = query();
PageDomain pageDomain = TableSupport.buildPageRequest();
if (StringUtils.isNotEmpty(config.getConfigName())) {
queryWrapper.and(SYS_CONFIG.CONFIG_NAME.like(config.getConfigName()));
}
if (StringUtils.isNotEmpty(config.getConfigType())) {
queryWrapper.and(SYS_CONFIG.CONFIG_TYPE.eq(config.getConfigType()));
}
if (StringUtils.isNotEmpty(config.getConfigKey())) {
queryWrapper.and(SYS_CONFIG.CONFIG_KEY.like(config.getConfigKey()));
}
if (StringUtils.isNotEmpty((String) config.getParams().get("beginTime"))) {
queryWrapper.and(SYS_CONFIG.CREATE_TIME.ge(config.getParams().get("beginTime")));
}
if (StringUtils.isNotEmpty((String) config.getParams().get("endTime"))) {
queryWrapper.and(SYS_CONFIG.CREATE_TIME.le(config.getParams().get("endTime")));
}
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
queryWrapper.orderBy(orderBy);
}
return queryWrapper;
}
/**
* 查询参数配置列表
*
@ -91,51 +130,62 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService
* @return 参数配置集合
*/
@Override
public List<SysConfig> selectConfigList(SysConfig config)
{
return configMapper.selectConfigList(config);
public List<SysConfigVo> selectConfigList(SysConfigBo config) {
QueryWrapper queryWrapper = buildQueryWrapper(config);
return this.listAs(queryWrapper,SysConfigVo.class);
}
/**
* 分页查询参数配置
*
* @param config 参数配置信息
* @return
*/
@Override
public TableDataInfo<SysConfigVo> selectConfigPage(SysConfigBo config) {
QueryWrapper queryWrapper = buildQueryWrapper(config);
PageDomain pageDomain = TableSupport.buildPageRequest();
Page<SysConfigVo> page = this.getMapper().paginateAs(pageDomain.getPageNum(), pageDomain.getPageSize(), queryWrapper,SysConfigVo.class);
return TableDataInfo.build(page);
}
/**
* 新增参数配置
*
* @param config 参数配置信息
* @param configBo 参数配置信息
* @return 结果
*/
@CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#config.configKey")
@CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#configBo.configKey")
@Override
public int insertConfig(SysConfig config)
{
int row = configMapper.insertConfig(config);
if (row > 0)
{
return row;
}
return 0;
public int insertConfig(SysConfigBo configBo) {
SysConfig sysConfig = MapstructUtils.convert(configBo, SysConfig.class);
//boolean ret = this.save(sysConfig);
//int ret = this.getMapper().insert(sysConfig,false);
//return this.getMapper().insertSelective(sysConfig);
//return configMapper.insertSelective(sysConfig);
int ret=configMapper.insert(sysConfig,false);
return ret;
}
/**
* 修改参数配置
*
* @param config 参数配置信息
* @param configBo 参数配置信息
* @return 结果
*/
@CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#config.configKey")
@CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#configBo.configKey")
@Override
public int updateConfig(SysConfig config)
{
SysConfig temp = configMapper.selectConfigById(config.getConfigId());
if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey()))
{
public boolean updateConfig(SysConfigBo configBo) {
SysConfig config = MapstructUtils.convert(configBo, SysConfig.class);
SysConfig temp = this.getById(config.getConfigId());
if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) {
CacheUtils.evict(CacheNames.SYS_CONFIG, temp.getConfigKey());
}
int row = configMapper.updateConfig(config);
if (row > 0)
{
return row;
}
return 0;
return this.updateById(config);
}
/**
@ -144,16 +194,13 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService
* @param configIds 需要删除的参数ID
*/
@Override
public void deleteConfigByIds(Long[] configIds)
{
for (Long configId : configIds)
{
SysConfig config = selectConfigById(configId);
if (StringUtils.equals(UserConstants.YES, config.getConfigType()))
{
public void deleteConfigByIds(Long[] configIds) {
for (Long configId : configIds) {
SysConfigVo config = selectConfigById(configId);
if (StringUtils.equals(UserConstants.YES, config.getConfigType())) {
throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
}
configMapper.deleteConfigById(configId);
this.removeById(configId);
CacheUtils.evict(CacheNames.SYS_CONFIG, config.getConfigKey());
}
}
@ -162,8 +209,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService
* 重置参数缓存数据
*/
@Override
public void resetConfigCache()
{
public void resetConfigCache() {
CacheUtils.clear(CacheNames.SYS_CONFIG);
}
@ -174,12 +220,10 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService
* @return 结果
*/
@Override
public boolean checkConfigKeyUnique(SysConfig config)
{
public boolean checkConfigKeyUnique(SysConfigBo config) {
Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId();
SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey());
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue())
{
SysConfig info = this.getOne(query().where(SYS_CONFIG.CONFIG_KEY.eq(config.getConfigKey())));
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;

View File

@ -16,102 +16,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectConfigVo">
select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark
from sys_config
<sql id="Base_Column_List">
`config_id`, `config_name`, `config_key`, `config_value`, `config_type`, `create_by`, `create_time`,
`update_by`, `update_time`, `remark`
</sql>
<!-- 查询条件 -->
<sql id="sqlwhereSearch">
<where>
<if test="configId !=null">
and config_id = #{configId}
</if>
<if test="configKey !=null and configKey != ''">
and config_key = #{configKey}
</if>
</where>
</sql>
<select id="selectConfig" parameterType="SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
<include refid="sqlwhereSearch"/>
</select>
<select id="selectConfigList" parameterType="SysConfig" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
<where>
<if test="configName != null and configName != ''">
AND config_name like concat('%', #{configName}, '%')
</if>
<if test="configType != null and configType != ''">
AND config_type = #{configType}
</if>
<if test="configKey != null and configKey != ''">
AND config_key like concat('%', #{configKey}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
</select>
<select id="selectConfigById" parameterType="Long" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
where config_id = #{configId}
</select>
<select id="checkConfigKeyUnique" parameterType="String" resultMap="SysConfigResult">
<include refid="selectConfigVo"/>
where config_key = #{configKey} limit 1
</select>
<insert id="insertConfig" parameterType="SysConfig">
insert into sys_config (
<if test="configName != null and configName != '' ">config_name,</if>
<if test="configKey != null and configKey != '' ">config_key,</if>
<if test="configValue != null and configValue != '' ">config_value,</if>
<if test="configType != null and configType != '' ">config_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)values(
<if test="configName != null and configName != ''">#{configName},</if>
<if test="configKey != null and configKey != ''">#{configKey},</if>
<if test="configValue != null and configValue != ''">#{configValue},</if>
<if test="configType != null and configType != ''">#{configType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
sysdate()
)
</insert>
<update id="updateConfig" parameterType="SysConfig">
update sys_config
<set>
<if test="configName != null and configName != ''">config_name = #{configName},</if>
<if test="configKey != null and configKey != ''">config_key = #{configKey},</if>
<if test="configValue != null and configValue != ''">config_value = #{configValue},</if>
<if test="configType != null and configType != ''">config_type = #{configType},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
update_time = sysdate()
</set>
where config_id = #{configId}
</update>
<delete id="deleteConfigById" parameterType="Long">
delete from sys_config where config_id = #{configId}
</delete>
<delete id="deleteConfigByIds" parameterType="Long">
delete from sys_config where config_id in
<foreach item="configId" collection="array" open="(" separator="," close=")">
#{configId}
</foreach>
</delete>
</mapper>

View File

@ -33,7 +33,7 @@
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd"
value-format="YYYY-MM-DD"
type="daterange"
range-separator="-"
start-placeholder="开始日期"

View File

@ -527,3 +527,5 @@ DROP TABLE IF EXISTS QRTZ_JOB_DETAILS;
DROP TABLE IF EXISTS QRTZ_CALENDARS;
--update to V4.1.8