40 lines
730 B
Go
40 lines
730 B
Go
package repo
|
|
|
|
import (
|
|
"context"
|
|
"taotie-api/common"
|
|
"taotie-api/model/po"
|
|
)
|
|
|
|
type UserRepo[T IEntity] struct {
|
|
BaseRepo[T]
|
|
}
|
|
|
|
func NewUserRepo(mdb *MongoDb) *UserRepo[*po.TUser] {
|
|
return &UserRepo[*po.TUser]{
|
|
BaseRepo[*po.TUser]{
|
|
mdb: mdb,
|
|
tableName: "tuser",
|
|
},
|
|
}
|
|
}
|
|
|
|
func (rp *UserRepo[T]) FindOneByTenantIdAndUserName(ctx context.Context, tenantId string, userName string) (result T, err error) {
|
|
result, err = rp.RawFindOne(ctx, &QueryParams{
|
|
Where: common.Map{
|
|
"tenantId": tenantId,
|
|
"userName": userName,
|
|
},
|
|
})
|
|
|
|
if err != nil {
|
|
return result, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
func (rp *UserRepo[T]) Update(ctx context.Context, qp *QueryParams, setData map[string]any) error {
|
|
return nil
|
|
}
|