Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/issue 400 #461

Merged
merged 4 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 として振る舞う
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description: |だけで複数行かけるのでそれでいいはず

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

イベントはさらに、、の行言ってること分かりにくいけど思い出したら別PRで書き換えときます

schema:
type: string
enum:
- admins
- belongs
- belongs-or-admins
- attendees

userID:
Expand Down
21 changes: 21 additions & 0 deletions router/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,27 @@ func (h *Handlers) HandleGetMeGroupIDs(c echo.Context) error {
if err != nil {
return judgeErrorResponse(err)
}
case presentation.RelationBelongsOrAdmins:
belongingGroupIDs, err := h.Repo.GetUserBelongingGroupIDs(userID, getConinfo(c))
if err != nil {
return judgeErrorResponse(err)
}
adminGroupIDs, err := h.Repo.GetUserAdminGroupIDs(userID)
if err != nil {
return judgeErrorResponse(err)
}

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

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

uniqueIDMap[groupID] = struct{}{}
groupIDs = append(groupIDs, groupID)
}
}

return c.JSON(http.StatusOK, groupIDs)
Expand Down
9 changes: 6 additions & 3 deletions router/presentation/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ func GetTiemRange(values url.Values) (start time.Time, end time.Time, err error)
type UserRelation int

const (
RelationBelongs = iota
RelationAdmins = iota
RelationBelongs = iota
RelationAdmins = iota
RelationBelongsOrAdmins = iota
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RelationBelongs = iota
RelationAdmins = iota
RelationBelongsOrAdmins = iota
RelationBelongs UserRelation = iota
RelationAdmins
RelationBelongsOrAdmins

かも?今のままだとuntyped intとかになってそう

)

func GetUserRelationQuery(values url.Values) UserRelation {
Expand All @@ -38,9 +39,11 @@ func GetUserRelationQuery(values url.Values) UserRelation {
return RelationBelongs
case "admins":
return RelationAdmins
case "belongs-or-admins":
return RelationBelongsOrAdmins
}

return RelationBelongs
return RelationBelongsOrAdmins
}

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