Line data Source code
1 : // Package license は 資格・免許 に関するユースケース(アプリケーションロジック)を提供します
2 : // ドメイン層のエンティティやリポジトリを操作し、アプリケーション全体で利用可能なビジネスフローを実装します
3 : package license
4 :
5 : import (
6 : "context"
7 :
8 : "resume/internal/domain/entity"
9 : "resume/internal/shared/apperr"
10 : )
11 :
12 : // DetailUserLicense は ユーザーの資格・免許 を 取得 します
13 : func (uc *Interactor) DetailUserLicense(
14 : ctx context.Context,
15 : in DetailUserLicenseInput,
16 0 : ) (DetailUserLicenseOutput, error) {
17 0 : var license *entity.UserLicense
18 0 : err := uc.tx.Do(ctx, func(txCtx context.Context) error {
19 0 : var err error
20 0 : license, err = uc.ulRepo.FindByIDAndUserID(txCtx, in.ID, in.UserID)
21 0 : if err != nil {
22 0 : return err
23 0 : }
24 0 : if license == nil {
25 0 : return apperr.New(
26 0 : apperr.CodeNotFound,
27 0 : "user license not found",
28 0 : map[string]any{
29 0 : "id": in.ID,
30 0 : "user_id": in.UserID,
31 0 : },
32 0 : )
33 0 : }
34 0 : return nil
35 : })
36 :
37 0 : if err != nil {
38 0 : return DetailUserLicenseOutput{}, err
39 0 : }
40 :
41 0 : return DetailUserLicenseOutput{
42 0 : ID: license.ID,
43 0 : UserID: license.UserID,
44 0 : Name: license.Name,
45 0 : EventDate: license.EventDate,
46 0 : SortOrder: license.SortOrder,
47 0 : CreatedAt: license.CreatedAt,
48 0 : UpdatedAt: license.UpdatedAt,
49 0 : }, nil
50 : }
|