Skip to content

Commit

Permalink
Merge pull request #42 from ShibeaRlz/feature/2038
Browse files Browse the repository at this point in the history
スカウトリストに合わせたレスポンスに修正
  • Loading branch information
zono0013 authored Dec 9, 2024
2 parents 806cf24 + 3ead6c2 commit fa8a3a7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
6 changes: 4 additions & 2 deletions server/domain/models/scoutList.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ type ScoutListResponse struct {
}

type DetailInfo struct {
Name string `json:"name"`
Img string `json:"img"`
Name string `json:"name"`
Img string `json:"img"`
Mem1 string `json:"mem1"`
Tags []string `json:"tags"`
}

type MessageCommunity struct {
Expand Down
2 changes: 1 addition & 1 deletion server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func main() {
authcommunityUsecase := usecase.NewAuthCommunityUseCase(communityRepo, sessionRepo, memberRepo, tagRepo)
userUsecase := usecase.NewUserUseCase(userRepo, memberRepo, tagRepo)
communityUsecase := usecase.NewCommunityUseCase(communityRepo, memberRepo, tagRepo)
scoutListUsecase := usecase.NewScoutListUsecase(scoutListRepo, userRepo, communityRepo, messageRepo)
scoutListUsecase := usecase.NewScoutListUsecase(scoutListRepo, userRepo, communityRepo, messageRepo, tagRepo, memberRepo)
eventUsecase := usecase.NewEventUsecase(eventRepo)
tagUsecase := usecase.NewTagUseCase(tagRepo)

Expand Down
24 changes: 23 additions & 1 deletion server/usecase/scoutList_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@ type IScoutListUsecase interface {
type scoutListUsecase struct {
scoutListRepo repositories.IScoutListRepository
userRepo repositories.IUserRepository
tagRepo repositories.ITagRepository
memberRepo repositories.IMemberRepository
communityRepo repositories.ICommunityRepository
messageRepo repositories.MessageRepository
}

func NewScoutListUsecase(repo repositories.IScoutListRepository, userRepo repositories.IUserRepository, communityRepo repositories.ICommunityRepository, messageRepo repositories.MessageRepository) IScoutListUsecase {
func NewScoutListUsecase(repo repositories.IScoutListRepository, userRepo repositories.IUserRepository, communityRepo repositories.ICommunityRepository, messageRepo repositories.MessageRepository, tagRepo repositories.ITagRepository, memberRepo repositories.IMemberRepository) IScoutListUsecase {
return &scoutListUsecase{
scoutListRepo: repo,
userRepo: userRepo,
communityRepo: communityRepo,
messageRepo: messageRepo,
tagRepo: tagRepo,
memberRepo: memberRepo,
}
}

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

// Mem1 の取得
mem1, err := u.memberRepo.FindByID(ctx, detail.Mem1)
if err != nil {
return nil, fmt.Errorf("failed to get unread member1 %s: %w", detail.Mem1, err)
}

// Tags の取得
tagNames := make([]string, 0, len(detail.Tags))
for _, tagID := range detail.Tags {
tag, err := u.tagRepo.FindTagByID(ctx, tagID)
if err != nil {
return nil, fmt.Errorf("failed to find tag by ID (%d): %w", tagID, err)
}
tagNames = append(tagNames, tag.Name)
}

response := models.ScoutListResponse{
ID: scoutlist.ID,
Status: scoutlist.Status,
Expand All @@ -84,6 +104,8 @@ func (u *scoutListUsecase) GetWithCommunityDetails(ctx context.Context, UserUUID
DetailInfo: models.DetailInfo{
Name: detail.Name,
Img: detail.Img,
Mem1: mem1.Name,
Tags: tagNames,
},
}
responses = append(responses, response)
Expand Down

0 comments on commit fa8a3a7

Please sign in to comment.