feat(REQ-2300): 写操作增加事务注解
This commit is contained in:
parent
ef36265460
commit
0c3b119631
@ -43,6 +43,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -69,6 +70,7 @@ public class DataObjectServiceImpl implements DataObjectService {
|
|||||||
private TransactionTemplate transactionTemplate;
|
private TransactionTemplate transactionTemplate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createDataObject(CreateDataObjectReq req) {
|
public Long createDataObject(CreateDataObjectReq req) {
|
||||||
// 校验
|
// 校验
|
||||||
// objectName、objectCode不能重复
|
// objectName、objectCode不能重复
|
||||||
@ -173,6 +175,7 @@ public class DataObjectServiceImpl implements DataObjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void editDataObject(EditDataObjectReq req) {
|
public void editDataObject(EditDataObjectReq req) {
|
||||||
// 对象属性名和code不能重复
|
// 对象属性名和code不能重复
|
||||||
checkObjectAttrNameOrCodeUnique(req.getAttrs());
|
checkObjectAttrNameOrCodeUnique(req.getAttrs());
|
||||||
@ -242,6 +245,7 @@ public class DataObjectServiceImpl implements DataObjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteDataObject(Long dataObjectId, Long updateBy) {
|
public void deleteDataObject(Long dataObjectId, Long updateBy) {
|
||||||
List<Long> idList = Collections.singletonList(dataObjectId);
|
List<Long> idList = Collections.singletonList(dataObjectId);
|
||||||
transactionTemplate.executeWithoutResult(status -> {
|
transactionTemplate.executeWithoutResult(status -> {
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -48,6 +49,7 @@ public class DataResourceServiceImpl implements DataResourceService {
|
|||||||
private final SaasFeatureDao saasFeatureDao;
|
private final SaasFeatureDao saasFeatureDao;
|
||||||
private final SaasFeatureDataResourceDao saasFeatureDataResourceDao;
|
private final SaasFeatureDataResourceDao saasFeatureDataResourceDao;
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void create(CreateDataResourceParam param) {
|
public void create(CreateDataResourceParam param) {
|
||||||
DataResource existDataResource = dataResourceDao.lambdaQuery()
|
DataResource existDataResource = dataResourceDao.lambdaQuery()
|
||||||
.eq(DataResource::getResourceCode, param.getResourceCode())
|
.eq(DataResource::getResourceCode, param.getResourceCode())
|
||||||
@ -72,6 +74,7 @@ public class DataResourceServiceImpl implements DataResourceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean delete(DeleteDataResourceParam param) {
|
public boolean delete(DeleteDataResourceParam param) {
|
||||||
DataResource dataResource = dataResourceDao.getById(param.getId());
|
DataResource dataResource = dataResourceDao.getById(param.getId());
|
||||||
if (Objects.nonNull(dataResource)) {
|
if (Objects.nonNull(dataResource)) {
|
||||||
@ -109,6 +112,7 @@ public class DataResourceServiceImpl implements DataResourceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean update(UpdateDataResourceParam param) {
|
public boolean update(UpdateDataResourceParam param) {
|
||||||
DataResource dataResource = new DataResource();
|
DataResource dataResource = new DataResource();
|
||||||
BeanUtils.copyProperties(param, dataResource);
|
BeanUtils.copyProperties(param, dataResource);
|
||||||
@ -116,6 +120,7 @@ public class DataResourceServiceImpl implements DataResourceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void createDataResourceSaasFeature(DataResourceSaasFeatureParam param) {
|
public void createDataResourceSaasFeature(DataResourceSaasFeatureParam param) {
|
||||||
DataResource existDataResource = dataResourceDao.lambdaQuery()
|
DataResource existDataResource = dataResourceDao.lambdaQuery()
|
||||||
.eq(DataResource::getResourceCode, param.getResourceCode())
|
.eq(DataResource::getResourceCode, param.getResourceCode())
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -75,6 +76,7 @@ public class FeatureResourceSyncServiceImpl implements FeatureResourceSyncServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void syncFromBase(ResourceSyncReq req) {
|
public void syncFromBase(ResourceSyncReq req) {
|
||||||
if (req.getIds().size() > 1) {
|
if (req.getIds().size() > 1) {
|
||||||
//超过一个异步处理
|
//超过一个异步处理
|
||||||
|
|||||||
@ -314,6 +314,7 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public PermissionPointDTO save(PermissionPointDTO dto) {
|
public PermissionPointDTO save(PermissionPointDTO dto) {
|
||||||
if (dto.getId() == null) {
|
if (dto.getId() == null) {
|
||||||
return doInsert(dto);
|
return doInsert(dto);
|
||||||
@ -431,6 +432,7 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void move(PermissionPointMoveRequest request) {
|
public void move(PermissionPointMoveRequest request) {
|
||||||
SaasFeature feature = getAndCheck(request.getPermissionId());
|
SaasFeature feature = getAndCheck(request.getPermissionId());
|
||||||
changeParent(feature, request);
|
changeParent(feature, request);
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bouncycastle.util.Integers;
|
import org.bouncycastle.util.Integers;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@ -92,6 +93,7 @@ public class ProductServiceImpl implements ProductService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ApiResult<ProductVO> add(ProductAddReq req) {
|
public ApiResult<ProductVO> add(ProductAddReq req) {
|
||||||
Optional<ProductModule> optProduct = productModuleDao.lambdaQuery()
|
Optional<ProductModule> optProduct = productModuleDao.lambdaQuery()
|
||||||
.eq(ProductModule::getProductName, req.getProductName())
|
.eq(ProductModule::getProductName, req.getProductName())
|
||||||
@ -108,6 +110,7 @@ public class ProductServiceImpl implements ProductService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ApiResult<ProductVO> update(ProductUpdateReq req) {
|
public ApiResult<ProductVO> update(ProductUpdateReq req) {
|
||||||
Optional<ProductModule> optProduct = productModuleDao.lambdaQuery()
|
Optional<ProductModule> optProduct = productModuleDao.lambdaQuery()
|
||||||
.eq(ProductModule::getProductName, req.getProductName())
|
.eq(ProductModule::getProductName, req.getProductName())
|
||||||
@ -125,6 +128,7 @@ public class ProductServiceImpl implements ProductService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ApiResult<ProductVO> delete(Long id) {
|
public ApiResult<ProductVO> delete(Long id) {
|
||||||
ProductModule productModule = productModuleDao.getById(id);
|
ProductModule productModule = productModuleDao.getById(id);
|
||||||
AssertUtil.isTrue(Objects.nonNull(productModule), "产品不存在");
|
AssertUtil.isTrue(Objects.nonNull(productModule), "产品不存在");
|
||||||
|
|||||||
@ -351,12 +351,14 @@ public class RoleUserService implements SaasRoleUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void removeWorkspaceOuAllUserRole(Long workspaceId, Long ouId) {
|
public void removeWorkspaceOuAllUserRole(Long workspaceId, Long ouId) {
|
||||||
saasRoleDao.removeWorkspaceOuAllRole(workspaceId, ouId);
|
saasRoleDao.removeWorkspaceOuAllRole(workspaceId, ouId);
|
||||||
roleUserRelationDao.removeWorkspaceOuAllUserRole(workspaceId, ouId);
|
roleUserRelationDao.removeWorkspaceOuAllUserRole(workspaceId, ouId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void grantOrUngrantWorkerLeader(GantOrUnGantaWorkerLeaderRoleReq req) {
|
public void grantOrUngrantWorkerLeader(GantOrUnGantaWorkerLeaderRoleReq req) {
|
||||||
Boolean grant = req.getGrant();
|
Boolean grant = req.getGrant();
|
||||||
// 授权
|
// 授权
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -103,6 +104,7 @@ public class SaasBasicDictServiceImpl implements SaasBasicDictService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long create(BasicDictCreateReq req) {
|
public Long create(BasicDictCreateReq req) {
|
||||||
SaasBasicDict parent = saasBasicDictDao.getById(req.getParentId());
|
SaasBasicDict parent = saasBasicDictDao.getById(req.getParentId());
|
||||||
if (Objects.isNull(parent)) {
|
if (Objects.isNull(parent)) {
|
||||||
@ -145,6 +147,7 @@ public class SaasBasicDictServiceImpl implements SaasBasicDictService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean update(BasicDictUpdateReq req) {
|
public Boolean update(BasicDictUpdateReq req) {
|
||||||
BasicDictNodeResp currentNode = getById(req.getId());
|
BasicDictNodeResp currentNode = getById(req.getId());
|
||||||
if (Objects.isNull(currentNode)) {
|
if (Objects.isNull(currentNode)) {
|
||||||
@ -166,6 +169,7 @@ public class SaasBasicDictServiceImpl implements SaasBasicDictService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean updateStauts(BasicDictUpdateStatusReq req) {
|
public Boolean updateStauts(BasicDictUpdateStatusReq req) {
|
||||||
return saasBasicDictDao.updateStatus(req);
|
return saasBasicDictDao.updateStatus(req);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -220,6 +220,7 @@ public class SaasFeatureResourceServiceImpl implements SaasFeatureResourceServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@CacheEvict(value = SaasFeatureResourceCacheService.CACHE_FEATURE_RESOURCE_TREE,allEntries = true)
|
@CacheEvict(value = SaasFeatureResourceCacheService.CACHE_FEATURE_RESOURCE_TREE,allEntries = true)
|
||||||
public void updateFeatureAuthType(Long featureId, Integer authType) {
|
public void updateFeatureAuthType(Long featureId, Integer authType) {
|
||||||
if (featureId != null && authType != null) {
|
if (featureId != null && authType != null) {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -104,6 +105,7 @@ public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long saveOrUpdate(SaasRoleGroupVO req) {
|
public Long saveOrUpdate(SaasRoleGroupVO req) {
|
||||||
SaasRoleGroup saasRoleGroup = validAndBuildGroup(req);
|
SaasRoleGroup saasRoleGroup = validAndBuildGroup(req);
|
||||||
saasRoleGroupDao.saveOrUpdate(saasRoleGroup);
|
saasRoleGroupDao.saveOrUpdate(saasRoleGroup);
|
||||||
@ -115,6 +117,7 @@ public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, S
|
|||||||
* @param ids
|
* @param ids
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void delete(List<Long> ids) {
|
public void delete(List<Long> ids) {
|
||||||
if (CollectionUtils.isEmpty(ids)) {
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user