From 2b39b434fac1fa7d4a0e382e8ab9fe5552499eef Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 13 Jul 2024 22:42:54 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BE=9D=E8=B5=96=E3=80=91mybatis-plu?= =?UTF-8?q?s=20from=203.5.5=20to=203.5.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-dependencies/pom.xml | 12 +- .../db/DataPermissionDatabaseInterceptor.java | 398 ++---------------- .../rule/dept/DeptDataPermissionRule.java | 3 +- ...ataPermissionDatabaseInterceptorTest2.java | 7 +- .../mybatis/core/mapper/BaseMapperX.java | 4 +- .../core/type/JsonLongSetTypeHandler.java | 31 -- .../ai/dal/dataobject/image/AiImageDO.java | 18 +- .../dataobject/definition/BpmUserGroupDO.java | 9 +- .../dal/dataobject/file/FileConfigDO.java | 14 +- .../dataobject/comment/ProductCommentDO.java | 2 +- .../dal/dataobject/sku/ProductSkuDO.java | 20 +- .../dataobject/reward/RewardActivityDO.java | 20 +- .../dal/dataobject/aftersale/AfterSaleDO.java | 2 +- .../dataobject/order/TradeOrderItemDO.java | 20 +- .../message/vo/message/MpMessageRespVO.java | 4 +- .../mp/dal/dataobject/menu/MpMenuDO.java | 3 +- .../dal/dataobject/message/MpAutoReplyDO.java | 3 +- .../dal/dataobject/message/MpMessageDO.java | 25 +- .../dal/dataobject/permission/RoleDO.java | 6 +- .../dataobject/tenant/TenantPackageDO.java | 4 +- .../dal/dataobject/user/AdminUserDO.java | 4 +- 21 files changed, 90 insertions(+), 519 deletions(-) delete mode 100644 yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/JsonLongSetTypeHandler.java diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index b9c5fcef4..8c0c60e4d 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -23,10 +23,11 @@ 4.3.0 1.2.23 - 3.5.5 - 3.5.5 + 3.5.16 + 3.5.7 + 3.5.7 4.3.1 - 1.4.10 + 1.4.13 2.2.11 3.26.0 8.1.3.62 @@ -171,6 +172,11 @@ druid-spring-boot-3-starter ${druid.version} + + org.mybatis + mybatis + ${mybatis.version} + com.baomidou mybatis-plus-spring-boot3-starter diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptor.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptor.java index cbeedee4d..cea2ad658 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptor.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptor.java @@ -7,19 +7,17 @@ import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRuleFac import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.PluginUtils; -import com.baomidou.mybatisplus.extension.parser.JsqlParserSupport; +import com.baomidou.mybatisplus.extension.plugins.inner.BaseMultiTableInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; import lombok.Getter; import lombok.RequiredArgsConstructor; -import net.sf.jsqlparser.expression.*; +import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.operators.conditional.AndExpression; -import net.sf.jsqlparser.expression.operators.conditional.OrExpression; -import net.sf.jsqlparser.expression.operators.relational.ExistsExpression; -import net.sf.jsqlparser.expression.operators.relational.ExpressionList; -import net.sf.jsqlparser.expression.operators.relational.InExpression; import net.sf.jsqlparser.schema.Table; import net.sf.jsqlparser.statement.delete.Delete; -import net.sf.jsqlparser.statement.select.*; +import net.sf.jsqlparser.statement.select.Select; +import net.sf.jsqlparser.statement.select.WithItem; import net.sf.jsqlparser.statement.update.Update; import org.apache.ibatis.executor.Executor; import org.apache.ibatis.executor.statement.StatementHandler; @@ -30,20 +28,25 @@ import org.apache.ibatis.session.ResultHandler; import org.apache.ibatis.session.RowBounds; import java.sql.Connection; -import java.util.*; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** * 数据权限拦截器,通过 {@link DataPermissionRule} 数据权限规则,重写 SQL 的方式来实现 - * 主要的 SQL 重写方法,可见 {@link #builderExpression(Expression, List)} 方法 + * 主要的 SQL 重写方法,可见 {@link #buildTableExpression(Table, Expression, String)} 方法 * * 整体的代码实现上,参考 {@link com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor} 实现。 * 所以每次 MyBatis Plus 升级时,需要 Review 下其具体的实现是否有变更! * + * 为什么不直接基于 {@link DataPermissionInterceptor} 实现?因为它是 MyBatis Plus 3.5.2 版本才出来,当时 yudao 已经实现数据权限了! + * * @author 芋道源码 */ @RequiredArgsConstructor -public class DataPermissionDatabaseInterceptor extends JsqlParserSupport implements InnerInterceptor { +public class DataPermissionDatabaseInterceptor extends BaseMultiTableInnerInterceptor implements InnerInterceptor { private final DataPermissionRuleFactory ruleFactory; @@ -101,10 +104,11 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme @Override protected void processSelect(Select select, int index, String sql, Object obj) { - processSelectBody(select.getSelectBody()); + final String whereSegment = (String) obj; + processSelectBody(select, whereSegment); List withItemsList = select.getWithItemsList(); if (!CollectionUtils.isEmpty(withItemsList)) { - withItemsList.forEach(this::processSelectBody); + withItemsList.forEach(withItem -> processSelectBody(withItem, whereSegment)); } } @@ -113,8 +117,10 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme */ @Override protected void processUpdate(Update update, int index, String sql, Object obj) { - final Table table = update.getTable(); - update.setWhere(this.builderExpression(update.getWhere(), table)); + final Expression sqlSegment = getUpdateOrDeleteExpression(update.getTable(), update.getWhere(), (String) obj); + if (null != sqlSegment) { + update.setWhere(sqlSegment); + } } /** @@ -122,367 +128,16 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme */ @Override protected void processDelete(Delete delete, int index, String sql, Object obj) { - delete.setWhere(this.builderExpression(delete.getWhere(), delete.getTable())); - } - - // ========== 和 TenantLineInnerInterceptor 一致的逻辑 ========== - - protected void processSelectBody(SelectBody selectBody) { - if (selectBody == null) { - return; + final Expression sqlSegment = getUpdateOrDeleteExpression(delete.getTable(), delete.getWhere(), (String) obj); + if (null != sqlSegment) { + delete.setWhere(sqlSegment); } - if (selectBody instanceof PlainSelect) { - processPlainSelect((PlainSelect) selectBody); - } else if (selectBody instanceof WithItem) { - WithItem withItem = (WithItem) selectBody; - processSelectBody(withItem.getSubSelect().getSelectBody()); - } else { - SetOperationList operationList = (SetOperationList) selectBody; - List selectBodyList = operationList.getSelects(); - if (CollectionUtils.isNotEmpty(selectBodyList)) { - selectBodyList.forEach(this::processSelectBody); - } - } - } - - /** - * 处理 PlainSelect - */ - protected void processPlainSelect(PlainSelect plainSelect) { - //#3087 github - List selectItems = plainSelect.getSelectItems(); - if (CollectionUtils.isNotEmpty(selectItems)) { - selectItems.forEach(this::processSelectItem); - } - - // 处理 where 中的子查询 - Expression where = plainSelect.getWhere(); - processWhereSubSelect(where); - - // 处理 fromItem - FromItem fromItem = plainSelect.getFromItem(); - List list = processFromItem(fromItem); - List
mainTables = new ArrayList<>(list); - - // 处理 join - List joins = plainSelect.getJoins(); - if (CollectionUtils.isNotEmpty(joins)) { - mainTables = processJoins(mainTables, joins); - } - - // 当有 mainTable 时,进行 where 条件追加 - if (CollectionUtils.isNotEmpty(mainTables)) { - plainSelect.setWhere(builderExpression(where, mainTables)); - } - } - - private List
processFromItem(FromItem fromItem) { - // 处理括号括起来的表达式 - while (fromItem instanceof ParenthesisFromItem) { - fromItem = ((ParenthesisFromItem) fromItem).getFromItem(); - } - - List
mainTables = new ArrayList<>(); - // 无 join 时的处理逻辑 - if (fromItem instanceof Table) { - Table fromTable = (Table) fromItem; - mainTables.add(fromTable); - } else if (fromItem instanceof SubJoin) { - // SubJoin 类型则还需要添加上 where 条件 - List
tables = processSubJoin((SubJoin) fromItem); - mainTables.addAll(tables); - } else { - // 处理下 fromItem - processOtherFromItem(fromItem); - } - return mainTables; - } - - /** - * 处理where条件内的子查询 - *

- * 支持如下: - * 1. in - * 2. = - * 3. > - * 4. < - * 5. >= - * 6. <= - * 7. <> - * 8. EXISTS - * 9. NOT EXISTS - *

- * 前提条件: - * 1. 子查询必须放在小括号中 - * 2. 子查询一般放在比较操作符的右边 - * - * @param where where 条件 - */ - protected void processWhereSubSelect(Expression where) { - if (where == null) { - return; - } - if (where instanceof FromItem) { - processOtherFromItem((FromItem) where); - return; - } - if (where.toString().indexOf("SELECT") > 0) { - // 有子查询 - if (where instanceof BinaryExpression) { - // 比较符号 , and , or , 等等 - BinaryExpression expression = (BinaryExpression) where; - processWhereSubSelect(expression.getLeftExpression()); - processWhereSubSelect(expression.getRightExpression()); - } else if (where instanceof InExpression) { - // in - InExpression expression = (InExpression) where; - Expression inExpression = expression.getRightExpression(); - if (inExpression instanceof SubSelect) { - processSelectBody(((SubSelect) inExpression).getSelectBody()); - } - } else if (where instanceof ExistsExpression) { - // exists - ExistsExpression expression = (ExistsExpression) where; - processWhereSubSelect(expression.getRightExpression()); - } else if (where instanceof NotExpression) { - // not exists - NotExpression expression = (NotExpression) where; - processWhereSubSelect(expression.getExpression()); - } else if (where instanceof Parenthesis) { - Parenthesis expression = (Parenthesis) where; - processWhereSubSelect(expression.getExpression()); - } - } - } - - protected void processSelectItem(SelectItem selectItem) { - if (selectItem instanceof SelectExpressionItem) { - SelectExpressionItem selectExpressionItem = (SelectExpressionItem) selectItem; - if (selectExpressionItem.getExpression() instanceof SubSelect) { - processSelectBody(((SubSelect) selectExpressionItem.getExpression()).getSelectBody()); - } else if (selectExpressionItem.getExpression() instanceof Function) { - processFunction((Function) selectExpressionItem.getExpression()); - } - } - } - - /** - * 处理函数 - *

支持: 1. select fun(args..) 2. select fun1(fun2(args..),args..)

- *

fixed gitee pulls/141

- * - * @param function - */ - protected void processFunction(Function function) { - ExpressionList parameters = function.getParameters(); - if (parameters != null) { - parameters.getExpressions().forEach(expression -> { - if (expression instanceof SubSelect) { - processSelectBody(((SubSelect) expression).getSelectBody()); - } else if (expression instanceof Function) { - processFunction((Function) expression); - } - }); - } - } - - /** - * 处理子查询等 - */ - protected void processOtherFromItem(FromItem fromItem) { - // 去除括号 - while (fromItem instanceof ParenthesisFromItem) { - fromItem = ((ParenthesisFromItem) fromItem).getFromItem(); - } - - if (fromItem instanceof SubSelect) { - SubSelect subSelect = (SubSelect) fromItem; - if (subSelect.getSelectBody() != null) { - processSelectBody(subSelect.getSelectBody()); - } - } else if (fromItem instanceof ValuesList) { - logger.debug("Perform a subQuery, if you do not give us feedback"); - } else if (fromItem instanceof LateralSubSelect) { - LateralSubSelect lateralSubSelect = (LateralSubSelect) fromItem; - if (lateralSubSelect.getSubSelect() != null) { - SubSelect subSelect = lateralSubSelect.getSubSelect(); - if (subSelect.getSelectBody() != null) { - processSelectBody(subSelect.getSelectBody()); - } - } - } - } - - /** - * 处理 sub join - * - * @param subJoin subJoin - * @return Table subJoin 中的主表 - */ - private List
processSubJoin(SubJoin subJoin) { - List
mainTables = new ArrayList<>(); - if (subJoin.getJoinList() != null) { - List
list = processFromItem(subJoin.getLeft()); - mainTables.addAll(list); - mainTables = processJoins(mainTables, subJoin.getJoinList()); - } - return mainTables; - } - - /** - * 处理 joins - * - * @param mainTables 可以为 null - * @param joins join 集合 - * @return List
右连接查询的 Table 列表 - */ - private List
processJoins(List
mainTables, List joins) { - // join 表达式中最终的主表 - Table mainTable = null; - // 当前 join 的左表 - Table leftTable = null; - - if (mainTables == null) { - mainTables = new ArrayList<>(); - } else if (mainTables.size() == 1) { - mainTable = mainTables.get(0); - leftTable = mainTable; - } - - //对于 on 表达式写在最后的 join,需要记录下前面多个 on 的表名 - Deque> onTableDeque = new LinkedList<>(); - for (Join join : joins) { - // 处理 on 表达式 - FromItem joinItem = join.getRightItem(); - - // 获取当前 join 的表,subJoint 可以看作是一张表 - List
joinTables = null; - if (joinItem instanceof Table) { - joinTables = new ArrayList<>(); - joinTables.add((Table) joinItem); - } else if (joinItem instanceof SubJoin) { - joinTables = processSubJoin((SubJoin) joinItem); - } - - if (joinTables != null) { - - // 如果是隐式内连接 - if (join.isSimple()) { - mainTables.addAll(joinTables); - continue; - } - - // 当前表是否忽略 - Table joinTable = joinTables.get(0); - - List
onTables = null; - // 如果不要忽略,且是右连接,则记录下当前表 - if (join.isRight()) { - mainTable = joinTable; - if (leftTable != null) { - onTables = Collections.singletonList(leftTable); - } - } else if (join.isLeft()) { - onTables = Collections.singletonList(joinTable); - } else if (join.isInner()) { - if (mainTable == null) { - onTables = Collections.singletonList(joinTable); - } else { - onTables = Arrays.asList(mainTable, joinTable); - } - mainTable = null; - } - - mainTables = new ArrayList<>(); - if (mainTable != null) { - mainTables.add(mainTable); - } - - // 获取 join 尾缀的 on 表达式列表 - Collection originOnExpressions = join.getOnExpressions(); - // 正常 join on 表达式只有一个,立刻处理 - if (originOnExpressions.size() == 1 && onTables != null) { - List onExpressions = new LinkedList<>(); - onExpressions.add(builderExpression(originOnExpressions.iterator().next(), onTables)); - join.setOnExpressions(onExpressions); - leftTable = joinTable; - continue; - } - // 表名压栈,忽略的表压入 null,以便后续不处理 - onTableDeque.push(onTables); - // 尾缀多个 on 表达式的时候统一处理 - if (originOnExpressions.size() > 1) { - Collection onExpressions = new LinkedList<>(); - for (Expression originOnExpression : originOnExpressions) { - List
currentTableList = onTableDeque.poll(); - if (CollectionUtils.isEmpty(currentTableList)) { - onExpressions.add(originOnExpression); - } else { - onExpressions.add(builderExpression(originOnExpression, currentTableList)); - } - } - join.setOnExpressions(onExpressions); - } - leftTable = joinTable; - } else { - processOtherFromItem(joinItem); - leftTable = null; - } - } - - return mainTables; } // ========== 和 TenantLineInnerInterceptor 存在差异的逻辑:关键,实现权限条件的拼接 ========== - /** - * 处理条件 - * - * @param currentExpression 当前 where 条件 - * @param table 单个表 - */ - protected Expression builderExpression(Expression currentExpression, Table table) { - return this.builderExpression(currentExpression, Collections.singletonList(table)); - } - - /** - * 处理条件 - * - * @param currentExpression 当前 where 条件 - * @param tables 多个表 - */ - protected Expression builderExpression(Expression currentExpression, List
tables) { - // 没有表需要处理直接返回 - if (CollectionUtils.isEmpty(tables)) { - return currentExpression; - } - - // 第一步,获得 Table 对应的数据权限条件 - Expression dataPermissionExpression = null; - for (Table table : tables) { - // 构建每个表的权限 Expression 条件 - Expression expression = buildDataPermissionExpression(table); - if (expression == null) { - continue; - } - // 合并到 dataPermissionExpression 中 - dataPermissionExpression = dataPermissionExpression == null ? expression - : new AndExpression(dataPermissionExpression, expression); - } - - // 第二步,合并多个 Expression 条件 - if (dataPermissionExpression == null) { - return currentExpression; - } - if (currentExpression == null) { - return dataPermissionExpression; - } - // ① 如果表达式为 Or,则需要 (currentExpression) AND dataPermissionExpression - if (currentExpression instanceof OrExpression) { - return new AndExpression(new Parenthesis(currentExpression), dataPermissionExpression); - } - // ② 如果表达式为 And,则直接返回 where AND dataPermissionExpression - return new AndExpression(currentExpression, dataPermissionExpression); + protected Expression getUpdateOrDeleteExpression(final Table table, final Expression where, final String whereSegment) { + return andExpression(table, where, whereSegment); } /** @@ -491,7 +146,8 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme * @param table 表 * @return Expression 过滤条件 */ - private Expression buildDataPermissionExpression(Table table) { + @Override + public Expression buildTableExpression(Table table, Expression where, String whereSegment) { // 生成条件 Expression allExpression = null; for (DataPermissionRule rule : ContextHolder.getRules()) { diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRule.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRule.java index bc54314b4..a8ee34cca 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRule.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/core/rule/dept/DeptDataPermissionRule.java @@ -156,7 +156,8 @@ public class DeptDataPermissionRule implements DataPermissionRule { } // 拼接条件 return new InExpression(MyBatisUtils.buildColumn(tableName, tableAlias, columnName), - new ExpressionList(CollectionUtils.convertList(deptIds, LongValue::new))); + // Parenthesis 的目的,是提供 (1,2,3) 的 () 左右括号 + new Parenthesis(new ExpressionList<>(CollectionUtils.convertList(deptIds, LongValue::new)))); } private Expression buildUserExpression(String tableName, Alias tableAlias, Boolean self, Long userId) { diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java index b8cad13cf..4baa2337c 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest2.java @@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; import net.sf.jsqlparser.expression.Alias; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.LongValue; +import net.sf.jsqlparser.expression.Parenthesis; import net.sf.jsqlparser.expression.operators.relational.EqualsTo; import net.sf.jsqlparser.expression.operators.relational.ExpressionList; import net.sf.jsqlparser.expression.operators.relational.InExpression; @@ -71,9 +72,9 @@ public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest @Override public Expression getExpression(String tableName, Alias tableAlias) { Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); - ExpressionList values = new ExpressionList(new LongValue(10L), + ExpressionList values = new ExpressionList<>(new LongValue(10L), new LongValue(20L)); - return new InExpression(column, values); + return new InExpression(column, new Parenthesis((values))); } }; @@ -262,7 +263,7 @@ public class DataPermissionDatabaseInterceptorTest2 extends BaseMockitoUnitTest "right join entity2 e2 on e1.id = e2.id", "SELECT * FROM entity e " + "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + - "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1 " + + "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e.tenant_id = 1 " + "WHERE e2.tenant_id = 1"); assertSql("SELECT * FROM entity e " + diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java index e7767c6f1..8dca318de 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java @@ -185,8 +185,8 @@ public interface BaseMapperX extends MPJBaseMapper { return Db.updateBatchById(entities, size); } - default Boolean insertOrUpdate(T entity) { - return Db.saveOrUpdate(entity); + default boolean insertOrUpdate(T entity) { + return Db.saveOrUpdate(entity); } default Boolean insertOrUpdateBatch(Collection collection) { diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/JsonLongSetTypeHandler.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/JsonLongSetTypeHandler.java deleted file mode 100644 index 052c7232e..000000000 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/type/JsonLongSetTypeHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.iocoder.yudao.framework.mybatis.core.type; - -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import com.fasterxml.jackson.core.type.TypeReference; - -import java.util.Set; - -/** - * 参考 {@link com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler} 实现 - * 在我们将字符串反序列化为 Set 并且泛型为 Long 时,如果每个元素的数值太小,会被处理成 Integer 类型,导致可能存在隐性的 BUG。 - * - * 例如说哦,SysUserDO 的 postIds 属性 - * - * @author 芋道源码 - */ -public class JsonLongSetTypeHandler extends AbstractJsonTypeHandler { - - private static final TypeReference> TYPE_REFERENCE = new TypeReference>(){}; - - @Override - protected Object parse(String json) { - return JsonUtils.parseObject(json, TYPE_REFERENCE); - } - - @Override - protected String toJson(Object obj) { - return JsonUtils.toJsonString(obj); - } - -} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/image/AiImageDO.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/image/AiImageDO.java index 6768d904b..a894caee6 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/image/AiImageDO.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/image/AiImageDO.java @@ -1,7 +1,6 @@ package cn.iocoder.yudao.module.ai.dal.dataobject.image; import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModelDO; import cn.iocoder.yudao.module.ai.enums.image.AiImageStatusEnum; @@ -10,7 +9,6 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.Data; import org.springframework.ai.openai.OpenAiImageOptions; @@ -107,7 +105,7 @@ public class AiImageDO extends BaseDO { /** * mj buttons 按钮 */ - @TableField(typeHandler = ButtonTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private List buttons; /** @@ -117,19 +115,5 @@ public class AiImageDO extends BaseDO { */ private String taskId; - public static class ButtonTypeHandler extends AbstractJsonTypeHandler { - - @Override - protected Object parse(String json) { - return JsonUtils.parseArray(json, MidjourneyApi.Button.class); - } - - @Override - protected String toJson(Object obj) { - return JsonUtils.toJsonString(obj); - } - - } - } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java index 87df0472b..2de62c7f6 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java @@ -2,11 +2,14 @@ package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; import java.util.Set; @@ -44,7 +47,7 @@ public class BpmUserGroupDO extends BaseDO { /** * 成员用户编号数组 */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private Set userIds; } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileConfigDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileConfigDO.java index ac2d4d028..67e4d2e71 100755 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileConfigDO.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileConfigDO.java @@ -17,6 +17,8 @@ import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; import com.fasterxml.jackson.core.type.TypeReference; import lombok.*; +import java.lang.reflect.Field; + /** * 文件配置表 * @@ -65,8 +67,16 @@ public class FileConfigDO extends BaseDO { public static class FileClientConfigTypeHandler extends AbstractJsonTypeHandler { + public FileClientConfigTypeHandler(Class type) { + super(type); + } + + public FileClientConfigTypeHandler(Class type, Field field) { + super(type, field); + } + @Override - protected Object parse(String json) { + public Object parse(String json) { FileClientConfig config = JsonUtils.parseObjectQuietly(json, new TypeReference<>() {}); if (config != null) { return config; @@ -92,7 +102,7 @@ public class FileConfigDO extends BaseDO { } @Override - protected String toJson(Object obj) { + public String toJson(Object obj) { return JsonUtils.toJsonString(obj); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java index 40b04caf0..86d70f0a8 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java @@ -100,7 +100,7 @@ public class ProductCommentDO extends BaseDO { * * 关联 {@link ProductSkuDO#getProperties()} */ - @TableField(typeHandler = ProductSkuDO.PropertyTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private List skuProperties; /** diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java index dacb02ec8..ea9528d15 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.product.dal.dataobject.sku; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; @@ -9,7 +8,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.*; import java.util.List; @@ -43,7 +42,7 @@ public class ProductSkuDO extends BaseDO { /** * 属性数组,JSON 格式 */ - @TableField(typeHandler = PropertyTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private List properties; /** * 商品价格,单位:分 @@ -131,21 +130,6 @@ public class ProductSkuDO extends BaseDO { } - // TODO @芋艿:可以找一些新的思路 - public static class PropertyTypeHandler extends AbstractJsonTypeHandler { - - @Override - protected Object parse(String json) { - return JsonUtils.parseArray(json, Property.class); - } - - @Override - protected String toJson(Object obj) { - return JsonUtils.toJsonString(obj); - } - - } - // TODO 芋艿:integral from y // TODO 芋艿:pinkPrice from y // TODO 芋艿:seckillPrice from y diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java index 0c0b477ef..d94533e8c 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/reward/RewardActivityDO.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.reward; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; @@ -10,7 +9,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.Data; import lombok.EqualsAndHashCode; @@ -76,7 +75,7 @@ public class RewardActivityDO extends BaseDO { /** * 优惠规则的数组 */ - @TableField(typeHandler = RuleTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private List rules; /** @@ -115,19 +114,4 @@ public class RewardActivityDO extends BaseDO { } - // TODO @芋艿:可以找一些新的思路 - public static class RuleTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List parse(String json) { - return JsonUtils.parseArray(json, Rule.class); - } - - @Override - protected String toJson(List obj) { - return JsonUtils.toJsonString(obj); - } - - } - } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java index 214592b62..98dfbd4e2 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/aftersale/AfterSaleDO.java @@ -124,7 +124,7 @@ public class AfterSaleDO extends BaseDO { * * 冗余 {@link TradeOrderItemDO#getProperties()} */ - @TableField(typeHandler = TradeOrderItemDO.PropertyTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private List properties; /** * 商品图片 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java index 10b07ce58..450bc764f 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderItemDO.java @@ -1,13 +1,12 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.order; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.AfterSaleDO; import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -74,7 +73,7 @@ public class TradeOrderItemDO extends BaseDO { * * 冗余 ProductSkuDO 的 properties 字段 */ - @TableField(typeHandler = PropertyTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private List properties; /** * 商品图片 @@ -210,20 +209,5 @@ public class TradeOrderItemDO extends BaseDO { } - // TODO @芋艿:可以找一些新的思路 - public static class PropertyTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List parse(String json) { - return JsonUtils.parseArray(json, Property.class); - } - - @Override - protected String toJson(List obj) { - return JsonUtils.toJsonString(obj); - } - - } - } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java index 27c85be6b..8773e515e 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/message/vo/message/MpMessageRespVO.java @@ -2,12 +2,12 @@ package cn.iocoder.yudao.module.mp.controller.admin.message.vo.message; import cn.iocoder.yudao.module.mp.dal.dataobject.message.MpMessageDO; import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import me.chanjar.weixin.common.api.WxConsts; import java.time.LocalDateTime; -import java.util.Date; import java.util.List; @Schema(description = "管理后台 - 公众号消息 Response VO") @@ -81,7 +81,7 @@ public class MpMessageRespVO { * * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private List articles; @Schema(description = "音乐链接 消息类型为 music 时,才有值", example = "https://www.iocoder.cn/xxx.mp3") diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java index 2e6aa73ce..6ae8e6b7c 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/menu/MpMenuDO.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -163,7 +164,7 @@ public class MpMenuDO extends BaseDO { * * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private List replyArticles; /** diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java index 52f4539a4..6804e40a6 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpAutoReplyDO.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -143,7 +144,7 @@ public class MpAutoReplyDO extends BaseDO { * * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS */ - @TableField(typeHandler = MpMessageDO.ArticleTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private List responseArticles; /** diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java index 76fe1818a..f2ddeca8a 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/dal/dataobject/message/MpMessageDO.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.mp.dal.dataobject.message; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; import cn.iocoder.yudao.module.mp.dal.dataobject.user.MpUserDO; @@ -9,12 +8,14 @@ import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; -import lombok.*; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; +import jakarta.validation.constraints.NotEmpty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.mp.builder.kefu.NewsBuilder; -import jakarta.validation.constraints.NotEmpty; import java.io.Serializable; import java.util.List; @@ -173,7 +174,7 @@ public class MpMessageDO extends BaseDO { * * 消息类型为 {@link WxConsts.XmlMsgType} 的 NEWS */ - @TableField(typeHandler = ArticleTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private List
articles; /** @@ -238,18 +239,4 @@ public class MpMessageDO extends BaseDO { } - // TODO @芋艿:可以找一些新的思路 - public static class ArticleTypeHandler extends AbstractJsonTypeHandler> { - - @Override - protected List
parse(String json) { - return JsonUtils.parseArray(json, Article.class); - } - - @Override - protected String toJson(List
obj) { - return JsonUtils.toJsonString(obj); - } - - } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/RoleDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/RoleDO.java index ab0ec912a..482a4b59d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/RoleDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/RoleDO.java @@ -1,14 +1,14 @@ package cn.iocoder.yudao.module.system.dal.dataobject.permission; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; -import cn.iocoder.yudao.module.system.enums.permission.DataScopeEnum; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import cn.iocoder.yudao.module.system.enums.permission.DataScopeEnum; import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.Data; import lombok.EqualsAndHashCode; @@ -72,7 +72,7 @@ public class RoleDO extends TenantBaseDO { * * 适用于 {@link #dataScope} 的值为 {@link DataScopeEnum#DEPT_CUSTOM} 时 */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private Set dataScopeDeptIds; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantPackageDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantPackageDO.java index dba7569af..60efbc8a5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantPackageDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantPackageDO.java @@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.system.dal.dataobject.tenant; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.*; import java.util.Set; @@ -46,7 +46,7 @@ public class TenantPackageDO extends BaseDO { /** * 关联的菜单编号 */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private Set menuIds; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java index 84f54a344..2f07a3015 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java @@ -1,13 +1,13 @@ package cn.iocoder.yudao.module.system.dal.dataobject.user; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import cn.iocoder.yudao.module.system.enums.common.SexEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.*; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -58,7 +58,7 @@ public class AdminUserDO extends TenantBaseDO { /** * 岗位编号数组 */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) + @TableField(typeHandler = JacksonTypeHandler.class) private Set postIds; /** * 用户邮箱