Commit 206bf171 authored by haoyanbin's avatar haoyanbin

strcut

parent f9a37051
......@@ -2,6 +2,7 @@ package pool
import (
"encoding/json"
"strings"
)
......@@ -34,4 +35,15 @@ func SerializeJson(data interface{}) []byte {
func UnserislizeJson(str []byte, data interface{}) {
_ = json.Unmarshal(str, data)
}
func StrCut(s string) string {
if s == "" {
return ""
}
sMap := strings.Split(s, "_")
if len(sMap) < 4 {
return ""
}
return sMap[1] + "_" + sMap[2] + "_" + sMap[3]
}
\ No newline at end of file
......@@ -491,6 +491,8 @@ func GetAllList(key string) map[string]string {
}
func AppendConversationRecord(msg *SetMsgReq) {
msg.Sender = StrCut(msg.Sender)
msg.Receiver = StrCut(msg.Receiver)
Redis.HSetNX("msg:"+strconv.Itoa(msg.ConversationId), msg.Sender+":"+msg.Receiver+":"+msg.SendTime, string(SerializeJson(msg)))
return
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment