airobot/busi/friend/friend_apply.go
2022-12-09 18:41:12 +08:00

43 lines
717 B
Go

package friend
import (
"time"
"google.golang.org/protobuf/proto"
"legu.airobot/lib"
"legu.airobot/pb"
)
var _ lib.ICaller = (*FriendApply)(nil)
type FriendApply struct {
lib.Action
Desc string
}
func (a *FriendApply) BuildReq(head *pb.UserMessage) lib.ActionReq {
id := time.Now().UnixNano()
var req []byte
b := a.Get("friend.apply")
rsp := &pb.FriendRandlistResp{}
if err := proto.Unmarshal(b, rsp); err != nil {
panic(err)
}
if len(rsp.List) == 0 {
return lib.ActionReq{}
}
if lib.ProtoMarshal(&pb.FriendApplyReq{
FriendId: rsp.List[0].UserId,
}, head) {
data, err := proto.Marshal(head)
if err != nil {
panic(err)
}
req = data
}
return lib.ActionReq{ID: id, Req: req}
}