mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 02:58:26 +08:00
Refactor code
This commit is contained in:
parent
7b41ce1f24
commit
18600bcd11
@ -182,16 +182,27 @@ func GetGroupAllMemberList(c *gin.Context) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memberListResp.Test = JsonData(memberListResp.MemberList)
|
||||||
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", memberListResp)
|
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", memberListResp)
|
||||||
c.JSON(http.StatusOK, memberListResp)
|
c.JSON(http.StatusOK, memberListResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func JsonData(resp interface{}) []map[string]interface{} {
|
||||||
|
var result []map[string]interface{}
|
||||||
|
for _, v := range resp.([]proto.Message) {
|
||||||
|
m := ProtoToMap(v.(proto.Message), false)
|
||||||
|
result = append(result, m)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func ProtoToMap(pb proto.Message, idFix bool) map[string]interface{} {
|
func ProtoToMap(pb proto.Message, idFix bool) map[string]interface{} {
|
||||||
marshaler := jsonpb.Marshaler{
|
marshaler := jsonpb.Marshaler{
|
||||||
OrigName: true,
|
OrigName: true,
|
||||||
EnumsAsInts: false,
|
EnumsAsInts: false,
|
||||||
EmitDefaults: true,
|
EmitDefaults: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
s, _ := marshaler.MarshalToString(pb)
|
s, _ := marshaler.MarshalToString(pb)
|
||||||
out := make(map[string]interface{})
|
out := make(map[string]interface{})
|
||||||
json.Unmarshal([]byte(s), &out)
|
json.Unmarshal([]byte(s), &out)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user