Line data Source code
1 : // Package license は 資格・免許 に関するユースケース(アプリケーションロジック)を提供します
2 : // ドメイン層のエンティティやリポジトリを操作し、アプリケーション全体で利用可能なビジネスフローを実装します
3 : package license
4 :
5 : import (
6 : "context"
7 :
8 : "resume/internal/domain/entity"
9 : )
10 :
11 : // ListUserLicense は ユーザーの資格・免許 を 取得 します
12 : func (uc *Interactor) ListUserLicense(
13 : ctx context.Context,
14 : in ListUserLicenseInput,
15 0 : ) (ListUserLicenseOutput, error) {
16 0 : if in.UserID == 0 {
17 0 : return ListUserLicenseOutput{}, errUnauthorized()
18 0 : }
19 :
20 0 : var licenses []*entity.UserLicense
21 0 : err := uc.tx.Do(ctx, func(txCtx context.Context) error {
22 0 : var err error
23 0 : licenses, err = uc.ulRepo.ListByUserID(txCtx, in.UserID)
24 0 : if err != nil {
25 0 : return err
26 0 : }
27 0 : return nil
28 : })
29 :
30 0 : if err != nil {
31 0 : return ListUserLicenseOutput{}, err
32 0 : }
33 :
34 0 : return ListUserLicenseOutput{
35 0 : Items: ToUserLicenseListResponse(licenses),
36 0 : }, nil
37 : }
|