删除应用组并删除关联关系

pull/49/head
shao1121353141 1 year ago
parent 7c88c7d6af
commit 4c80f8023d

@ -55,7 +55,7 @@ public interface AppGroupAssociationRepository extends
void deleteByGroupIdAndAppId(@Param("groupId") Long groupId, @Param("appId") Long appId); void deleteByGroupIdAndAppId(@Param("groupId") Long groupId, @Param("appId") Long appId);
/** /**
* * ID
* *
* @param appId {@link Long} * @param appId {@link Long}
* @return {@link Boolean} * @return {@link Boolean}
@ -66,6 +66,19 @@ public interface AppGroupAssociationRepository extends
+ " WHERE app_id = :appId", nativeQuery = true) + " WHERE app_id = :appId", nativeQuery = true)
void deleteAllByAppId(@Param(value = "appId") Long appId); void deleteAllByAppId(@Param(value = "appId") Long appId);
/**
* ID
*
* @param groupId {@link Long}
* @return {@link Boolean}
*/
@Modifying
@Transactional(rollbackFor = Exception.class)
@Query(value = "UPDATE app_group_association SET " + SOFT_DELETE_SET
+ " WHERE group_id = :groupId", nativeQuery = true)
void deleteAllByGroupId(@Param(value = "groupId") Long groupId);
/** /**
* ID * ID
* *

@ -26,7 +26,6 @@ import org.mapstruct.Mapping;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import cn.topiam.employee.application.ApplicationService; import cn.topiam.employee.application.ApplicationService;
import cn.topiam.employee.application.ApplicationServiceLoader; import cn.topiam.employee.application.ApplicationServiceLoader;
import cn.topiam.employee.common.entity.app.AppEntity; import cn.topiam.employee.common.entity.app.AppEntity;

@ -125,6 +125,7 @@ public class AppGroupServiceImpl implements AppGroupService {
public boolean deleteAppGroup(Long id) { public boolean deleteAppGroup(Long id) {
appGroupRequireNonNull(id); appGroupRequireNonNull(id);
appGroupRepository.deleteById(id); appGroupRepository.deleteById(id);
appGroupAssociationRepository.deleteAllByGroupId(id);
AuditContext AuditContext
.setTarget(Target.builder().id(id.toString()).type(TargetType.APP_GROUP).build()); .setTarget(Target.builder().id(id.toString()).type(TargetType.APP_GROUP).build());
return true; return true;

Loading…
Cancel
Save