Skip to content

Commit

Permalink
Merge pull request #479 from openinfradev/audit1
Browse files Browse the repository at this point in the history
trivial. add attribute to audit
  • Loading branch information
cho4036 authored May 7, 2024
2 parents 443453b + 9148fa6 commit 706b1aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions internal/delivery/http/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request) {
Description: errorResponse.Text(),
ClientIP: audit.GetClientIpAddress(w, r),
UserId: nil,
UserAccountId: input.AccountId,
})
log.Errorf(r.Context(), "error is :%s(%T)", err.Error(), err)
ErrorJSON(w, r, err)
Expand Down
17 changes: 13 additions & 4 deletions internal/usecase/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,27 @@ type IAuditUsecase interface {
}

type AuditUsecase struct {
repo repository.IAuditRepository
userRepo repository.IUserRepository
repo repository.IAuditRepository
userRepo repository.IUserRepository
organizationRepo repository.IOrganizationRepository
}

func NewAuditUsecase(r repository.Repository) IAuditUsecase {
return &AuditUsecase{
repo: r.Audit,
userRepo: r.User,
repo: r.Audit,
userRepo: r.User,
organizationRepo: r.Organization,
}
}

func (u *AuditUsecase) Create(ctx context.Context, dto model.Audit) (auditId uuid.UUID, err error) {
if dto.OrganizationId != "" {
organization, err := u.organizationRepo.Get(ctx, dto.OrganizationId)
if err == nil {
dto.OrganizationName = organization.Name
}
}

if dto.UserId != nil && *dto.UserId != uuid.Nil {
user, err := u.userRepo.GetByUuid(ctx, *dto.UserId)
if err != nil {
Expand Down

0 comments on commit 706b1aa

Please sign in to comment.