Compare commits

...

10 Commits

Author SHA1 Message Date
dataprince
3d3d17066c 修改版本号:V4.2.0 2023-12-21 08:16:05 +08:00
dataprince
703e3c2b07 powerjob配置参数新增默认PostgreSQL数据源 2023-12-21 08:14:43 +08:00
dataprince
5e8fec31df 更新文档,添加支持PostgreSQL数据库 2023-12-21 08:13:51 +08:00
dataprince
9f28779390 支持PostgreSQL数据库 2023-12-20 19:44:47 +08:00
dataprince
f546a47c61 增加多数据源演示(学生信息表的服务selectPage方法),默认关闭 2023-12-20 14:29:26 +08:00
dataprince
ea1411246e 为方便入门,数据库登录用户、密码不再加密! 2023-12-19 16:32:21 +08:00
dataprince
95e54ad11a 修改delFlag属性为Integer类型 2023-12-19 16:10:22 +08:00
dataprince
7bde7c05bc 修改mysql数据库表的del_flag字段为smallint类型 2023-12-19 16:06:49 +08:00
dataprince
3b804032dc 升级依赖Redisson到V3.25.1,改进 JDK21 虚拟线程兼容性 2023-12-19 09:49:49 +08:00
dataprince
5a72eb7f49 代码生成模块重构 2023-12-18 11:36:48 +08:00
55 changed files with 4101 additions and 2980 deletions

View File

@ -1,13 +1,13 @@
<p align="center">
<img alt="logo" src="https://gitee.com/dataprince/ruoyi-flex/raw/master/image/ruoyi-flex-logo.png">
</p>
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">Ruoyi-Flex V4.1.8</h1>
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">Ruoyi-Flex V4.2.0</h1>
<h4 align="center">Ruoyi-Flex是基于JDK21、Spring Boot V3.2.X+平台 前后端分离的Java快速开发框架</h4>
## 1、平台简介
Ruoyi-Flex是一套全部开源的快速开发平台使用MIT开源许可协议毫无保留给个人及企业免费使用。基于RuoYi-Vue、RuoYi-Vue-Plus集成MyBatis-Flex、JDK21、SpringBootV3.2.X+、Lombok、Sa-Token、SpringDoc、Hutool、SpringBoot Admin、PowerJob、Vue3、Element-Plus、MinIO等优秀开源软件
Ruoyi-Flex是一套全部开源的快速开发平台使用MIT开源许可协议毫无保留给个人及企业免费使用。基于RuoYi-Vue、RuoYi-Vue-Plus集成MyBatis-Flex、JDK21、SpringBootV3.2.X+、Lombok、Sa-Token、SpringDoc、Hutool、SpringBoot Admin、PowerJob、Vue3、Element-Plus、MinIO等优秀开源软件
## 2、系统特色
Ruoyi-Flex秉承“写的更少、性能更好、出错更低、交流通畅、快速入门” 的理念,为您带来全方位的赋能与提升:
@ -53,7 +53,8 @@ Ruoyi-Flex实行前后端分离仓库本项目是java后端部分前端项
15. 系统接口集成springdoc根据文档注释自动生成相关的api接口文档。
16. 监控中心集成Spring Boot Admin监视集群系统CPU、内存、磁盘、堆栈、在线日志、Spring相关配置等。
17. 缓存监控:对系统的缓存信息查询,命令统计等。
18. 演示模块mybatis、mybatis-flex两种格式代码的单表、树表、主子表三种类型的演示程序。
18. 后台数据库支持MySQL、PostgreSQL数据库。
19. 演示模块mybatis、mybatis-flex两种格式代码的单表、树表、主子表三种类型的演示程序。
## 5、演示图

Binary file not shown.

12
pom.xml
View File

@ -13,7 +13,7 @@
<description>Ruoyi-Flex管理系统</description>
<properties>
<revision>4.2.0-SNAPSHOT</revision>
<revision>4.2.0</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>21</java.version>
@ -21,7 +21,6 @@
<mybatis-flex.version>1.7.5</mybatis-flex.version>
<mybatis-spring.version>3.0.3</mybatis-spring.version>
<satoken.version>1.37.0</satoken.version>
<mysql.version>8.0.33</mysql.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<HikariCP.version>5.0.1</HikariCP.version>
<bitwalker.version>1.21</bitwalker.version>
@ -45,7 +44,7 @@
<mapstruct-plus.version>1.3.5</mapstruct-plus.version>
<mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
<hutool.version>5.8.22</hutool.version>
<redisson.version>3.23.5</redisson.version>
<redisson.version>3.25.1</redisson.version>
<lock4j.version>2.2.4</lock4j.version>
<alibaba-ttl.version>2.14.3</alibaba-ttl.version>
<spring-boot-admin.version>3.1.6</spring-boot-admin.version>
@ -179,13 +178,6 @@
<version>${satoken.version}</version>
</dependency>
<!-- Mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- servlet包 -->
<dependency>
<groupId>jakarta.servlet</groupId>

View File

@ -27,8 +27,8 @@
<!-- Mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- PostgreSql -->

View File

@ -34,17 +34,23 @@ mybatis-flex:
datasource:
# 数据源-1
PrimaryDS:
ds1:
# 指定为HikariDataSource
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
username: root123
password: Root@369---0000
# mysql数据库
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
# username: root
# password: Root@369
#postgresql数据库
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
username: postgres
password: postgres@369
hikari:
#连接池名
pool-name: HikariCP-PrimaryDS
pool-name: HikariCP-ds1
#最小空闲连接数
minimum-idle: 5
# 空闲连接存活最大时间默认10分钟
@ -63,6 +69,42 @@ mybatis-flex:
keepaliveTime: 30000
# 连接测试query
connection-test-query: SELECT 1
# 数据源-2
# ds2:
# # 指定为HikariDataSource
# type: com.zaxxer.hikari.HikariDataSource
# # mysql数据库
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
# username: root
# password: Root@369
# #postgresql数据库
## driver-class-name: org.postgresql.Driver
## url: jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
## username: postgres
## password: postgres@369
#
# hikari:
# #连接池名
# pool-name: HikariCP-ds1
# #最小空闲连接数
# minimum-idle: 5
# # 空闲连接存活最大时间默认10分钟
# idle-timeout: 600000
# # 连接池最大连接数默认是10
# maximum-pool-size: 10
# # 此属性控制从池返回的连接的默认自动提交行为,默认值true
# auto-commit: true
# # 此属性控制池中连接的最长生命周期值0表示无限生命周期默认30分钟
# max-lifetime: 1800000
# # 数据库连接超时时间,默认30秒
# connection-timeout: 30000
# # 校验超时时间
# validationTimeout: 5000
# # 多久检查一次连接的活性
# keepaliveTime: 30000
# # 连接测试query
# connection-test-query: SELECT 1
# redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
spring.data:

View File

@ -43,10 +43,16 @@ mybatis-flex:
PrimaryDS:
# 指定为HikariDataSource
type: com.zaxxer.hikari.HikariDataSource
# mysql数据库
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
username: root123
password: Root@369---0000
username: root
password: Root@369
#postgresql数据库
# driver-class-name: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: postgres
# password: postgres@369
hikari:
#连接池名

View File

@ -14,7 +14,7 @@
</description>
<properties>
<revision>4.2.0-SNAPSHOT</revision>
<revision>4.2.0</revision>
</properties>
<dependencyManagement>

View File

@ -32,29 +32,35 @@ public class GenConstants
public static final String PARENT_MENU_NAME = "parentMenuName";
/** 数据库字符串类型 */
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2","character","character varying" };
/** 数据库文本类型 */
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext", "binary", "varbinary", "blob",
"ntext", "image", "bytea" };
/** 数据库时间类型 */
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp","timestamp without time zone","year", "interval",
"smalldatetime", "datetime2", "datetimeoffset" };
/** 数据库数字类型 */
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
"bit", "bigint", "float", "double", "decimal" };
"bit", "bigint", "float", "double", "decimal", "numeric", "real", "double precision",
"smallserial", "serial", "bigserial", "money", "smallmoney" };
/** 页面不需要编辑字段 */
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "update_by",
"update_time","del_flag" };
/**
* BO对象 不需要添加字段
*/
public static final String[] COLUMNNAME_NOT_ADD = {"create_by", "create_time", "update_by", "update_time" };
/** 页面不需要显示的列表字段 */
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
"update_time" };
/** BO对象 不需要编辑字段 */
public static final String[] COLUMNNAME_NOT_EDIT = { "create_by", "create_time", "update_by", "update_time" };
/** 页面不需要查询字段 */
public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
"update_time", "remark" };
/** VO对象 不需要显示的列表字段 */
public static final String[] COLUMNNAME_NOT_LIST = { "create_by", "create_time", "update_by", "update_time" };
/** BO对象 不需要查询字段 */
public static final String[] COLUMNNAME_NOT_QUERY = { "create_by", "create_time", "update_by",
"update_time", "del_flag", "remark", "version" };
/** Entity基类字段 */
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime"};

View File

