用DDD分项目模块

This commit is contained in:
2025-10-05 01:46:48 +08:00
parent 48461b9c49
commit 28acc5104c
41 changed files with 1138 additions and 17 deletions

View File

@@ -0,0 +1,29 @@
package model
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))
}