feat article添加create

This commit is contained in:
timerzz 2024-09-11 17:51:59 +08:00
parent 6fd11575b9
commit cfd5a77e71

View File

@ -9,6 +9,7 @@ import (
) )
type ArticleApi interface { type ArticleApi interface {
Create(article *v2.Article) error
Upsert(article v2.Article) error Upsert(article v2.Article) error
Update(article v2.Article, selects ...string) error Update(article v2.Article, selects ...string) error
Find(query *FindArticleQuery) (articles []v2.Article, err error) Find(query *FindArticleQuery) (articles []v2.Article, err error)
@ -27,6 +28,10 @@ func NewArticleApi(db *gorm.DB) ArticleApi {
} }
} }
func (a *articleApi) Create(article *v2.Article) error {
return a.db.Create(article).Error
}
// Upsert 插入或者更新商品 // Upsert 插入或者更新商品
func (a *articleApi) Upsert(article v2.Article) error { func (a *articleApi) Upsert(article v2.Article) error {
return a.db.Transaction(func(tx *gorm.DB) error { return a.db.Transaction(func(tx *gorm.DB) error {