@ -12,13 +12,14 @@ public class Decipher implements DataSourceDecipher {
@Override
public String decrypt(DataSourceProperty property, String value) {
//解密数据源URL用户名密码通过编码支持任意加密方式的解密
//为了减轻入门用户负担默认返回原字符用户可以定制加解密算法
String result = "";
switch (property) {
case URL -> result = value;
case USERNAME -> result = value.substring(0, 4);
case PASSWORD -> result = value.substring(0, 8);
case USERNAME -> result = value;
case PASSWORD -> result = value;
}
return result;
}

View File

@ -0,0 +1,23 @@
package com.ruoyi.common.orm.helper;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.dialect.DbType;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
* 数据库助手判断数据库类型
*
* @author dataprince数据小王子
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DataBaseHelper {
public static boolean isMySql() {
return DbType.MYSQL == FlexGlobalConfig.getDefaultConfig().getDbType();
}
public static boolean isPostgreSql() {
return DbType.POSTGRE_SQL == FlexGlobalConfig.getDefaultConfig().getDbType();
}
}

View File

@ -1,10 +1,15 @@
oms.env=dev
####### Database properties(Configure according to the the environment) #######
spring.datasource.core.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.core.jdbc-url=jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.core.username=root
spring.datasource.core.password=Root@369
spring.datasource.core.driver-class-name=org.postgresql.Driver
spring.datasource.core.jdbc-url=jdbc:postgresql://localhost:5432/ruoyi-flex?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.core.username=postgres
spring.datasource.core.password=postgres@369
## MySQL数据库连接参数
#spring.datasource.core.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.core.jdbc-url=jdbc:mysql://localhost:3306/ruoyi-flex?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
#spring.datasource.core.username=root
#spring.datasource.core.password=Root@369
spring.datasource.core.maximum-pool-size=20
spring.datasource.core.minimum-idle=5

View File

@ -1,9 +1,9 @@
package com.ruoyi.mf.controller;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

View File

@ -1,9 +1,9 @@
package com.ruoyi.mf.controller;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

View File

@ -2,8 +2,7 @@ package com.ruoyi.mf.service.impl;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.annotation.UseDataSource;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.utils.MapstructUtils;
@ -11,7 +10,6 @@ import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.orm.core.page.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.common.core.utils.DateUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -85,6 +83,7 @@ public class MfStudentServiceImpl extends BaseServiceImpl<MfStudentMapper, MfStu
* @return 分页学生信息表集合
*/
@Override
//@UseDataSource("ds2")
public TableDataInfo<MfStudentVo> selectPage(MfStudentBo mfStudentBo)
{
QueryWrapper queryWrapper = buildQueryWrapper(mfStudentBo);

View File

@ -102,9 +102,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<insert id="batchDemoGoods">
insert into demo_goods( goods_id, customer_id, name, weight, price, date, type) values
insert into demo_goods( customer_id, name, weight, price, date, type) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.goodsId}, #{item.customerId}, #{item.name}, #{item.weight}, #{item.price}, #{item.date}, #{item.type})
( #{item.customerId}, #{item.name}, #{item.weight}, #{item.price}, #{item.date}, #{item.type})
</foreach>
</insert>
</mapper>

View File

@ -31,7 +31,9 @@ import com.ruoyi.generator.service.IGenTableService;
* 代码生成 操作处理
*
* @author ruoyi
* @author 数据小王子
*/
@Validated
@RestController
@RequestMapping("/tool/gen")
public class GenController extends BaseController
@ -47,11 +49,9 @@ public class GenController extends BaseController
*/
@SaCheckPermission("tool:gen:list")
@GetMapping("/list")
public TableDataInfo genList(GenTable genTable)
public TableDataInfo<GenTable> genList(GenTable genTable)
{
startPage();
List<GenTable> list = genTableService.selectGenTableList(genTable);
return getDataTable(list);
return genTableService.selectPage(genTable);
}
/**
@ -198,7 +198,7 @@ public class GenController extends BaseController
response.reset();
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi-flex.zip\"");
response.addHeader("Content-Length", "" + data.length);
response.setContentType("application/octet-stream; charset=UTF-8");
IOUtils.write(data, response.getOutputStream());

View File

@ -2,8 +2,14 @@ package com.ruoyi.generator.domain;
import java.io.Serial;
import java.util.List;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.ArrayUtils;
import com.ruoyi.common.core.constant.GenConstants;
import com.ruoyi.common.orm.core.domain.BaseEntity;
@ -13,13 +19,18 @@ import com.ruoyi.common.core.utils.StringUtils;
* 业务表 gen_table
*
* @author ruoyi
* @author 数据小王子
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Table(value = "gen_table")
public class GenTable extends BaseEntity
{
@Serial
private static final long serialVersionUID = 1L;
/** 编号 */
@Id
private Long tableId;
/** 表名称 */
@ -70,6 +81,7 @@ public class GenTable extends BaseEntity
private String genPath;
/** 主键信息 */
@Column(ignore = true)
private GenTableColumn pkColumn;
/** 子表信息 */
@ -83,12 +95,15 @@ public class GenTable extends BaseEntity
private String options;
/** 树编码字段 */
@Column(ignore = true)
private String treeCode;
/** 树父编码字段 */
@Column(ignore = true)
private String treeParentCode;
/** 树名称字段 */
@Column(ignore = true)
private String treeName;
/*
@ -97,252 +112,16 @@ public class GenTable extends BaseEntity
private List<Long> menuIds;
/** 上级菜单ID字段 */
@Column(ignore = true)
private String parentMenuId;
/** 上级菜单名称字段 */
@Column(ignore = true)
private String parentMenuName;
/** 备注 */
private String remark;
public Long getTableId()
{
return tableId;
}
public void setTableId(Long tableId)
{
this.tableId = tableId;
}
public String getTableName()
{
return tableName;
}
public void setTableName(String tableName)
{
this.tableName = tableName;
}
public String getTableComment()
{
return tableComment;
}
public void setTableComment(String tableComment)
{
this.tableComment = tableComment;
}
public String getSubTableName()
{
return subTableName;
}
public void setSubTableName(String subTableName)
{
this.subTableName = subTableName;
}
public String getSubTableFkName()
{
return subTableFkName;
}
public void setSubTableFkName(String subTableFkName)
{
this.subTableFkName = subTableFkName;
}
public String getClassName()
{
return className;
}
public void setClassName(String className)
{
this.className = className;
}
public String getTplCategory()
{
return tplCategory;
}
public void setTplCategory(String tplCategory)
{
this.tplCategory = tplCategory;
}
public String getPackageName()
{
return packageName;
}
public void setPackageName(String packageName)
{
this.packageName = packageName;
}
public String getModuleName()
{
return moduleName;
}
public void setModuleName(String moduleName)
{
this.moduleName = moduleName;
}
public String getBusinessName()
{
return businessName;
}
public void setBusinessName(String businessName)
{
this.businessName = businessName;
}
public String getFunctionName()
{
return functionName;
}
public void setFunctionName(String functionName)
{
this.functionName = functionName;
}
public String getFunctionAuthor()
{
return functionAuthor;
}
public void setFunctionAuthor(String functionAuthor)
{
this.functionAuthor = functionAuthor;
}
public String getGenType()
{
return genType;
}
public void setGenType(String genType)
{
this.genType = genType;
}
public String getGenPath()
{
return genPath;
}
public void setGenPath(String genPath)
{
this.genPath = genPath;
}
public GenTableColumn getPkColumn()
{
return pkColumn;
}
public void setPkColumn(GenTableColumn pkColumn)
{
this.pkColumn = pkColumn;
}
public GenTable getSubTable()
{
return subTable;
}
public void setSubTable(GenTable subTable)
{
this.subTable = subTable;
}
public List<GenTableColumn> getColumns()
{
return columns;
}
public void setColumns(List<GenTableColumn> columns)
{
this.columns = columns;
}
public String getOptions()
{
return options;
}
public void setOptions(String options)
{
this.options = options;
}
public String getTreeCode()
{
return treeCode;
}
public void setTreeCode(String treeCode)
{
this.treeCode = treeCode;
}
public String getTreeParentCode()
{
return treeParentCode;
}
public void setTreeParentCode(String treeParentCode)
{
this.treeParentCode = treeParentCode;
}
public String getTreeName()
{
return treeName;
}
public void setTreeName(String treeName)
{
this.treeName = treeName;
}
public List<Long> getMenuIds() {
return menuIds;
}
public void setMenuIds(List<Long> menuIds) {
this.menuIds = menuIds;
}
public String getParentMenuId()
{
return parentMenuId;
}
public void setParentMenuId(String parentMenuId)
{
this.parentMenuId = parentMenuId;
}
public String getParentMenuName()
{
return parentMenuName;
}
public void setParentMenuName(String parentMenuName)
{
this.parentMenuName = parentMenuName;
}
public boolean isSub()
{
return isSub(this.tplCategory);
@ -388,11 +167,4 @@ public class GenTable extends BaseEntity
return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

View File

@ -1,8 +1,12 @@
package com.ruoyi.generator.domain;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import jakarta.validation.constraints.NotBlank;
import com.ruoyi.common.orm.core.domain.BaseEntity;
import com.ruoyi.common.core.utils.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
@ -10,13 +14,18 @@ import java.io.Serial;
* 代码生成业务字段表 gen_table_column
*
* @author ruoyi
* @author 数据小王子
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Table(value = "gen_table_column")
public class GenTableColumn extends BaseEntity
{
@Serial
private static final long serialVersionUID = 1L;
/** 编号 */
@Id
private Long columnId;
/** 归属表编号 */
@ -71,91 +80,11 @@ public class GenTableColumn extends BaseEntity
/** 排序 */
private Integer sort;
public void setColumnId(Long columnId)
{
this.columnId = columnId;
}
public Long getColumnId()
{
return columnId;
}
public void setTableId(Long tableId)
{
this.tableId = tableId;
}
public Long getTableId()
{
return tableId;
}
public void setColumnName(String columnName)
{
this.columnName = columnName;
}
public String getColumnName()
{
return columnName;
}
public void setColumnComment(String columnComment)
{
this.columnComment = columnComment;
}
public String getColumnComment()
{
return columnComment;
}
public void setColumnType(String columnType)
{
this.columnType = columnType;
}
public String getColumnType()
{
return columnType;
}
public void setJavaType(String javaType)
{
this.javaType = javaType;
}
public String getJavaType()
{
return javaType;
}
public void setJavaField(String javaField)
{
this.javaField = javaField;
}
public String getJavaField()
{
return javaField;
}
public String getCapJavaField()
{
return StringUtils.capitalize(javaField);
}
public void setIsPk(String isPk)
{
this.isPk = isPk;
}
public String getIsPk()
{
return isPk;
}
public boolean isPk()
{
return isPk(this.isPk);
@ -166,16 +95,6 @@ public class GenTableColumn extends BaseEntity
return isPk != null && StringUtils.equals("1", isPk);
}
public String getIsIncrement()
{
return isIncrement;
}
public void setIsIncrement(String isIncrement)
{
this.isIncrement = isIncrement;
}
public boolean isIncrement()
{
return isIncrement(this.isIncrement);
@ -186,16 +105,6 @@ public class GenTableColumn extends BaseEntity
return isIncrement != null && StringUtils.equals("1", isIncrement);
}
public void setIsRequired(String isRequired)
{
this.isRequired = isRequired;
}
public String getIsRequired()
{
return isRequired;
}
public boolean isRequired()
{
return isRequired(this.isRequired);
@ -206,16 +115,6 @@ public class GenTableColumn extends BaseEntity
return isRequired != null && StringUtils.equals("1", isRequired);
}
public void setIsInsert(String isInsert)
{
this.isInsert = isInsert;
}
public String getIsInsert()
{
return isInsert;
}
public boolean isInsert()
{
return isInsert(this.isInsert);
@ -226,16 +125,6 @@ public class GenTableColumn extends BaseEntity
return isInsert != null && StringUtils.equals("1", isInsert);
}
public void setIsEdit(String isEdit)
{
this.isEdit = isEdit;
}
public String getIsEdit()
{
return isEdit;
}
public boolean isEdit()
{
return isInsert(this.isEdit);
@ -245,17 +134,6 @@ public class GenTableColumn extends BaseEntity
{
return isEdit != null && StringUtils.equals("1", isEdit);
}
public void setIsList(String isList)
{
this.isList = isList;
}
public String getIsList()
{
return isList;
}
public boolean isList()
{
return isList(this.isList);
@ -266,16 +144,6 @@ public class GenTableColumn extends BaseEntity
return isList != null && StringUtils.equals("1", isList);
}
public void setIsQuery(String isQuery)
{
this.isQuery = isQuery;
}
public String getIsQuery()
{
return isQuery;
}
public boolean isQuery()
{
return isQuery(this.isQuery);
@ -286,46 +154,6 @@ public class GenTableColumn extends BaseEntity
return isQuery != null && StringUtils.equals("1", isQuery);
}
public void setQueryType(String queryType)
{
this.queryType = queryType;
}
public String getQueryType()
{
return queryType;
}
public String getHtmlType()
{
return htmlType;
}
public void setHtmlType(String htmlType)
{
this.htmlType = htmlType;
}
public void setDictType(String dictType)
{
this.dictType = dictType;
}
public String getDictType()
{
return dictType;
}
public void setSort(Integer sort)
{
this.sort = sort;
}
public Integer getSort()
{
return sort;
}
public boolean isSuperColumn()
{
return isSuperColumn(this.javaField);

View File

@ -1,14 +1,19 @@
package com.ruoyi.generator.mapper;
import java.util.List;
import com.mybatisflex.core.BaseMapper;
import com.ruoyi.generator.domain.GenTableColumn;
import org.apache.ibatis.annotations.Mapper;
/**
* 业务字段 数据层
*
* @author ruoyi
* @author 数据小王子
*/
public interface GenTableColumnMapper
@Mapper
public interface GenTableColumnMapper extends BaseMapper<GenTableColumn>
{
/**
* 根据表名称查询列信息
@ -16,31 +21,7 @@ public interface GenTableColumnMapper
* @param tableName 表名称
* @return 列信息
*/
public List<GenTableColumn> selectDbTableColumnsByName(String tableName);
/**
* 查询业务字段列表
*
* @param tableId 业务字段编号
* @return 业务字段集合
*/
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
/**
* 新增业务字段
*
* @param genTableColumn 业务字段信息
* @return 结果
*/
public int insertGenTableColumn(GenTableColumn genTableColumn);
/**
* 修改业务字段
*
* @param genTableColumn 业务字段信息
* @return 结果
*/
public int updateGenTableColumn(GenTableColumn genTableColumn);
List<GenTableColumn> selectDbTableColumnsByName(String tableName);
/**
* 删除业务字段
@ -48,7 +29,7 @@ public interface GenTableColumnMapper
* @param genTableColumns 列数据
* @return 结果
*/
public int deleteGenTableColumns(List<GenTableColumn> genTableColumns);
int deleteGenTableColumns(List<GenTableColumn> genTableColumns);
/**
* 批量删除业务字段
@ -56,5 +37,5 @@ public interface GenTableColumnMapper
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteGenTableColumnByIds(Long[] ids);
int deleteGenTableColumnByIds(Long[] ids);
}

View File

@ -1,30 +1,27 @@
package com.ruoyi.generator.mapper;
import java.util.List;
import com.mybatisflex.core.BaseMapper;
import com.ruoyi.generator.domain.GenTable;
import org.apache.ibatis.annotations.Mapper;
/**
* 业务 数据层
*
* @author ruoyi
* @author 数据小王子
*/
public interface GenTableMapper
@Mapper
public interface GenTableMapper extends BaseMapper<GenTable>
{
/**
* 查询业务列表
*
* @param genTable 业务信息
* @return 业务集合
*/
public List<GenTable> selectGenTableList(GenTable genTable);
/**
* 查询据库列表
*
* @param genTable 业务信息
* @return 数据库表集合
*/
public List<GenTable> selectDbTableList(GenTable genTable);
List<GenTable> selectDbTableList(GenTable genTable);
/**
* 查询据库列表
@ -32,22 +29,9 @@ public interface GenTableMapper
* @param tableNames 表名称组
* @return 数据库表集合
*/
public List<GenTable> selectDbTableListByNames(String[] tableNames);
List<GenTable> selectDbTableListByNames(String[] tableNames);
/**
* 查询所有表信息
*
* @return 表信息集合
*/
public List<GenTable> selectGenTableAll();
/**
* 查询表ID业务信息
*
* @param id 业务ID
* @return 业务信息
*/
public GenTable selectGenTableById(Long id);
/**
* 查询表名称业务信息
@ -55,29 +39,6 @@ public interface GenTableMapper
* @param tableName 表名称
* @return 业务信息
*/
public GenTable selectGenTableByName(String tableName);
GenTable selectGenTableByName(String tableName);
/**
* 新增业务
*
* @param genTable 业务信息
* @return 结果
*/
public int insertGenTable(GenTable genTable);
/**
* 修改业务
*
* @param genTable 业务信息
* @return 结果
*/
public int updateGenTable(GenTable genTable);
/**
* 批量删除业务
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteGenTableByIds(Long[] ids);
}

View File

@ -2,23 +2,33 @@ package com.ruoyi.generator.service;
import java.util.List;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.core.text.Convert;
import com.ruoyi.generator.domain.GenTableColumn;
import com.ruoyi.generator.mapper.GenTableColumnMapper;
import static com.ruoyi.generator.domain.table.GenTableColumnTableDef.GEN_TABLE_COLUMN;
/**
* 业务字段 服务层实现
*
* @author ruoyi
* @author 数据小王子
*/
@Service
public class GenTableColumnServiceImpl implements IGenTableColumnService
public class GenTableColumnServiceImpl extends BaseServiceImpl<GenTableColumnMapper, GenTableColumn> implements IGenTableColumnService
{
@Resource
private GenTableColumnMapper genTableColumnMapper;
@Override
public QueryWrapper query() {
return super.query().from(GEN_TABLE_COLUMN);
}
/**
* 查询业务字段列表
*
@ -28,7 +38,11 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
@Override
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId)
{
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
QueryWrapper queryWrapper = QueryWrapper.create()
.from(GEN_TABLE_COLUMN)
.where(GEN_TABLE_COLUMN.TABLE_ID.eq(tableId))
.orderBy(GEN_TABLE_COLUMN.SORT.asc());
return this.list(queryWrapper);
}
/**
@ -40,7 +54,8 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
@Override
public int insertGenTableColumn(GenTableColumn genTableColumn)
{
return genTableColumnMapper.insertGenTableColumn(genTableColumn);
//return genTableColumnMapper.insertGenTableColumn(genTableColumn);
return genTableColumnMapper.insertSelective(genTableColumn);
}
/**
@ -52,7 +67,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
@Override
public int updateGenTableColumn(GenTableColumn genTableColumn)
{
return genTableColumnMapper.updateGenTableColumn(genTableColumn);
return genTableColumnMapper.update(genTableColumn);
}
/**

View File

@ -1,24 +1,28 @@
package com.ruoyi.generator.service;
import java.io.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.dialect.DbType;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryMethods;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.orm.core.page.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson2.JSON;
@ -36,23 +40,44 @@ import com.ruoyi.generator.util.GenUtils;
import com.ruoyi.generator.util.VelocityInitializer;
import com.ruoyi.generator.util.VelocityUtils;
import static com.ruoyi.generator.domain.table.GenTableColumnTableDef.GEN_TABLE_COLUMN;
import static com.ruoyi.generator.domain.table.GenTableTableDef.GEN_TABLE;
/**
* 业务 服务层实现
*
* @author ruoyi
*/
@Slf4j
@Service
public class GenTableServiceImpl implements IGenTableService
public class GenTableServiceImpl extends BaseServiceImpl<GenTableMapper, GenTable> implements IGenTableService
{
@Serial
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
@Resource
private GenTableMapper genTableMapper;
@Resource
private GenTableColumnMapper genTableColumnMapper;
@Override
public QueryWrapper query() {
return super.query().from(GEN_TABLE);
}
private QueryWrapper buildQueryWrapper(GenTable genTable) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
if (StringUtils.isNotBlank(genTable.getTableName())) {
queryWrapper.and(QueryMethods.lower(GEN_TABLE.TABLE_NAME).like(genTable.getTableName().toLowerCase()));
}
if (StringUtils.isNotBlank(genTable.getTableComment())) {
queryWrapper.and(QueryMethods.lower(GEN_TABLE.TABLE_COMMENT).like(genTable.getTableComment().toLowerCase()));
}
Map<String, Object> params = genTable.getParams();
if (params.get("beginTime") != null && params.get("endTime") != null) {
queryWrapper.and(GEN_TABLE.CREATE_TIME.between(params.get("beginTime"), params.get("endTime")));
}
return queryWrapper;
}
/**
* 查询业务信息
*
@ -62,21 +87,34 @@ public class GenTableServiceImpl implements IGenTableService
@Override
public GenTable selectGenTableById(Long id)
{
GenTable genTable = genTableMapper.selectGenTableById(id);
/*SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_id = #{tableId} order by c.sort*/
QueryWrapper queryWrapper = QueryWrapper.create()
.from(GEN_TABLE)
.leftJoin(GEN_TABLE_COLUMN).on(GEN_TABLE_COLUMN.TABLE_ID.eq(GEN_TABLE.TABLE_ID))
.where(GEN_TABLE.TABLE_ID.eq(id))
.orderBy(GEN_TABLE_COLUMN.SORT.asc());
GenTable genTable = this.getOne(queryWrapper);
setTableFromOptions(genTable);
return genTable;
}
/**
* 查询业务列表
* 分页查询业务列表
*
* @param genTable 业务信息
* @return 业务集合
* @return 分页集合
*/
@Override
public List<GenTable> selectGenTableList(GenTable genTable)
public TableDataInfo<GenTable> selectPage(GenTable genTable)
{
return genTableMapper.selectGenTableList(genTable);
QueryWrapper queryWrapper = buildQueryWrapper(genTable);
Page<GenTable> page = this.pageAs(PageQuery.build(), queryWrapper, GenTable.class);
return TableDataInfo.build(page);
}
/**
@ -111,7 +149,11 @@ public class GenTableServiceImpl implements IGenTableService
@Override
public List<GenTable> selectGenTableAll()
{
return genTableMapper.selectGenTableAll();
QueryWrapper queryWrapper = QueryWrapper.create()
.from(GEN_TABLE)
.leftJoin(GEN_TABLE_COLUMN).on(GEN_TABLE_COLUMN.TABLE_ID.eq(GEN_TABLE.TABLE_ID))
.orderBy(GEN_TABLE_COLUMN.SORT.asc());
return this.list(queryWrapper);
}
/**
@ -126,12 +168,12 @@ public class GenTableServiceImpl implements IGenTableService
{
String options = JSON.toJSONString(genTable.getParams());
genTable.setOptions(options);
int row = genTableMapper.updateGenTable(genTable);
if (row > 0)
boolean updated = this.updateById(genTable);
if (updated)
{
for (GenTableColumn cenTableColumn : genTable.getColumns())
for (GenTableColumn genTableColumn : genTable.getColumns())
{
genTableColumnMapper.updateGenTableColumn(cenTableColumn);
genTableColumnMapper.update(genTableColumn);
}
}
}
@ -146,7 +188,7 @@ public class GenTableServiceImpl implements IGenTableService
@Transactional
public void deleteGenTableByIds(Long[] tableIds)
{
genTableMapper.deleteGenTableByIds(tableIds);
genTableMapper.deleteBatchByIds(Arrays.asList(tableIds));
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
}
@ -165,15 +207,15 @@ public class GenTableServiceImpl implements IGenTableService
{
String tableName = table.getTableName();
GenUtils.initTable(table);
int row = genTableMapper.insertGenTable(table);
if (row > 0)
boolean saved = this.save(table);
if (saved)
{
// 保存列信息
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
for (GenTableColumn column : genTableColumns)
{
GenUtils.initColumnField(column, table);
genTableColumnMapper.insertGenTableColumn(column);
genTableColumnMapper.insertSelective(column);
}
}
}
@ -195,7 +237,7 @@ public class GenTableServiceImpl implements IGenTableService
{
Map<String, String> dataMap = new LinkedHashMap<>();
// 查询表信息
GenTable table = genTableMapper.selectGenTableById(tableId);
GenTable table = selectGenTableById(tableId);
//设置生成的sys_menu6条记录的主键值
setMenuIds(table);
// 设置主子表信息
@ -319,11 +361,11 @@ public class GenTableServiceImpl implements IGenTableService
column.setIsRequired(prevColumn.getIsRequired());
column.setHtmlType(prevColumn.getHtmlType());
}
genTableColumnMapper.updateGenTableColumn(column);
genTableColumnMapper.update(column);
}
else
{
genTableColumnMapper.insertGenTableColumn(column);
genTableColumnMapper.insertSelective(column);
}
});
@ -362,6 +404,8 @@ public class GenTableServiceImpl implements IGenTableService
GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息
setSubTable(table);
//设置生成的sys_menu6条记录的主键值
setMenuIds(table);
// 设置主键列信息
setPkColumn(table);

View File

@ -7,6 +7,7 @@ import com.ruoyi.generator.domain.GenTableColumn;
* 业务字段 服务层
*
* @author ruoyi
* @author 数据小王子
*/
public interface IGenTableColumnService
{
@ -16,7 +17,7 @@ public interface IGenTableColumnService
* @param tableId 业务字段编号
* @return 业务字段集合
*/
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
/**
* 新增业务字段
@ -24,7 +25,7 @@ public interface IGenTableColumnService
* @param genTableColumn 业务字段信息
* @return 结果
*/
public int insertGenTableColumn(GenTableColumn genTableColumn);
int insertGenTableColumn(GenTableColumn genTableColumn);
/**
* 修改业务字段
@ -32,7 +33,7 @@ public interface IGenTableColumnService
* @param genTableColumn 业务字段信息
* @return 结果
*/
public int updateGenTableColumn(GenTableColumn genTableColumn);
int updateGenTableColumn(GenTableColumn genTableColumn);
/**
* 删除业务字段信息
@ -40,5 +41,5 @@ public interface IGenTableColumnService
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteGenTableColumnByIds(String ids);
int deleteGenTableColumnByIds(String ids);
}

View File

@ -2,23 +2,19 @@ package com.ruoyi.generator.service;
import java.util.List;
import java.util.Map;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.IBaseService;
import com.ruoyi.generator.domain.GenTable;
/**
* 业务 服务层
*
* @author ruoyi
* @author 数据小王子
*/
public interface IGenTableService
public interface IGenTableService extends IBaseService<GenTable>
{
/**
* 查询业务列表
*
* @param genTable 业务信息
* @return 业务集合
*/
public List<GenTable> selectGenTableList(GenTable genTable);
/**
* 查询据库列表
*
@ -27,6 +23,14 @@ public interface IGenTableService
*/
public List<GenTable> selectDbTableList(GenTable genTable);
/**
* 分页查询业务列表
*
* @param genTable 业务信息
* @return 分页集合
*/
TableDataInfo<GenTable> selectPage(GenTable genTable);
/**
* 查询据库列表
*

View File

@ -14,6 +14,7 @@ import com.ruoyi.generator.domain.GenTableColumn;
* 代码生成器 工具类
*
* @author ruoyi
* @author 数据小王子
*/
public class GenUtils
{
@ -80,25 +81,26 @@ public class GenUtils
}
}
// 插入字段
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk())
{
// BO对象 默认插入勾选
if (!arraysContains(GenConstants.COLUMNNAME_NOT_ADD, columnName) && !column.isPk()) {
column.setIsInsert(GenConstants.REQUIRE);
}
// 编辑字段
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName))
{
// BO对象 默认编辑勾选
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) {
column.setIsEdit(GenConstants.REQUIRE);
}
// 列表字段
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk())
{
// BO对象 默认是否必填勾选
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName)) {
column.setIsRequired(GenConstants.REQUIRE);
}
// VO对象 默认返回勾选
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName)) {
column.setIsList(GenConstants.REQUIRE);
}
// 查询字段
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk())
{
// BO对象 默认查询勾选
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) {
column.setIsQuery(GenConstants.REQUIRE);
}
@ -168,9 +170,11 @@ public class GenUtils
*/
public static String getBusinessName(String tableName)
{
int lastIndex = tableName.lastIndexOf("_");
int firstIndex = tableName.indexOf("_");
int nameLength = tableName.length();
return StringUtils.substring(tableName, lastIndex + 1, nameLength);
String businessName = StringUtils.substring(tableName, firstIndex + 1, nameLength);
businessName = StringUtils.toCamelCase(businessName);
return businessName;
}
/**

View File

@ -4,6 +4,11 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import cn.hutool.core.collection.CollUtil;
import com.mybatisflex.core.datasource.FlexDataSource;
import com.mybatisflex.core.dialect.DbTypeUtil;
import com.ruoyi.common.orm.helper.DataBaseHelper;
import org.apache.velocity.VelocityContext;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
@ -17,6 +22,7 @@ import com.ruoyi.generator.domain.GenTableColumn;
* 模板处理工具类
*
* @author ruoyi
* @author 数据小王子
*/
public class VelocityUtils
{
@ -140,7 +146,11 @@ public class VelocityUtils
templates.add("vm/java/serviceImpl.java.vm");
templates.add("vm/java/controller.java.vm");
templates.add("vm/xml/mapper.xml.vm");
templates.add("vm/sql/sql.vm");
if (DataBaseHelper.isPostgreSql()) {
templates.add("vm/sql/postgresql/sql.vm");
} else {
templates.add("vm/sql/mysql/sql.vm");
}
templates.add("vm/js/api.js.vm");
if (GenConstants.TPL_CRUD.equals(tplCategory))
{
@ -193,7 +203,8 @@ public class VelocityUtils
case "vm/java/controller.java.vm" -> fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
case "vm/xml/mapper.xml.vm" -> fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
case "vm/xml/sub-mapper.xml.vm" -> fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, genTable.getSubTable().getClassName());
case "vm/sql/sql.vm" -> fileName = businessName + "Menu.sql";
case "vm/sql/postgresql/sql.vm" -> fileName = businessName + "Menu(postgresql).sql";
case "vm/sql/mysql/sql.vm" -> fileName = businessName + "Menu(mysql).sql";
case "vm/js/api.js.vm" -> fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
case "vm/vue/index.vue.vm" -> fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
case "vm/vue/index-tree.vue.vm" -> fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
@ -334,7 +345,7 @@ public class VelocityUtils
*/
public static String getTreeParentCode(JSONObject paramsObj)
{
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
if (CollUtil.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
}
@ -349,7 +360,7 @@ public class VelocityUtils
*/
public static String getTreeName(JSONObject paramsObj)
{
if (paramsObj.containsKey(GenConstants.TREE_NAME))
if (CollUtil.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.TREE_NAME))
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
}

View File

@ -33,83 +33,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
</sql>
<select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult">
<include refid="selectGenTableColumnVo"/>
where table_id = #{tableId}
order by sort
</select>
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else '0' end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
<if test="@com.ruoyi.common.orm.helper.DataBaseHelper@isMySql()">
select column_name,
(case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else '0' end) as is_required,
(case when column_key = 'PRI' then '1' else '0' end) as is_pk,
ordinal_position as sort,
column_comment,
(case when extra = 'auto_increment' then '1' else '0' end) as is_increment,
column_type
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
order by ordinal_position
</if>
<if test="@com.ruoyi.common.orm.helper.DataBaseHelper@isPostgreSql()">
SELECT column_name, is_required, is_pk, sort, column_comment, is_increment, column_type
FROM (
SELECT c.relname AS table_name,
a.attname AS column_name,
d.description AS column_comment,
CASE WHEN a.attnotnull AND con.conname IS NULL THEN 1 ELSE 0
END AS is_required,
CASE WHEN con.conname IS NOT NULL THEN 1 ELSE 0
END AS is_pk,
a.attnum AS sort,
CASE WHEN "position"(pg_get_expr(ad.adbin, ad.adrelid),
((c.relname::text || '_'::text) || a.attname::text) || '_seq'::text) > 0 THEN 1 ELSE 0
END AS is_increment,
btrim(
CASE WHEN t.typelem <![CDATA[ <> ]]> 0::oid AND t.typlen = '-1'::integer THEN 'ARRAY'::text ELSE
CASE WHEN t.typtype = 'd'::"char" THEN format_type(t.typbasetype, NULL::integer)
ELSE format_type(a.atttypid, NULL::integer) END
END, '"'::text
) AS column_type
FROM pg_attribute a
JOIN (pg_class c JOIN pg_namespace n ON c.relnamespace = n.oid) ON a.attrelid = c.oid
LEFT JOIN pg_description d ON d.objoid = c.oid AND a.attnum = d.objsubid
LEFT JOIN pg_constraint con ON con.conrelid = c.oid AND (a.attnum = ANY (con.conkey))
LEFT JOIN pg_attrdef ad ON a.attrelid = ad.adrelid AND a.attnum = ad.adnum
LEFT JOIN pg_type t ON a.atttypid = t.oid
WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
AND a.attnum > 0
AND n.nspname = 'public'::name
ORDER BY c.relname, a.attnum
) temp
WHERE table_name = (#{tableName})
AND column_type <![CDATA[ <> ]]> '-'
</if>
</select>
<insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
insert into gen_table_column (
<if test="tableId != null and tableId != ''">table_id,</if>
<if test="columnName != null and columnName != ''">column_name,</if>
<if test="columnComment != null and columnComment != ''">column_comment,</if>
<if test="columnType != null and columnType != ''">column_type,</if>
<if test="javaType != null and javaType != ''">java_type,</if>
<if test="javaField != null and javaField != ''">java_field,</if>
<if test="isPk != null and isPk != ''">is_pk,</if>
<if test="isIncrement != null and isIncrement != ''">is_increment,</if>
<if test="isRequired != null and isRequired != ''">is_required,</if>
<if test="isInsert != null and isInsert != ''">is_insert,</if>
<if test="isEdit != null and isEdit != ''">is_edit,</if>
<if test="isList != null and isList != ''">is_list,</if>
<if test="isQuery != null and isQuery != ''">is_query,</if>
<if test="queryType != null and queryType != ''">query_type,</if>
<if test="htmlType != null and htmlType != ''">html_type,</if>
<if test="dictType != null and dictType != ''">dict_type,</if>
<if test="sort != null">sort,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="tableId != null and tableId != ''">#{tableId},</if>
<if test="columnName != null and columnName != ''">#{columnName},</if>
<if test="columnComment != null and columnComment != ''">#{columnComment},</if>
<if test="columnType != null and columnType != ''">#{columnType},</if>
<if test="javaType != null and javaType != ''">#{javaType},</if>
<if test="javaField != null and javaField != ''">#{javaField},</if>
<if test="isPk != null and isPk != ''">#{isPk},</if>
<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
<if test="isRequired != null and isRequired != ''">#{isRequired},</if>
<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
<if test="isEdit != null and isEdit != ''">#{isEdit},</if>
<if test="isList != null and isList != ''">#{isList},</if>
<if test="isQuery != null and isQuery != ''">#{isQuery},</if>
<if test="queryType != null and queryType != ''">#{queryType},</if>
<if test="htmlType != null and htmlType != ''">#{htmlType},</if>
<if test="dictType != null and dictType != ''">#{dictType},</if>
<if test="sort != null">#{sort},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateGenTableColumn" parameterType="GenTableColumn">
update gen_table_column
<set>
<if test="columnComment != null">column_comment = #{columnComment},</if>
<if test="javaType != null">java_type = #{javaType},</if>
<if test="javaField != null">java_field = #{javaField},</if>
<if test="isInsert != null">is_insert = #{isInsert},</if>
<if test="isEdit != null">is_edit = #{isEdit},</if>
<if test="isList != null">is_list = #{isList},</if>
<if test="isQuery != null">is_query = #{isQuery},</if>
<if test="isRequired != null">is_required = #{isRequired},</if>
<if test="queryType != null">query_type = #{queryType},</if>
<if test="htmlType != null">html_type = #{htmlType},</if>
<if test="dictType != null">dict_type = #{dictType},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where column_id = #{columnId}
</update>
<delete id="deleteGenTableColumnByIds" parameterType="Long">
delete from gen_table_column where table_id in
<foreach collection="array" item="tableId" open="(" separator="," close=")">

View File

@ -57,28 +57,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
</sql>
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
<include refid="selectGenTableVo"/>
<where>
<if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
</if>
<if test="tableComment != null and tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
</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="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
<if test="@com.ruoyi.common.orm.helper.DataBaseHelper@isMySql()">
select table_name, table_comment, create_time, update_time
from information_schema.tables
where table_schema = (select database())
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
AND table_name NOT LIKE 'pj_%' AND table_name NOT LIKE 'gen_%'
AND table_name NOT IN (select table_name from gen_table)
<if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
@ -86,22 +70,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tableComment != null and tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
</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')
order by create_time desc
</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 test="@com.ruoyi.common.orm.helper.DataBaseHelper@isPostgreSql()">
select table_name, table_comment, create_time, update_time
from (
SELECT c.relname AS table_name,
obj_description(c.oid) AS table_comment,
CURRENT_TIMESTAMP AS create_time,
CURRENT_TIMESTAMP AS update_time
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
AND c.relname != 'spatial_%'::text
AND n.nspname = 'public'::name
AND n.nspname <![CDATA[ <> ]]> ''::name
) list_table
where table_name NOT LIKE 'pj_%' AND table_name NOT LIKE 'gen_%'
AND table_name NOT IN (select table_name from gen_table)
<if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
</if>
<if test="tableComment != null and tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
</if>
order by create_time desc
</if>
</select>
<select id="selectDbTableListByNames" resultMap="GenTableResult">
<if test="@com.ruoyi.common.orm.helper.DataBaseHelper@isMySql()">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
where table_name NOT LIKE 'pj_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
and table_name in
<foreach collection="array" item="name" open="(" separator="," close=")">
#{name}
</foreach>
</if>
<if test="@com.ruoyi.common.orm.helper.DataBaseHelper@isPostgreSql()">
select table_name, table_comment, create_time, update_time
from (
SELECT c.relname AS table_name,
obj_description(c.oid) AS table_comment,
CURRENT_TIMESTAMP AS create_time,
CURRENT_TIMESTAMP AS update_time
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
AND c.relname != 'spatial_%'::text
AND n.nspname = 'public'::name
AND n.nspname <![CDATA[ <> ]]> ''::name
) list_table
where table_name NOT LIKE 'pj_%' and table_name NOT LIKE 'gen_%'
and table_name in
<foreach collection="array" item="name" open="(" separator="," close=")">
#{name}
</foreach>
</if>
</select>
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
@ -110,14 +136,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and table_name = #{tableName}
</select>
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_id = #{tableId} order by c.sort
</select>
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
@ -126,77 +144,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where t.table_name = #{tableName} order by c.sort
</select>
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
order by c.sort
</select>
<insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
insert into gen_table (
<if test="tableName != null">table_name,</if>
<if test="tableComment != null and tableComment != ''">table_comment,</if>
<if test="className != null and className != ''">class_name,</if>
<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
<if test="packageName != null and packageName != ''">package_name,</if>
<if test="moduleName != null and moduleName != ''">module_name,</if>
<if test="businessName != null and businessName != ''">business_name,</if>
<if test="functionName != null and functionName != ''">function_name,</if>
<if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
<if test="genType != null and genType != ''">gen_type,</if>
<if test="genPath != null and genPath != ''">gen_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="tableName != null">#{tableName},</if>
<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
<if test="className != null and className != ''">#{className},</if>
<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
<if test="packageName != null and packageName != ''">#{packageName},</if>
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
<if test="businessName != null and businessName != ''">#{businessName},</if>
<if test="functionName != null and functionName != ''">#{functionName},</if>
<if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
<if test="genType != null and genType != ''">#{genType},</if>
<if test="genPath != null and genPath != ''">#{genPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateGenTable" parameterType="GenTable">
update gen_table
<set>
<if test="tableName != null">table_name = #{tableName},</if>
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
<if test="subTableName != null">sub_table_name = #{subTableName},</if>
<if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if>
<if test="className != null and className != ''">class_name = #{className},</if>
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
<if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
<if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
<if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
<if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
<if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
<if test="options != null and options != ''">options = #{options},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
update_time = sysdate()
</set>
where table_id = #{tableId}
</update>
<delete id="deleteGenTableByIds" parameterType="Long">
delete from gen_table where table_id in
<foreach collection="array" item="tableId" open="(" separator="," close=")">
#{tableId}
</foreach>
</delete>
</mapper>

View File

@ -1,6 +1,6 @@
-- 菜单 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(${table.menuIds[0]}, '${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 1, sysdate(), 1, null, '${functionName}菜单');
values(${table.menuIds[0]}, '${functionName}', ${parentMenuId}, '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 1, sysdate(), 1, null, '${functionName}菜单');
-- 按钮 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)

View File

@ -0,0 +1,19 @@
-- 菜单 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(${table.menuIds[0]}, '${functionName}', ${parentMenuId}, '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 1, now(), 1, null, '${functionName}菜单');
-- 按钮 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 1, now(), 1, null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 1, now(), 1, null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 1, now(), 1, null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 1, now(), 1, null, '');
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 1, now(), 1, null, '');

View File

@ -74,7 +74,7 @@ public class SysClient extends BaseEntity {
* 删除标志0代表存在 1代表删除
*/
@Column(isLogicDelete = true)
private String delFlag;
private Integer delFlag;
}

View File

@ -38,7 +38,7 @@ public class SysDept extends BaseEntity
private String orderNum;
/** 负责人 */
private String leader;//TODO:修改为Long类型
private String leader;//TODO:修改为Long类型?
/** 联系电话 */
private String phone;
@ -49,8 +49,8 @@ public class SysDept extends BaseEntity
/** 部门状态:0正常,1停用 */
private String status;
/** 删除标志0代表存在 2代表删除) */
private String delFlag;
/** 删除标志0代表存在 1代表删除) */
private Integer delFlag;
/** 父部门名称 */
@Column(ignore = true)

View File

@ -61,9 +61,9 @@ public class SysRole extends BaseEntity {
private String status;
/**
* 删除标志0代表存在 2代表删除
* 删除标志0代表存在 1代表删除
*/
private String delFlag;
private Integer delFlag;
/**
* 备注
@ -82,11 +82,6 @@ public class SysRole extends BaseEntity {
@Column(ignore = true)
private Long[] menuIds;
@RelationManyToMany(
selfField = "roleId", targetField = "menuId",
joinTable = "sys_role_menu",
joinSelfColumn = "role_id", joinTargetColumn = "menu_id"
)
private List<SysMenu> menuList;
/**
@ -95,18 +90,8 @@ public class SysRole extends BaseEntity {
@Column(ignore = true)
private Long[] deptIds;
@RelationManyToMany(
selfField = "roleId", targetField = "deptId",
joinTable = "sys_role_dept",
joinSelfColumn = "role_id", joinTargetColumn = "dept_id"
)
private List<SysDept> deptList;
@RelationManyToMany(
selfField = "roleId", targetField = "userId",
joinTable = "sys_user_role",
joinSelfColumn = "role_id", joinTargetColumn = "user_id"
)
private List<SysUser> userList;
/**

View File

@ -65,8 +65,8 @@ public class SysUser extends BaseEntity
/** 帐号状态0正常 1停用 */
private String status;
/** 删除标志0代表存在 2代表删除) */
private String delFlag;
/** 删除标志0代表存在 1代表删除) */
private Integer delFlag;
/** 最后登录IP */
private String loginIp;

View File

@ -44,7 +44,7 @@ public interface SysRoleMapper extends BaseMapper<SysRole>
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.ROLE_ID.eq(SYS_ROLE.ROLE_ID))
.leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_ROLE.USER_ID))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID));
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq("0"))
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq(0))
.and(SYS_USER_ROLE.USER_ID.eq(userId));
List<SysRoleVo> userRoles = selectListByQueryAs(queryWrapper, SysRoleVo.class);

