handler_get_player_chat_log.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //@Author : KaiShin
  2. //@Time : 2021/11/2
  3. package handler
  4. import (
  5. "call_center/call/rpc/internal/interaction"
  6. "call_center/call/rpc/pb"
  7. db "call_center/db/rpc/pb"
  8. "call_center/public/exception"
  9. "log"
  10. )
  11. func GetPlayerChatLog(serviceId string, req *pb.CommandMsg, interDb interaction.InterDb) (*pb.CommandMsg, error) {
  12. cmdMsg := new(pb.CommandMsg)
  13. exception.Try(func() {
  14. playerId := req.CmdStr
  15. dataList := interDb.GetChatLog(playerId)
  16. if dataList != nil {
  17. chatLogList := new(pb.ArrayChatLog)
  18. for _, v := range dataList {
  19. fromPlayer := false
  20. if v.ChatType == db.EDbChatType_E_DB_CHAT_TYPE_PLAYER {
  21. fromPlayer = true
  22. }
  23. chatLogList.DataList = append(chatLogList.DataList, &pb.ChatLog{
  24. Content: v.Content,
  25. TimeStamp: v.TimeStamp,
  26. GameId: v.GameId,
  27. FromPlayer: fromPlayer,
  28. })
  29. }
  30. cmdMsg.Buff = &pb.CommandMsg_ArrayChatLog{ArrayChatLog: chatLogList}
  31. }
  32. log.Println("<handler.playerChatLogHandler> id:", serviceId)
  33. }).Catch(func(e exception.Exception) {
  34. }).Finally(func() {
  35. })
  36. return cmdMsg, nil
  37. }