Line data Source code
1 : // Package profile は、ユーザー住所に関するユースケース(アプリケーションロジック)を提供します。
2 : // ドメイン層のエンティティやリポジトリを操作し、アプリケーション全体で再利用可能なビジネスフローを実装します。
3 : package profile
4 :
5 : import (
6 : "context"
7 : "log/slog"
8 : )
9 :
10 : // ListUserAddress は 認証済みユーザーの住所一覧を取得します。
11 0 : func (uc *Interactor) ListUserAddress(ctx context.Context, in ListUserAddressInput) (ListUserAddressOutput, error) {
12 0 : if in.UserID == 0 {
13 0 : return ListUserAddressOutput{}, errUnauthorized()
14 0 : }
15 0 : slog.Debug("interactor", "ctx", ctx, "in", in)
16 0 : addresses, total, err := uc.uaRepo.ListByUserIDWithSpec(ctx, in.UserID, in)
17 0 : if err != nil {
18 0 : return ListUserAddressOutput{}, err
19 0 : }
20 :
21 0 : return ListUserAddressOutput{
22 0 : Items: ToUserAddressResponses(addresses),
23 0 : Total: total,
24 0 : }, nil
25 : }
|