View File

@ -10,8 +10,7 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
/**
* 系统授权表 服务层实现
*
* @author mybatis-flex-helper automatic generation
* @since 1.0
* @author dataprince数据小王子
*/
@Service
public class SysClientServiceImpl extends ServiceImpl<SysClientMapper, SysClient> implements ISysClientService {

View File

@ -11,7 +11,6 @@ import com.ruoyi.system.domain.vo.SysRoleVo;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysDataScopeService;
import com.ruoyi.system.service.ISysRoleService;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

View File

@ -26,7 +26,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.annotation.DataScope;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.core.text.Convert;
import com.ruoyi.common.core.exception.ServiceException;
@ -44,6 +43,7 @@ import static com.ruoyi.system.domain.table.SysRoleDeptTableDef.SYS_ROLE_DEPT;
* 部门管理 服务实现
*
* @author ruoyi
* @author dataprince数据小王子
*/
@RequiredArgsConstructor
@Service
@ -68,7 +68,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
*/
private QueryWrapper buildQueryWrapper(SysDeptBo deptBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
queryWrapper.where(SYS_DEPT.DEL_FLAG.eq("0"));
queryWrapper.where(SYS_DEPT.DEL_FLAG.eq(0));
if (ObjectUtil.isNotNull(deptBo.getDeptId())) {
queryWrapper.and(SYS_DEPT.DEPT_ID.eq(deptBo.getDeptId()));
@ -173,7 +173,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
@Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
@Override
public SysDeptVo selectDeptById(Long deptId) {
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq("0"));
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0));
queryWrapper.and(SYS_DEPT.DEPT_ID.eq(deptId));
return this.getOneAs(queryWrapper, SysDeptVo.class);//TODO:缺少parent_name
}
@ -185,7 +185,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
*/
@Override
public long selectDeptCountByName(String deptName) {
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq("0")).and(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0"));
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0)).and(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0"));
return this.count(queryWrapper);
}
@ -196,7 +196,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
*/
@Override
public SysDeptVo selectDeptByName(String deptName) {
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq("0")).and(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0"));
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0)).and(SYS_DEPT.DEPT_NAME.eq(deptName)).and(SYS_DEPT.STATUS.eq("0"));
return this.getOneAs(queryWrapper,SysDeptVo.class);
}
@ -212,7 +212,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
.select(QueryMethods.count(SYS_DEPT.DEPT_ID))
.from(SYS_DEPT)
.where(SYS_DEPT.STATUS.eq("0"))
.and(SYS_DEPT.DEL_FLAG.eq("0"))
.and(SYS_DEPT.DEL_FLAG.eq(0))
.and(QueryMethods.findInSet(QueryMethods.number(deptId),SYS_DEPT.ANCESTORS).gt(0));
return deptMapper.selectObjectByQueryAs(queryWrapper,Integer.class);
@ -229,7 +229,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
QueryWrapper queryWrapper = QueryWrapper.create()
.select(QueryMethods.count(SYS_DEPT.DEPT_ID))
.from(SYS_DEPT)
.where(SYS_DEPT.DEL_FLAG.eq("0"))
.where(SYS_DEPT.DEL_FLAG.eq(0))
.and(SYS_DEPT.PARENT_ID.eq(deptId));
int result = deptMapper.selectObjectByQueryAs(queryWrapper,Integer.class);
@ -247,7 +247,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
public boolean checkDeptNameUnique(SysDeptBo dept) {
Long deptId = ObjectUtil.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq("0"));
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq(0));
queryWrapper.and(SYS_DEPT.DEPT_NAME.eq(dept.getDeptName()));
queryWrapper.and(SYS_DEPT.PARENT_ID.eq(dept.getParentId()));
SysDeptVo info = this.getOneAs(queryWrapper, SysDeptVo.class);
@ -295,7 +295,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
}
SysDept dept = MapstructUtils.convert(deptBo, SysDept.class);
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
dept.setDelFlag("0");//0 代表存在
dept.setDelFlag(0);//0 代表存在
return this.save(dept);
}
@ -379,7 +379,7 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
//update sys_dept set del_flag = '1' where dept_id = #{deptId}
SysDept sysDept = new SysDept();
sysDept.setDeptId(deptId);
sysDept.setDelFlag("1");
sysDept.setDelFlag(1);
return this.updateById(sysDept);
}

