Skip to content

Commit

Permalink
♻️ change uniqueid related program and chnage swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
iChemy committed Oct 16, 2023
1 parent 05bec26 commit 4a6e1ee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
9 changes: 5 additions & 4 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1200,15 +1200,16 @@ components:
name: relation
in: query
required: false
description: どのような関係性でユーザーと結びつけるか。|
取り得る値は、admins(ユーザーが管理者), belongs(ユーザーが所属している) |
イベントはさらに、attendees(not absent)|
値がない場合は、belongs として振る舞う
description: どのような関係性でユーザーと結びつけるか。
|取り得る値は、admins(ユーザーが管理者), belongs(ユーザーが所属している), belongs-or-admins(ユーザーが管理者または所属している)
|イベントはさらに、attendees(not absent)
|値がない場合は、belongs として振る舞う
schema:
type: string
enum:
- admins
- belongs
- belongs-or-admins
- attendees

userID:
Expand Down
19 changes: 8 additions & 11 deletions router/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,17 @@ func (h *Handlers) HandleGetMeGroupIDs(c echo.Context) error {
return judgeErrorResponse(err)
}

uniqueIDs := make(map[uuid.UUID]struct{})
allGroupIDs := append(belongingGroupIDs, adminGroupIDs...)
uniqueIDMap := make(map[uuid.UUID]struct{})

for _, id := range belongingGroupIDs {
uniqueIDs[id] = struct{}{}
}

for _, id := range adminGroupIDs {
uniqueIDs[id] = struct{}{}
}
for _, groupID := range allGroupIDs {
if _, ok := uniqueIDMap[groupID]; ok {
continue
}

for id := range uniqueIDs {
groupIDs = append(groupIDs, id)
uniqueIDMap[groupID] = struct{}{}
groupIDs = append(groupIDs, groupID)
}

}

return c.JSON(http.StatusOK, groupIDs)
Expand Down
4 changes: 2 additions & 2 deletions router/presentation/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func GetUserRelationQuery(values url.Values) UserRelation {
return RelationBelongs
case "admins":
return RelationAdmins
case "belongsoradmins":
case "belongs-or-admins":
return RelationBelongsOrAdmins
}

return RelationBelongs
return RelationBelongsOrAdmins
}

func GetExcludeEventID(values url.Values) (uuid.UUID, error) {
Expand Down

0 comments on commit 4a6e1ee

Please sign in to comment.