执行逻辑删除的时候,同时修改主键字段值增加删除标识,方便再次使用这个主键值
This commit is contained in:
@@ -106,6 +106,7 @@ public class CategoryService extends TreeService<CategoryDao, Category> {
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(Category category) {
|
||||
category.sqlMap().markIdDelete();
|
||||
super.delete(category);
|
||||
// 清理首页、栏目和文章页面缓存
|
||||
if (pageCacheService != null) {
|
||||
|
||||
@@ -75,6 +75,7 @@ public class SiteService extends CrudService<SiteDao, Site> {
|
||||
@Transactional
|
||||
public void updateStatus(Site site) {
|
||||
super.updateStatus(site);
|
||||
CmsUtils.removeCache("siteList");
|
||||
// 清理首页、栏目和文章页面缓存
|
||||
if (pageCacheService != null) {
|
||||
pageCacheService.clearCache(site);
|
||||
@@ -88,24 +89,26 @@ public class SiteService extends CrudService<SiteDao, Site> {
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(Site site) {
|
||||
site.sqlMap().markIdDelete();
|
||||
super.delete(site);
|
||||
CmsUtils.removeCache("siteList");
|
||||
// 清理首页、栏目和文章页面缓存
|
||||
if (pageCacheService != null) {
|
||||
pageCacheService.clearCache(site);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除站点
|
||||
* @param site
|
||||
* @param isRe
|
||||
*/
|
||||
@Transactional
|
||||
public void delete(Site site, Boolean isRe) {
|
||||
site.setStatus(isRe != null && isRe ? Site.STATUS_NORMAL : Site.STATUS_DELETE);
|
||||
super.delete(site);
|
||||
CmsUtils.removeCache("siteList");
|
||||
}
|
||||
// /**
|
||||
// * 删除站点
|
||||
// * @param site
|
||||
// * @param isRe
|
||||
// */
|
||||
// @Transactional
|
||||
// public void delete(Site site, Boolean isRe) {
|
||||
// site.setStatus(isRe != null && isRe ? Site.STATUS_NORMAL : Site.STATUS_DELETE);
|
||||
// super.delete(site);
|
||||
// CmsUtils.removeCache("siteList");
|
||||
// }
|
||||
|
||||
/**
|
||||
* 重建索引
|
||||
|
||||
@@ -53,6 +53,7 @@ public class AreaServiceSupport extends TreeService<AreaDao, Area>
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(Area area) {
|
||||
area.sqlMap().markIdDelete();
|
||||
super.delete(area);
|
||||
AreaUtils.clearCache();
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public class EmployeeServiceSupport extends CrudService<EmployeeDao, Employee>
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(Employee employee) {
|
||||
employee.sqlMap().markIdDelete();
|
||||
super.delete(employee);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,6 @@
|
||||
*/
|
||||
package com.jeesite.modules.sys.service.support;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.service.ServiceException;
|
||||
import com.jeesite.common.service.TreeService;
|
||||
@@ -23,6 +14,13 @@ import com.jeesite.modules.sys.entity.Office;
|
||||
import com.jeesite.modules.sys.service.DataScopeService;
|
||||
import com.jeesite.modules.sys.service.OfficeService;
|
||||
import com.jeesite.modules.sys.utils.EmpUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 机构Service
|
||||
@@ -158,6 +156,7 @@ public class OfficeServiceSupport extends TreeService<OfficeDao, Office>
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(Office office) {
|
||||
office.sqlMap().markIdDelete();
|
||||
super.delete(office);
|
||||
// 清理部门相关缓存
|
||||
clearOfficeCache();
|
||||
|
||||
@@ -92,6 +92,7 @@ public class PostServiceSupport extends CrudService<PostDao, Post>
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(Post post) {
|
||||
post.sqlMap().markIdDelete();
|
||||
super.delete(post);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)}();
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
*/
|
||||
package com.jeesite.modules.test.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.jeesite.common.service.TreeService;
|
||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||
import com.jeesite.modules.test.dao.TestTreeDao;
|
||||
import com.jeesite.modules.test.entity.TestTree;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试树表Service
|
||||
@@ -73,6 +72,7 @@ public class TestTreeService extends TreeService<TestTreeDao, TestTree> {
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(TestTree testTree) {
|
||||
testTree.sqlMap().markIdDelete(); // 逻辑删除时标记ID值
|
||||
super.delete(testTree);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
*/
|
||||
package com.jeesite.modules.test.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.jeesite.common.service.TreeService;
|
||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||
import com.jeesite.modules.test.dao.TestTreeDao;
|
||||
import com.jeesite.modules.test.entity.TestTree;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试树表Service
|
||||
@@ -73,6 +72,7 @@ public class TestTreeService extends TreeService<TestTreeDao, TestTree> {
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(TestTree testTree) {
|
||||
testTree.sqlMap().markIdDelete(); // 逻辑删除时标记ID值
|
||||
super.delete(testTree);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
*/
|
||||
package com.jeesite.modules.test.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.jeesite.common.service.TreeService;
|
||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||
import com.jeesite.modules.test.dao.TestTreeDao;
|
||||
import com.jeesite.modules.test.entity.TestTree;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试树表Service
|
||||
@@ -73,6 +72,7 @@ public class TestTreeService extends TreeService<TestTreeDao, TestTree> {
|
||||
@Override
|
||||
@Transactional
|
||||
public void delete(TestTree testTree) {
|
||||
testTree.sqlMap().markIdDelete(); // 逻辑删除时标记ID值
|
||||
super.delete(testTree);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user