34 lines
962 B
Go
34 lines
962 B
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) (code pb.ErrorCode) {
|
|
if req.Name == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
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) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
if code = this.SearchCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
rsp := &pb.SociatySearchResp{}
|
|
sociaty := this.module.modelSociaty.findByName(req.Name)
|
|
if sociaty != nil {
|
|
rsp.List = append(rsp.List, sociaty)
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSearch, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|