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

tks 템플릿 생성시 DB 에러 픽스 #379

Merged
merged 2 commits into from
Apr 15, 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
9 changes: 3 additions & 6 deletions internal/usecase/policy-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,14 @@ func (u *PolicyTemplateUsecase) Create(ctx context.Context, dto model.PolicyTemp
dto.Mandatory = false
dto.OrganizationId = nil

dto.PermittedOrganizations = make([]model.Organization, len(dto.PermittedOrganizationIds))
for i, organizationId := range dto.PermittedOrganizationIds {

organization, err := u.organizationRepo.Get(ctx, organizationId)
for _, organizationId := range dto.PermittedOrganizationIds {
_, err := u.organizationRepo.Get(ctx, organizationId)
if err != nil {
return uuid.Nil, httpErrors.NewBadRequestError(fmt.Errorf("invalid organizationId"), "C_INVALID_ORGANIZATION_ID", "")
}
dto.PermittedOrganizations[i] = organization
}
} else {
dto.PermittedOrganizations = make([]model.Organization, 0)
dto.PermittedOrganizationIds = make([]string, 0)
}

userId := user.GetUserId()
Expand Down
4 changes: 3 additions & 1 deletion internal/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ func validatePascalCase(fl validator.FieldLevel) bool {
}

func validateResourceName(fl validator.FieldLevel) bool {
// 정책 리소스 이름을 지정하지 않으면 지정하기 때문에 유효함
// 다른 리소스 이름을 처리할 때에는 분리 필요
if fl.Field().String() == "" {
return false
return true
}

r, _ := regexp.Compile(REGEX_RESOURCE_NAME)
Expand Down
Loading