Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trivial. add attribute to audit #479

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading