38 lines
828 B
Go
38 lines
828 B
Go
package friend
|
|
|
|
import (
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
)
|
|
|
|
const (
|
|
TableFriend core.SqlTable = "friend"
|
|
TableUser core.SqlTable = "user" //用户表
|
|
)
|
|
|
|
type ModelFriend struct {
|
|
modules.MCompModel
|
|
}
|
|
|
|
func (this *ModelFriend) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.TableName = string(TableFriend)
|
|
return
|
|
}
|
|
|
|
func (this *ModelFriend) Frined_FindCond(nickName string) *pb.DBUser {
|
|
var user *pb.DBUser
|
|
err := this.DB.FindOne(TableUser, bson.M{
|
|
"name": nickName,
|
|
}).Decode(&user)
|
|
if err != nil {
|
|
log.Errorf("findCond err:%v", err)
|
|
return nil
|
|
}
|
|
return user
|
|
}
|