22 lines
357 B
Go
22 lines
357 B
Go
package services
|
|
|
|
import (
|
|
"errors"
|
|
"qteam/app/http/domains"
|
|
"qteam/app/models/productsmodel"
|
|
)
|
|
|
|
func ProductCreate(do domains.Product) (err error) {
|
|
m := productsmodel.Products{}
|
|
m.FromDomain(do)
|
|
count, err := productsmodel.GetInstance().Insert(m)
|
|
if err != nil {
|
|
return
|
|
}
|
|
if count == 0 {
|
|
err = errors.New("product create fail")
|
|
}
|
|
|
|
return
|
|
}
|