init: taotie-api 项目初始化
This commit is contained in:
36
repo/tenantrepo.go
Normal file
36
repo/tenantrepo.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"taotie-api/common"
|
||||
"taotie-api/model/po"
|
||||
)
|
||||
|
||||
type TenantRepo[T IEntity] struct {
|
||||
BaseRepo[T]
|
||||
}
|
||||
|
||||
func NewTenantRepo(mdb *MongoDb) *TenantRepo[*po.TTenant] {
|
||||
return &TenantRepo[*po.TTenant]{
|
||||
BaseRepo: BaseRepo[*po.TTenant]{
|
||||
mdb: mdb,
|
||||
tableName: "ttenant",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (rp *TenantRepo[T]) FindOneByTenantNo(ctx context.Context, tenantNo string) (result T, err error) {
|
||||
return rp.RawFindOne(ctx, &QueryParams{
|
||||
Where: common.Map{
|
||||
"tenantNo": tenantNo,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (rp *TenantRepo[T]) FindOneByTenantName(ctx context.Context, tenantName string) (result T, err error) {
|
||||
return rp.RawFindOne(ctx, &QueryParams{
|
||||
Where: common.Map{
|
||||
"tenantName": tenantName,
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user