go_dreamfactory/modules/sociaty/api_cross_search.go
2023-06-06 10:11:23 +08:00

37 lines
1.0 KiB
Go

package sociaty
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
)
// 公会搜索
func (this *apiComp) SearchCheck(session comm.IUserSession, req *pb.SociatySearchReq) (errdata *pb.ErrorData) {
if req.Name == "" {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
this.module.Error("公会搜索参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()})
}
return
}
func (this *apiComp) Search(session comm.IUserSession, req *pb.SociatySearchReq) (errdata *pb.ErrorData) {
if code = this.SearchCheck(session, req); errdata != nil {
return
}
data = &pb.ErrorData{}
rsp := &pb.SociatySearchResp{}
sociaty := this.module.modelSociaty.findByName(req.Name)
if sociaty != nil && sociaty.Id != "" {
rsp.List = append(rsp.List, sociaty)
}
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSearch, rsp); err != nil {
code = pb.ErrorCode_SystemError
}
return
}