perf(X-Pack): 组织管理-删除逻辑优化
This commit is contained in:
@@ -49,6 +49,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -84,6 +85,23 @@ public class XpackShareManage {
|
||||
.fetchFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* 按资源 ID 集合批量删除分享及其凭证(用于组织删除级联清理)
|
||||
*/
|
||||
@Transactional
|
||||
public void deleteBatchByResourceIds(Collection<Long> resourceIds) {
|
||||
if (CollectionUtils.isEmpty(resourceIds)) return;
|
||||
QXpackShare qXpackShare = QXpackShare.xpackShare;
|
||||
List<XpackShare> shares = queryFactory.selectFrom(qXpackShare)
|
||||
.where(qXpackShare.resourceId.in(resourceIds))
|
||||
.fetch();
|
||||
if (CollectionUtils.isEmpty(shares)) return;
|
||||
queryFactory.delete(qXpackShare)
|
||||
.where(qXpackShare.resourceId.in(resourceIds))
|
||||
.execute();
|
||||
shares.stream().map(XpackShare::getUuid).distinct().forEach(uuid -> shareTicketManage.deleteByShare(uuid));
|
||||
}
|
||||
|
||||
public String queryPwd(Long resourceId, Long userId) {
|
||||
QXpackShare qXpackShare = QXpackShare.xpackShare;
|
||||
XpackShare xpackShare = queryFactory.selectFrom(qXpackShare)
|
||||
|
||||
@@ -31,8 +31,10 @@ import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@@ -80,6 +82,16 @@ public class VisualizationStoreManage {
|
||||
return coreStoreRepository.exists(spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按资源 ID 集合删除收藏记录(用于组织删除级联清理)
|
||||
*/
|
||||
@Transactional
|
||||
public void deleteByResourceIds(Collection<Long> resourceIds) {
|
||||
if (CollectionUtils.isEmpty(resourceIds)) return;
|
||||
Specification<CoreStore> spec = (root, query, cb) -> root.get("resourceId").in(resourceIds);
|
||||
coreStoreRepository.delete(spec);
|
||||
}
|
||||
|
||||
@XpackInteract(value = "perFilterManage", recursion = true, invalid = true)
|
||||
public PageResult<VisualizationStoreVO> query(int pageNum, int pageSize, VisualizationWorkbranchQueryRequest request) {
|
||||
Page<StorePO> storePOIPage = proxy().queryStorePage(pageNum, pageSize, request);
|
||||
|
||||
@@ -4,4 +4,4 @@ export const searchApi = data => request.get({ url: '/org/page/tree', data })
|
||||
export const saveApi = data => request.post({ url: '/org/page/create', data })
|
||||
export const updateApi = data => request.post({ url: '/org/page/edit', data })
|
||||
export const resourceExistApi = oid => request.get({ url: '/org/resourceExist/' + oid })
|
||||
export const deleteApi = oid => request.post({ url: '/org/page/delete/' + oid })
|
||||
export const deleteApi = data => request.post({ url: '/org/page/delete', data })
|
||||
|
||||
@@ -926,6 +926,9 @@ export default {
|
||||
confirm_delete: 'Are you sure you want to delete this organization? ',
|
||||
delete_children_first:
|
||||
'Please delete the child organization first, then delete the current organization',
|
||||
delete_role_tips: 'Friendly reminder: All roles under the organization will be deleted',
|
||||
sync_delete_resource:
|
||||
'Synchronize and delete resources. This operation cannot be undone. Please confirm carefully before deleting resources.',
|
||||
confirm_content:
|
||||
'A friendly reminder: After an organization is deleted, the resources under it will be treated as free-floating resources.',
|
||||
give_up_resource: 'Give up resources and delete directly',
|
||||
|
||||
@@ -885,6 +885,8 @@ export default {
|
||||
cannot_delete: '無法刪除',
|
||||
confirm_delete: '確定刪除該組織嗎? ',
|
||||
delete_children_first: '請先刪除子組織後,再刪除目前組織',
|
||||
delete_role_tips: '友情提示:組織下的角色都將被刪除',
|
||||
sync_delete_resource: '同步刪除資源,該操作無法恢復,請在刪除資源前仔細確認',
|
||||
confirm_content: '友情提示,組織被刪除後,組織下的資源將作為遊離資源處理',
|
||||
give_up_resource: '放棄資源,直接刪除',
|
||||
move_resource_first: '先遷移資源',
|
||||
|
||||
@@ -900,6 +900,8 @@ export default {
|
||||
cannot_delete: '无法删除',
|
||||
confirm_delete: '确定删除该组织吗?',
|
||||
delete_children_first: '请先删除子组织后,再删除当前组织',
|
||||
delete_role_tips: '友情提示:组织下的角色都将被删除',
|
||||
sync_delete_resource: '同步删除资源,该操作无法恢复,请在删除资源前仔细确认',
|
||||
confirm_content: '友情提示,组织被删除后,组织下的资源将作为游离资源处理',
|
||||
give_up_resource: '放弃资源,直接删除',
|
||||
move_resource_first: '先迁移资源',
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.dataease.api.permissions.org.api;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.api.permissions.org.dto.OrgCreator;
|
||||
import io.dataease.api.permissions.org.dto.OrgDelRequest;
|
||||
import io.dataease.api.permissions.org.dto.OrgEditor;
|
||||
import io.dataease.api.permissions.org.dto.OrgLazyRequest;
|
||||
import io.dataease.api.permissions.org.vo.LazyTreeVO;
|
||||
@@ -12,8 +13,6 @@ import io.dataease.auth.DeApiPath;
|
||||
import io.dataease.auth.DePermit;
|
||||
import io.dataease.model.KeywordRequest;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -50,10 +49,9 @@ public interface OrgApi {
|
||||
void edit(@RequestBody OrgEditor editor);
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@Parameter(name = "id", description = "ID", required = true, in = ParameterIn.PATH)
|
||||
@PostMapping("/page/delete/{id}")
|
||||
@DePermit({"m:read", "#p0+':manage'"})
|
||||
void delete(@PathVariable("id") Long id);
|
||||
@PostMapping("/page/delete")
|
||||
@DePermit({"m:read", "#p0.id+':manage'"})
|
||||
void delete(@RequestBody OrgDelRequest request);
|
||||
|
||||
@Operation(summary = "查询权限内组织树")
|
||||
@PostMapping("/mounted")
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.dataease.api.permissions.org.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class OrgDelRequest implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private boolean delResource;
|
||||
}
|
||||
Reference in New Issue
Block a user