MSP-5186 Check app duplicate name before check req.Id
This commit is contained in:
1 parent
1818bf8b45
commit
141650417a
1 file changed
+4
-8
@@ -161,11 +161,11 @@ func (s Application) CreateUpdate(ctx context.Context, req domain.ApplicationCre
|
||||
return nil, errors.WithMessage(err, "get service by id")
|
||||
}
|
||||
|
||||
if req.Id == 0 {
|
||||
if existed != nil {
|
||||
return nil, domain.ErrApplicationDuplicateName
|
||||
}
|
||||
if existed != nil && (existed.Id != req.Id || req.Id == 0) {
|
||||
return nil, domain.ErrApplicationDuplicateName
|
||||
}
|
||||
|
||||
if req.Id == 0 {
|
||||
_, err = s.appRepo.GetApplicationByNameAndAppGroupId(ctx, req.Name, req.ServiceId)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get application by name and service_id")
|
||||
@@ -189,10 +189,6 @@ func (s Application) CreateUpdate(ctx context.Context, req domain.ApplicationCre
|
||||
return result[0], nil
|
||||
}
|
||||
|
||||
if existed != nil && existed.Id != req.Id {
|
||||
return nil, domain.ErrApplicationDuplicateName
|
||||
}
|
||||
|
||||
_, err = s.appRepo.GetApplicationById(ctx, req.Id)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get application by id")
|
||||
|
||||
Reference in new issue
Block a user