Skip to content

Commit

Permalink
feat: 节点清理节点支持指定清理指定目录 #1405 (#1408)
Browse files Browse the repository at this point in the history
* feat: 节点清理节点支持指定清理指定目录 #1405

* feat: 代码格式调整 #1405
  • Loading branch information
zacYL authored Nov 9, 2023
1 parent 57da2f6 commit d9833dc
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ class UserNodeController(
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) date: LocalDateTime
): Response<NodeDeleteResult> {
return ResponseBuilder.success(
nodeService.deleteBeforeDate(artifactInfo.projectId, artifactInfo.repoName, date, userId)
nodeService.deleteBeforeDate(
artifactInfo.projectId, artifactInfo.repoName,
date, userId, artifactInfo.getArtifactFullPath()
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@ interface NodeDeleteOperation {
/**
* 根据创建时间删除[date]之前的历史数据
*/
fun deleteBeforeDate(projectId: String, repoName: String, date: LocalDateTime, operator: String): NodeDeleteResult
fun deleteBeforeDate(
projectId: String, repoName: String,
date: LocalDateTime, operator: String, path: String
): NodeDeleteResult
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ open class NodeDeleteSupport(
projectId: String,
repoName: String,
date: LocalDateTime,
operator: String
operator: String,
path: String
): NodeDeleteResult {
val option = NodeListOption(includeFolder = false, deep = true)
val criteria = NodeQueryHelper.nodeListCriteria(projectId, repoName, PathUtils.ROOT, option)
val criteria = NodeQueryHelper.nodeListCriteria(projectId, repoName, path, option)
.and(TNode::createdDate).lt(date)
val query = Query(criteria)
return delete(query, operator, criteria, projectId, repoName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ class NodeServiceImpl(
projectId: String,
repoName: String,
date: LocalDateTime,
operator: String
operator: String,
path: String
): NodeDeleteResult {
return NodeDeleteSupport(this).deleteBeforeDate(projectId, repoName, date, operator)
return NodeDeleteSupport(this).deleteBeforeDate(projectId, repoName, date, operator, path)
}

@Transactional(rollbackFor = [Throwable::class])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ class CommitEdgeCenterNodeDeleteSupport(
projectId: String,
repoName: String,
date: LocalDateTime,
operator: String
operator: String,
path: String
): NodeDeleteResult {
var deletedSize = 0L
var deletedNum = 0L
val option = NodeListOption(includeFolder = false, deep = true)
val criteria = NodeQueryHelper.nodeListCriteria(projectId, repoName, PathUtils.ROOT, option)
val criteria = NodeQueryHelper.nodeListCriteria(projectId, repoName, path, option)
.and(TNode::createdDate).lt(date)
val pageSize = 1
var queryCount: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,15 @@ class CommitEdgeCenterNodeServiceImpl(
projectId: String,
repoName: String,
date: LocalDateTime,
operator: String
operator: String,
path: String
): NodeDeleteResult {
return CommitEdgeCenterNodeDeleteSupport(this, clusterProperties).deleteBeforeDate(
projectId,
repoName,
date,
operator
operator,
path
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ class EdgeNodeServiceImpl(
projectId: String,
repoName: String,
date: LocalDateTime,
operator: String
operator: String,
path: String
): NodeDeleteResult {
return NodeDeleteSupport(this).deleteBeforeDate(projectId, repoName, date, operator)
return NodeDeleteSupport(this).deleteBeforeDate(projectId, repoName, date, operator, path)
}

@Transactional(rollbackFor = [Throwable::class])
Expand Down

0 comments on commit d9833dc

Please sign in to comment.