Skip to content

Commit 3ead6c2

Browse files
zono0013zono0013
zono0013
authored and
zono0013
committed
スカウトリストに合わせたレスポンスに修正
1 parent 5d19f74 commit 3ead6c2

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

server/domain/models/scoutList.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ type ScoutListResponse struct {
2424
}
2525

2626
type DetailInfo struct {
27-
Name string `json:"name"`
28-
Img string `json:"img"`
27+
Name string `json:"name"`
28+
Img string `json:"img"`
29+
Mem1 string `json:"mem1"`
30+
Tags []string `json:"tags"`
2931
}
3032

3133
type MessageCommunity struct {

server/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func main() {
6969
authcommunityUsecase := usecase.NewAuthCommunityUseCase(communityRepo, sessionRepo, memberRepo, tagRepo)
7070
userUsecase := usecase.NewUserUseCase(userRepo, memberRepo, tagRepo)
7171
communityUsecase := usecase.NewCommunityUseCase(communityRepo, memberRepo, tagRepo)
72-
scoutListUsecase := usecase.NewScoutListUsecase(scoutListRepo, userRepo, communityRepo, messageRepo)
72+
scoutListUsecase := usecase.NewScoutListUsecase(scoutListRepo, userRepo, communityRepo, messageRepo, tagRepo, memberRepo)
7373
eventUsecase := usecase.NewEventUsecase(eventRepo)
7474
tagUsecase := usecase.NewTagUseCase(tagRepo)
7575

server/usecase/scoutList_usecase.go

+23-1
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ type IScoutListUsecase interface {
2121
type scoutListUsecase struct {
2222
scoutListRepo repositories.IScoutListRepository
2323
userRepo repositories.IUserRepository
24+
tagRepo repositories.ITagRepository
25+
memberRepo repositories.IMemberRepository
2426
communityRepo repositories.ICommunityRepository
2527
messageRepo repositories.MessageRepository
2628
}
2729

28-
func NewScoutListUsecase(repo repositories.IScoutListRepository, userRepo repositories.IUserRepository, communityRepo repositories.ICommunityRepository, messageRepo repositories.MessageRepository) IScoutListUsecase {
30+
func NewScoutListUsecase(repo repositories.IScoutListRepository, userRepo repositories.IUserRepository, communityRepo repositories.ICommunityRepository, messageRepo repositories.MessageRepository, tagRepo repositories.ITagRepository, memberRepo repositories.IMemberRepository) IScoutListUsecase {
2931
return &scoutListUsecase{
3032
scoutListRepo: repo,
3133
userRepo: userRepo,
3234
communityRepo: communityRepo,
3335
messageRepo: messageRepo,
36+
tagRepo: tagRepo,
37+
memberRepo: memberRepo,
3438
}
3539
}
3640

@@ -76,6 +80,22 @@ func (u *scoutListUsecase) GetWithCommunityDetails(ctx context.Context, UserUUID
7680
return nil, fmt.Errorf("failed to get unread count for user %s: %w", scoutlist.User_UUID.String(), err)
7781
}
7882

83+
// Mem1 の取得
84+
mem1, err := u.memberRepo.FindByID(ctx, detail.Mem1)
85+
if err != nil {
86+
return nil, fmt.Errorf("failed to get unread member1 %s: %w", detail.Mem1, err)
87+
}
88+
89+
// Tags の取得
90+
tagNames := make([]string, 0, len(detail.Tags))
91+
for _, tagID := range detail.Tags {
92+
tag, err := u.tagRepo.FindTagByID(ctx, tagID)
93+
if err != nil {
94+
return nil, fmt.Errorf("failed to find tag by ID (%d): %w", tagID, err)
95+
}
96+
tagNames = append(tagNames, tag.Name)
97+
}
98+
7999
response := models.ScoutListResponse{
80100
ID: scoutlist.ID,
81101
Status: scoutlist.Status,
@@ -84,6 +104,8 @@ func (u *scoutListUsecase) GetWithCommunityDetails(ctx context.Context, UserUUID
84104
DetailInfo: models.DetailInfo{
85105
Name: detail.Name,
86106
Img: detail.Img,
107+
Mem1: mem1.Name,
108+
Tags: tagNames,
87109
},
88110
}
89111
responses = append(responses, response)

0 commit comments

Comments
 (0)