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

정책명 업데이트 버그 수정 #461

Merged
merged 1 commit into from
Apr 30, 2024
Merged
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
14 changes: 7 additions & 7 deletions internal/usecase/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,21 +245,21 @@ func (u *PolicyUsecase) Update(ctx context.Context, organizationId string, polic
updateMap["mandatory"] = mandatory
}

if policyName != nil {
policy, err := u.repo.GetByName(ctx, organizationId, *policyName)
if err != nil {
// 정책명을 업데이트하기로 설정하였고
if policyName != nil && policy.PolicyName != *policyName {
exists, err := u.repo.ExistByName(ctx, organizationId, *policyName)

if err != nil && !errors.IsNotFound(err) {
return err
}

// 이름이 같은 정책이 존재하지만 아이디가 서로 다른 경우, 즉 다른 정책이 해당 이름 사용 중임
if policy != nil && policyId != policy.ID {
if exists {
return httpErrors.NewBadRequestError(httpErrors.DuplicateResource, "P_INVALID_POLICY_NAME", "policy name already exists")
}

// 해당 이름 사용중인 정책이 없으면 업데이트, 있으면 동일 정책이므로 업데이트 안 함
if policy == nil {
updateMap["policy_name"] = policyName
}
updateMap["policy_name"] = policyName
}

if description != nil {
Expand Down
Loading