View File

@ -8,8 +8,6 @@ import com.mybatisflex.core.query.QueryMethods;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
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.utils.MapstructUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.orm.core.page.PageQuery;
@ -34,6 +32,7 @@ import static com.ruoyi.system.domain.table.SysDictDataTableDef.SYS_DICT_DATA;
* 字典 业务层处理
*
* @author ruoyi
* @author dataprince数据小王子
*/
@RequiredArgsConstructor
@Service

View File

@ -12,8 +12,6 @@ import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.constant.CacheConstants;
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.DictService;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.core.utils.SpringUtils;
@ -44,6 +42,7 @@ import static com.ruoyi.system.domain.table.SysDictTypeTableDef.SYS_DICT_TYPE;
* 字典 业务层处理
*
* @author ruoyi
* @author dataprince数据小王子
*/
@Service
public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService, DictService

View File

@ -39,6 +39,7 @@ import static com.ruoyi.system.domain.table.SysLogininforTableDef.SYS_LOGININFOR
* 系统访问日志情况信息 服务层处理
*
* @author ruoyi
* @author dataprince数据小王子
*/
@RequiredArgsConstructor
@Slf4j

View File

@ -44,6 +44,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
* 菜单 业务层处理
*
* @author ruoyi
* @author dataprince数据小王子
*/
@Service
public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuMapper,SysMenu> implements ISysMenuService {

View File

@ -25,7 +25,8 @@ import static com.ruoyi.system.domain.table.SysNoticeTableDef.SYS_NOTICE;
/**
* 公告 服务层实现
*
* @author 数据小王子
* @author ruoyi
* @author dataprince数据小王子
*/
@Service
public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {

View File

@ -31,6 +31,7 @@ import static com.ruoyi.system.domain.table.SysOperLogTableDef.SYS_OPER_LOG;
* 操作日志 服务层处理
*
* @author ruoyi
* @author dataprince数据小王子
*/
@Service
public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLogMapper, SysOperLog> implements ISysOperLogService

View File

@ -15,6 +15,7 @@ import java.util.Set;
* 用户权限处理
*
* @author ruoyi
* @author dataprince数据小王子
*/
@RequiredArgsConstructor
@Service

View File

@ -5,10 +5,7 @@ import java.util.List;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.core.page.PageDomain;
import com.ruoyi.common.core.core.page.TableSupport;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.core.utils.sql.SqlUtil;
import com.ruoyi.common.orm.core.page.PageQuery;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
@ -22,7 +19,6 @@ import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.service.ISysPostService;
import org.springframework.transaction.annotation.Transactional;
@ -34,6 +30,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
* 岗位信息 服务层处理
*
* @author ruoyi
* @author dataprince数据小王子
*/
@Service
public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost> implements ISysPostService

View File

@ -16,6 +16,7 @@ import static com.ruoyi.system.domain.table.SysRoleMenuTableDef.SYS_ROLE_MENU;
/**
* SysRoleMenu服务实现类
*
* @author ruoyi
* @author dataprince数据小王子
*/
@Service

View File

@ -26,14 +26,12 @@ import com.ruoyi.system.service.*;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.core.annotation.DataScope;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.SpringUtils;
import static com.ruoyi.system.domain.table.SysDeptTableDef.SYS_DEPT;
import static com.ruoyi.system.domain.table.SysRoleMenuTableDef.SYS_ROLE_MENU;
import static com.ruoyi.system.domain.table.SysRoleTableDef.SYS_ROLE;
import static com.ruoyi.system.domain.table.SysUserRoleTableDef.SYS_USER_ROLE;
import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
@ -42,6 +40,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
* 角色 业务层处理
*
* @author ruoyi
* @author dataprince数据小王子
*/
@Service
public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
@ -77,7 +76,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
.leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_ROLE.USER_ID))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID));
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq("0"));
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq(0));
if (ObjectUtil.isNotNull(roleBo.getRoleId())) {
queryWrapper.and(SYS_ROLE.ROLE_ID.eq(roleBo.getRoleId()));
}
@ -145,7 +144,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.ROLE_ID.eq(SYS_ROLE.ROLE_ID))
.leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_ROLE.USER_ID))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID));
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq("0"))
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq(0))
.and(SYS_USER_ROLE.USER_ID.eq(userId));
List<SysRoleVo> userRoles = this.listAs(queryWrapper, SysRoleVo.class);
@ -205,7 +204,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.ROLE_ID.eq(SYS_ROLE.ROLE_ID))
.leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_ROLE.USER_ID))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID));
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq("0"))
queryWrapper.where(SYS_ROLE.DEL_FLAG.eq(0))
.and(SYS_USER_ROLE.USER_ID.eq(userId));
List<SysRoleVo> perms = this.listAs(queryWrapper, SysRoleVo.class);
//List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId);
@ -272,7 +271,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
public boolean checkRoleNameUnique(SysRoleBo roleBo) {
Long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId();
QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_NAME.eq(roleBo.getRoleName()))
.and(SYS_ROLE.DEL_FLAG.eq("0"));
.and(SYS_ROLE.DEL_FLAG.eq(0));
SysRole info = this.getOne(queryWrapper);
if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE;
@ -290,7 +289,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
public boolean checkRoleKeyUnique(SysRoleBo roleBo) {
Long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId();
QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_KEY.eq(roleBo.getRoleKey()))
.and(SYS_ROLE.DEL_FLAG.eq("0"));
.and(SYS_ROLE.DEL_FLAG.eq(0));
SysRole info = this.getOne(queryWrapper);
if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
return UserConstants.NOT_UNIQUE;
@ -359,7 +358,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
@Transactional
public boolean insertRole(SysRoleBo roleBo) {
SysRole role = MapstructUtils.convert(roleBo, SysRole.class);
role.setDelFlag("0");
role.setDelFlag(0);
role.setDataScope("1");//默认1全部数据权限
// 新增角色信息
boolean inserted = this.save(role);//使用全局配置的雪花算法主键生成器生成ID值
@ -563,7 +562,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.ROLE_ID.eq(SYS_ROLE.ROLE_ID))
.leftJoin(SYS_USER).as("u").on(SYS_USER.USER_ID.eq(SYS_USER_ROLE.USER_ID))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
.where(SYS_ROLE.DEL_FLAG.eq("0"))
.where(SYS_ROLE.DEL_FLAG.eq(0))
.and(SYS_USER.USER_NAME.eq(userName));
return this.listAs(queryWrapper, SysRoleVo.class);
}

