40 lines
901 B
Go
40 lines
901 B
Go
package friend
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.Friend_Search_Req) (chk map[string]interface{}, code comm.ErrorCode) {
|
|
if req.NickName == "" {
|
|
code = comm.ErrorCode{Code: pb.ErrorCode_FriendSearchNameEmpty}
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
//搜索
|
|
func (this *apiComp) Search(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Search_Req) (code pb.ErrorCode) {
|
|
var (
|
|
rsp *pb.Friend_Search_Rsp
|
|
friend *pb.FriendBase
|
|
)
|
|
defer func() {
|
|
if code == pb.ErrorCode_Success {
|
|
rsp = &pb.Friend_Search_Rsp{
|
|
Friend: friend,
|
|
}
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_Search, rsp)
|
|
}()
|
|
|
|
user := this.module.modelFriend.Frined_FindCond(req.NickName)
|
|
if user != nil {
|
|
friend = &pb.FriendBase{
|
|
UserId: user.Uid,
|
|
NickName: user.Name,
|
|
}
|
|
}
|
|
return
|
|
}
|