some fixes
This commit is contained in:
parent
c1e8922968
commit
9fe21b4b78
3 changed files with 60 additions and 30 deletions
|
|
@ -49,8 +49,37 @@ func (s *service) createMerch(ctx context.Context, userId int64, payload *newMer
|
|||
return s.repo.createMerch(ctx, newMerch, merchExtra)
|
||||
}
|
||||
|
||||
func (s *service) getMany(ctx context.Context, userId int64) ([]merchDTO, error) {
|
||||
return s.repo.getMany(ctx, userId)
|
||||
func (s *service) getMany(ctx context.Context, userId int64) ([]ListResponse, error) {
|
||||
allUserMerch, err := s.repo.getMany(ctx, userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(allUserMerch) == 0 || allUserMerch == nil {
|
||||
logWarn(serviceLogHeader, "User has no merch records")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
ids := make([]int64, 0, len(allUserMerch))
|
||||
for _, m := range allUserMerch {
|
||||
ids = append(ids, m.Id)
|
||||
}
|
||||
|
||||
cardLabels, err := s.repo.getManyAttachedLabelsByList(ctx, userId, ids)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var response []ListResponse
|
||||
for _, m := range allUserMerch {
|
||||
response = append(response, ListResponse{
|
||||
MerchUuid: m.MerchUuid,
|
||||
Name: m.Name,
|
||||
Labels: cardLabels[m.Id],
|
||||
})
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (s *service) updateMerch(ctx context.Context, userId int64, payload *updateMerchDTO) (*merchDTO, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue