Skip to content

Commit

Permalink
fix: 修复自己看不到自己隐藏的作业集的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
dragove committed Mar 22, 2024
1 parent 96fb938 commit c8d1969
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CopilotSetController(
@ApiResponse(description = "作业集id")
@PostMapping("/query")
fun querySets(@RequestBody req: @Valid CopilotSetQuery): MaaResult<CopilotSetPageRes> {
return success(service.query(req))
return success(service.query(req, helper.obtainUserId()))
}

@Operation(summary = "查询作业集列表")
Expand Down
10 changes: 7 additions & 3 deletions src/main/kotlin/plus/maa/backend/service/CopilotSetService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,16 @@ class CopilotSetService(
repository.save(copilotSet)
}

fun query(req: CopilotSetQuery): CopilotSetPageRes {
fun query(req: CopilotSetQuery, userId: String?): CopilotSetPageRes {
val pageRequest = PageRequest.of(req.page - 1, req.limit, defaultSort)

val criteria = Criteria.where("status").`is`(CopilotSetStatus.PUBLIC)
val query = Query.query(
Criteria.where("status").`is`(CopilotSetStatus.PUBLIC).and("delete")
.`is`(false)
if (userId.isNullOrBlank()) {
criteria
} else {
Criteria().orOperator(criteria, Criteria.where("creatorId").`is`(userId))
}.and("delete").`is`(false)
).with(pageRequest)
if (!req.copilotIds.isNullOrEmpty()) {
query.addCriteria(Criteria.where("copilotIds").all(req.copilotIds)).with(pageRequest)
Expand Down

0 comments on commit c8d1969

Please sign in to comment.