v2
This commit is contained in:
46
internal/erpserver/biz/biz.go
Normal file
46
internal/erpserver/biz/biz.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
db "management/internal/db/sqlc"
|
||||
commonv1 "management/internal/erpserver/biz/v1/common"
|
||||
systemv1 "management/internal/erpserver/biz/v1/system"
|
||||
"management/internal/pkg/redis"
|
||||
"management/internal/pkg/session"
|
||||
)
|
||||
|
||||
// IBiz 定义了业务层需要实现的方法.
|
||||
type IBiz interface {
|
||||
// 获取公共业务接口.
|
||||
CommonV1() commonv1.CommonBiz
|
||||
// 获取系统业务接口.
|
||||
SystemV1() systemv1.SystemBiz
|
||||
}
|
||||
|
||||
// biz 是 IBiz 的一个具体实现.
|
||||
type biz struct {
|
||||
store db.Store
|
||||
redis redis.IRedis
|
||||
session session.ISession
|
||||
}
|
||||
|
||||
// 确保 biz 实现了 IBiz 接口.
|
||||
var _ IBiz = (*biz)(nil)
|
||||
|
||||
// NewBiz 创建一个 IBiz 类型的实例.
|
||||
func NewBiz(store db.Store, redis redis.IRedis, session session.ISession) *biz {
|
||||
return &biz{
|
||||
store: store,
|
||||
redis: redis,
|
||||
session: session,
|
||||
}
|
||||
}
|
||||
|
||||
// CommonV1 返回一个实现了 CommonBiz 接口的实例.
|
||||
func (b *biz) CommonV1() commonv1.CommonBiz {
|
||||
return commonv1.New()
|
||||
}
|
||||
|
||||
// SystemV1 返回一个实现了 SystemBiz 接口的实例.
|
||||
func (b *biz) SystemV1() systemv1.SystemBiz {
|
||||
return systemv1.New(b.store, b.redis, b.session)
|
||||
}
|
||||
Reference in New Issue
Block a user