更新结构

This commit is contained in:
2025-10-04 22:35:53 +08:00
parent f5c3b26479
commit 48461b9c49
34 changed files with 251 additions and 21 deletions

View 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))
}