MSP-5186 Check app duplicate name before check req.Id

This commit is contained in:
Синельник Тимур Романович committed 2025-04-02 09:54:25 +03:00
1 parent 1818bf8b45
commit 141650417a
1 file changed
+4 -8
+4 -8
View File
@@ -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")