更新结构
This commit is contained in:
29
server/internal/articlemodel/articlemodel.go
Normal file
29
server/internal/articlemodel/articlemodel.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package articlemodel
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ ArticleModel = (*customArticleModel)(nil)
|
||||
|
||||
type (
|
||||
// ArticleModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customArticleModel.
|
||||
ArticleModel interface {
|
||||
articleModel
|
||||
withSession(session sqlx.Session) ArticleModel
|
||||
}
|
||||
|
||||
customArticleModel struct {
|
||||
*defaultArticleModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewArticleModel returns a model for the database table.
|
||||
func NewArticleModel(conn sqlx.SqlConn) ArticleModel {
|
||||
return &customArticleModel{
|
||||
defaultArticleModel: newArticleModel(conn),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customArticleModel) withSession(session sqlx.Session) ArticleModel {
|
||||
return NewArticleModel(sqlx.NewSqlConnFromSession(session))
|
||||
}
|
||||
Reference in New Issue
Block a user