LCOV - code coverage report
Current view: top level - usecase/contact - update_user_contact_interactor.go Coverage Total Hit
Test: coverage.lcov Lines: 0.0 % 75 0
Test Date: 2026-04-14 06:42:22 Functions: - 0 0

            Line data    Source code
       1              : package contact
       2              : 
       3              : import (
       4              :         "context"
       5              : 
       6              :         "resume/internal/domain/entity"
       7              :         "resume/internal/shared/apperr"
       8              :         "resume/internal/shared/valerr"
       9              : )
      10              : 
      11              : // UpdateUserContact は 連絡先情報 を 更新 します
      12              : func (uc *Interactor) UpdateUserContact(
      13              :         ctx context.Context,
      14              :         in UpdateUserContactInput,
      15            0 : ) (UpdateUserContactOutput, error) {
      16            0 :         var updated *entity.UserContact
      17            0 : 
      18            0 :         err := uc.tx.Do(ctx, func(txCtx context.Context) error {
      19            0 : 
      20            0 :                 current, err := uc.ucRepo.FindByID(txCtx, in.ID)
      21            0 :                 if err != nil {
      22            0 :                         return err
      23            0 :                 }
      24              : 
      25            0 :                 if current == nil {
      26            0 :                         ve := valerr.New()
      27            0 :                         ve.Add(
      28            0 :                                 "domain.userContact.ID",
      29            0 :                                 "validation.rules.invalid",
      30            0 :                                 map[string]any{
      31            0 :                                         "field": "domain.userContact.ID",
      32            0 :                                 },
      33            0 :                         )
      34            0 :                         return apperr.New(
      35            0 :                                 apperr.CodeUnprocessable,
      36            0 :                                 "The request contains semantically invalid data.",
      37            0 :                                 ve.ToDetails(),
      38            0 :                         )
      39            0 :                 }
      40              : 
      41            0 :                 if current.UserID != in.UserID {
      42            0 :                         ve := valerr.New()
      43            0 :                         ve.Add(
      44            0 :                                 "domain.userContact.userId",
      45            0 :                                 "validation.rules.invalid",
      46            0 :                                 map[string]any{
      47            0 :                                         "field": "domain.userContact.userId",
      48            0 :                                 },
      49            0 :                         )
      50            0 :                         return apperr.New(
      51            0 :                                 apperr.CodeUnprocessable,
      52            0 :                                 "The request contains semantically invalid data.",
      53            0 :                                 ve.ToDetails(),
      54            0 :                         )
      55            0 :                 }
      56              : 
      57            0 :                 current.RelationshipTypeID = in.RelationshipTypeID
      58            0 :                 current.DisplayName = in.DisplayName
      59            0 :                 current.Email = in.Email
      60            0 :                 current.Phone = in.Phone
      61            0 :                 current.Note = in.Note
      62            0 : 
      63            0 :                 // NOTE: 一意制約のある 続柄ID の整合確認
      64            0 :                 if uc.userContactService.CheckDuplicateRelationship(txCtx, current) != nil {
      65            0 :                         ve := valerr.New()
      66            0 :                         ve.Add(
      67            0 :                                 "domain.userContact.relationshipTypeId",
      68            0 :                                 "validation.rules.unique",
      69            0 :                                 map[string]any{
      70            0 :                                         "field": "domain.userContact.relationshipTypeId.label",
      71            0 :                                         "value": in.RelationshipTypeID,
      72            0 :                                 },
      73            0 :                         )
      74            0 :                         return apperr.New(
      75            0 :                                 apperr.CodeUnprocessable,
      76            0 :                                 "The request contains semantically invalid data.",
      77            0 :                                 ve.ToDetails(),
      78            0 :                         )
      79            0 :                 }
      80              : 
      81            0 :                 res, err := uc.ucRepo.Update(txCtx, current)
      82            0 :                 if err != nil {
      83            0 :                         return err
      84            0 :                 }
      85              : 
      86            0 :                 updated = res
      87            0 : 
      88            0 :                 return nil
      89              :         })
      90            0 :         if err != nil {
      91            0 :                 return UpdateUserContactOutput{}, err
      92            0 :         }
      93              : 
      94            0 :         return UpdateUserContactOutput{
      95            0 :                 ID: updated.ID,
      96            0 :         }, nil
      97              : }
        

Generated by: LCOV version 2.3.1-1