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