执行逻辑删除的时候,同时修改主键字段值增加删除标识,方便再次使用这个主键值
This commit is contained in:
@@ -560,7 +560,14 @@ mybatis:
|
||||
|
||||
# 批量插入和更新的分批默认大小(防止库一次性接受不了太大的sql语句)
|
||||
defaultBatchSize: 500
|
||||
|
||||
|
||||
# 执行逻辑删除的时候,同时修改主键字段值,方便再次使用这个主键值 v5.4.0+
|
||||
# 案例分析(角色管理场景):
|
||||
# 1.如果是逻辑删除数据,并非物理删除,所以删除了角色 abc 再次新增时,会提示 abc 编号已存在
|
||||
# 2.使用方法为:在 super.delete(entity); 前调用:entity.sqlMap().markIdDelete();
|
||||
# 3.一般在手动填写主键业务中使用,启用后将会在删除后,修改 ID 值数据,例如:abc__del_随机串
|
||||
markIdDeleteFlag: __del_
|
||||
|
||||
# Mapper文件刷新线程
|
||||
mapper:
|
||||
refresh:
|
||||
|
||||
@@ -259,6 +259,9 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(${ClassName} ${className}) {
|
||||
<% if (table.pkList.~size > 0 && table.pkList[0].showType == 'input') { %>
|
||||
${className}.sqlMap().markIdDelete(); // 逻辑删除时标记ID值
|
||||
<% } %>
|
||||
super.delete(${className});
|
||||
<% for (child in table.childList) { %>
|
||||
${@StringUtils.cap(child.className)} ${@StringUtils.uncap(child.className)} = new ${@StringUtils.cap(child.className)}();
|
||||
|
||||
@@ -269,6 +269,9 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv
|
||||
@GlobalTransactional
|
||||
@Transactional
|
||||
public void delete(${ClassName} ${className}) {
|
||||
<% if (table.pkList.~size > 0 && table.pkList[0].showType == 'input') { %>
|
||||
${className}.sqlMap().markIdDelete(); // 逻辑删除时标记ID值
|
||||
<% } %>
|
||||
super.delete(${className});
|
||||
<% for (child in table.childList) { %>
|
||||
${@StringUtils.cap(child.className)} ${@StringUtils.uncap(child.className)} = new ${@StringUtils.cap(child.className)}();
|
||||
|
||||
Reference in New Issue
Block a user