update openapi and add the exists_in_database flag to get-product
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package productDescriptionRepo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/db"
|
||||
@@ -8,6 +9,7 @@ import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model/dbmodel"
|
||||
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
||||
"github.com/WinterYukky/gorm-extra-clause-plugin/exclause"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UIProductDescriptionRepo interface {
|
||||
@@ -35,8 +37,14 @@ func (r *ProductDescriptionRepo) GetProductDescription(productID uint, productid
|
||||
IDLang: int32(productid_lang),
|
||||
}).
|
||||
First(&ProductDescription).Error
|
||||
if err != nil {
|
||||
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// handle "not found" case only
|
||||
ProductDescription.ExistsInDatabse = false
|
||||
} else if err != nil {
|
||||
return nil, fmt.Errorf("database error: %w", err)
|
||||
} else {
|
||||
ProductDescription.ExistsInDatabse = true
|
||||
}
|
||||
|
||||
return &ProductDescription, nil
|
||||
|
||||
Reference in New Issue
Block a user