View File

@ -16,6 +16,7 @@ import static com.ruoyi.system.domain.table.SysUserPostTableDef.SYS_USER_POST;
/**
* ruoyi-flex
*
* @author ruoyi
* @author dataprince数据小王子
*/
@Service

View File

@ -18,6 +18,7 @@ import static com.ruoyi.system.domain.table.SysUserRoleTableDef.SYS_USER_ROLE;
/**
* SysUserRoleService实现类
*
* @author ruoyi
* @author dataprince数据小王子
*/
@Service

View File

@ -50,6 +50,7 @@ import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
* 用户 业务层处理
*
* @author ruoyi
* @author dataprince数据小王子
*/
@Service
public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser> implements ISysUserService, UserService {
@ -93,7 +94,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
.select(SYS_USER.USER_ID,SYS_USER.TENANT_ID,SYS_USER.DEPT_ID,SYS_USER.NICK_NAME,SYS_USER.USER_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.AVATAR,SYS_USER.PHONENUMBER,SYS_USER.GENDER,SYS_USER.STATUS,SYS_USER.DEL_FLAG,SYS_USER.LOGIN_IP,SYS_USER.LOGIN_DATE,SYS_USER.CREATE_BY,SYS_USER.CREATE_TIME,SYS_USER.REMARK,SYS_DEPT.DEPT_NAME,SYS_DEPT.LEADER)
.from(SYS_USER.as("u"))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
.where(SYS_USER.DEL_FLAG.eq("0"));
.where(SYS_USER.DEL_FLAG.eq(0));
if (ObjectUtil.isNotNull(userBo.getUserId())) {
queryWrapper.and(SYS_USER.USER_ID.eq(userBo.getUserId()));
}
@ -139,7 +140,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
))
.from(SYS_USER.as("u"))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
.where(SYS_USER.DEL_FLAG.eq("0"));
.where(SYS_USER.DEL_FLAG.eq(0));
//.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.USER_ID.eq(SYS_USER.USER_ID))
//.leftJoin(SYS_ROLE).as("r").on(SYS_ROLE.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID));
}
@ -198,7 +199,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.USER_ID.eq(SYS_USER.USER_ID))
.leftJoin(SYS_ROLE).as("r").on(SYS_ROLE.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID))
.where(SYS_USER.DEL_FLAG.eq("0"))
.where(SYS_USER.DEL_FLAG.eq(0))
.and(SYS_ROLE.ROLE_ID.eq(userBo.getRoleId()));
if (StringUtils.isNotEmpty(userBo.getUserName())) {
queryWrapper.and(SYS_USER.USER_NAME.like(userBo.getUserName()));
@ -240,7 +241,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.USER_ID.eq(SYS_USER.USER_ID))
.leftJoin(SYS_ROLE).as("r").on(SYS_ROLE.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID))
.where(SYS_USER.DEL_FLAG.eq("0"))
.where(SYS_USER.DEL_FLAG.eq(0))
.and(SYS_USER.STATUS.eq("0"))
.and(SYS_ROLE.ROLE_ID.ne(userBo.getRoleId()).or(SYS_ROLE.ROLE_ID.isNull()))
.and(SYS_USER.USER_ID.notIn(select(SYS_USER.USER_ID).from(SYS_USER.as("u")).innerJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.USER_ID.eq(SYS_USER.USER_ID).and(SYS_USER_ROLE.ROLE_ID.eq(userBo.getRoleId())))));
@ -264,7 +265,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
@Override
public SysUserVo selectUserByUserName(String userName) {
QueryWrapper queryWrapper = buildOneQueryWrapper();
queryWrapper.where(SYS_USER.DEL_FLAG.eq("0"));
queryWrapper.where(SYS_USER.DEL_FLAG.eq(0));
if (StringUtils.isNotEmpty(userName)) {
queryWrapper.and(SYS_USER.USER_NAME.eq(userName));
}
@ -280,7 +281,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
@Override
public SysUserVo selectUserByEmail(String email) {
QueryWrapper queryWrapper = buildOneQueryWrapper();
queryWrapper.where(SYS_USER.DEL_FLAG.eq("0"));
queryWrapper.where(SYS_USER.DEL_FLAG.eq(0));
if (StringUtils.isNotEmpty(email)) {
queryWrapper.and(SYS_USER.EMAIL.eq(email));
}
@ -318,7 +319,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
))
.from(SYS_USER.as("u"))
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
.where(SYS_USER.DEL_FLAG.eq("0"));
.where(SYS_USER.DEL_FLAG.eq(0));
if (ObjectUtil.isNotNull(userId)) {
queryWrapper.and(SYS_USER.USER_ID.eq(userId));
}
@ -365,7 +366,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
public boolean checkUserNameUnique(SysUserBo userBo) {
Long userId = ObjectUtil.isNull(userBo.getUserId()) ? -1L : userBo.getUserId();
QueryWrapper queryWrapper = query().where(SYS_USER.USER_NAME.eq(userBo.getUserName()))
.and(SYS_USER.DEL_FLAG.eq("0"));
.and(SYS_USER.DEL_FLAG.eq(0));
SysUser info = this.getOne(queryWrapper);
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
return UserConstants.NOT_UNIQUE;
@ -383,7 +384,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
public boolean checkPhoneUnique(SysUserBo user) {
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
QueryWrapper queryWrapper = query().where(SYS_USER.PHONENUMBER.eq(user.getPhonenumber()))
.and(SYS_USER.DEL_FLAG.eq("0"));
.and(SYS_USER.DEL_FLAG.eq(0));
SysUser info = this.getOne(queryWrapper);
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
return UserConstants.NOT_UNIQUE;
@ -401,7 +402,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
public boolean checkEmailUnique(SysUserBo user) {
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
QueryWrapper queryWrapper = query().where(SYS_USER.EMAIL.eq(user.getEmail()))
.and(SYS_USER.DEL_FLAG.eq("0"));
.and(SYS_USER.DEL_FLAG.eq(0));
SysUser info = this.getOne(queryWrapper);
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
return UserConstants.NOT_UNIQUE;
@ -455,7 +456,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
.select(QueryMethods.count(SYS_USER.USER_ID))
.from(SYS_USER)
.where(SYS_USER.DEPT_ID.eq(deptId))
.and(SYS_USER.DEL_FLAG.eq("0"));
.and(SYS_USER.DEL_FLAG.eq(0));
int result = userMapper.selectObjectByQueryAs(queryWrapper,Integer.class);
return result > 0;
@ -659,7 +660,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
//逻辑删除用户update sys_user set del_flag = '1' where user_id = #{userId}
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setDelFlag("1");
sysUser.setDelFlag(1);
return this.updateById(sysUser);
}
@ -684,7 +685,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
//逻辑删除update sys_user set del_flag = '1' where user_id in
QueryWrapper queryWrapper = query().where(SYS_USER.USER_ID.in(Arrays.asList(userIds)));
SysUser sysUser = new SysUser();
sysUser.setDelFlag("1");
sysUser.setDelFlag(1);
return this.update(sysUser,queryWrapper);
//return UpdateChain.of(SysUser.class)
// .set(SysUser::getDelFlag, "1")
@ -765,7 +766,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
*/
@Override
public List<SysUserVo> selectUserListByDept(Long deptId) {
QueryWrapper queryWrapper = query().where(SYS_USER.DEPT_ID.eq(deptId)).and(SYS_USER.DEL_FLAG.eq("0"));
QueryWrapper queryWrapper = query().where(SYS_USER.DEPT_ID.eq(deptId)).and(SYS_USER.DEL_FLAG.eq(0));
return this.listAs(queryWrapper,SysUserVo.class);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
--V4.1.8V4.2.0
-- sys_menu菜单表结构修改、去掉主键自增
ALTER TABLE `sys_menu`
CHANGE COLUMN `menu_id` `menu_id` BIGINT(19) NOT NULL COMMENT '菜单ID' FIRST,
@ -12,5 +13,18 @@ ALTER TABLE `gen_table`
ALTER TABLE `gen_table_column`
CHANGE COLUMN `column_id` `column_id` BIGINT(19) NOT NULL COMMENT '编号' FIRST;
ALTER TABLE `sys_tenant` DROP COLUMN `create_dept`;
-- 修改数据库表的del_flag字段为smallint类型
ALTER TABLE `sys_client`
CHANGE COLUMN `del_flag` `del_flag` SMALLINT NULL DEFAULT '0' COMMENT '删除标志0代表存在 1代表删除' COLLATE 'utf8mb4_bin' AFTER `status`;
ALTER TABLE `sys_dept`
CHANGE COLUMN `del_flag` `del_flag` SMALLINT NULL DEFAULT '0' COMMENT '删除标志0代表存在 1代表删除' COLLATE 'utf8mb4_bin' AFTER `status`;
ALTER TABLE `sys_role`
CHANGE COLUMN `del_flag` `del_flag` SMALLINT NULL DEFAULT '0' COMMENT '删除标志0代表存在 1代表删除' COLLATE 'utf8mb4_bin' AFTER `status`;
ALTER TABLE `sys_tenant`
CHANGE COLUMN `del_flag` `del_flag` SMALLINT NULL DEFAULT '0' COMMENT '删除标志0代表存在 1代表删除' COLLATE 'utf8mb4_bin' AFTER `status`;
ALTER TABLE `sys_user`
CHANGE COLUMN `del_flag` `del_flag` SMALLINT NULL DEFAULT '0' COMMENT '删除标志0代表存在 1代表删除' COLLATE 'utf8mb4_bin' AFTER `status`;

File diff suppressed because it is too large Load Diff