Merge remote-tracking branch 'origin/tuoyun' into tuoyun

pull/131/head
Gordon 3 years ago
commit c23426425e

@ -245,8 +245,9 @@ func CreateGroup(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return return
} }
req := &rpc.CreateGroupReq{} req := &rpc.CreateGroupReq{GroupInfo: &open_im_sdk.GroupInfo{}}
utils.CopyStructFields(req, &params) utils.CopyStructFields(req.GroupInfo, &params)
for _, v := range params.MemberList { for _, v := range params.MemberList {
req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel}) req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel})
} }
@ -257,6 +258,8 @@ func CreateGroup(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
return return
} }
req.OwnerUserID = req.OpUserID
req.OperationID = params.OperationID
log.NewInfo(req.OperationID, "CreateGroup args ", req.String()) log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
@ -447,7 +450,7 @@ func SetGroupInfo(c *gin.Context) {
return return
} }
req := &rpc.SetGroupInfoReq{GroupInfo: &open_im_sdk.GroupInfo{}} req := &rpc.SetGroupInfoReq{GroupInfo: &open_im_sdk.GroupInfo{}}
utils.CopyStructFields(req.GroupInfo, &params.Group) utils.CopyStructFields(req.GroupInfo, &params)
req.OperationID = params.OperationID req.OperationID = params.OperationID
var ok bool var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token")) ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))

@ -115,13 +115,12 @@ func GetSelfUserInfo(c *gin.Context) {
return return
} }
if len(RpcResp.UserInfoList) == 1 { if len(RpcResp.UserInfoList) == 1 {
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: RpcResp.UserInfoList[0]} resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfo: RpcResp.UserInfoList[0]}
resp.Data = jsonData.JsonDataList(resp.UserInfoList) resp.Data = jsonData.JsonDataOne(resp.UserInfo)
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp) log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
c.JSON(http.StatusOK, resp) c.JSON(http.StatusOK, resp)
} else { } else {
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}} resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
resp.Data = jsonData.JsonDataList(resp.UserInfoList)
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp) log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
c.JSON(http.StatusOK, resp) c.JSON(http.StatusOK, resp)
} }

@ -78,9 +78,10 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
//Time stamp + MD5 to generate group chat id //Time stamp + MD5 to generate group chat id
groupId := utils.Md5(strconv.FormatInt(time.Now().UnixNano(), 10)) groupId := utils.Md5(strconv.FormatInt(time.Now().UnixNano(), 10))
//to group //to group
groupInfo := db.Group{GroupID: groupId} groupInfo := db.Group{}
utils.CopyStructFields(&groupInfo, req.GroupInfo) utils.CopyStructFields(&groupInfo, req.GroupInfo)
groupInfo.CreatorUserID = req.OpUserID groupInfo.CreatorUserID = req.OpUserID
groupInfo.GroupID = groupId
err := imdb.InsertIntoGroup(groupInfo) err := imdb.InsertIntoGroup(groupInfo)
if err != nil { if err != nil {
log.NewError(req.OperationID, "InsertIntoGroup failed, ", err.Error(), groupInfo) log.NewError(req.OperationID, "InsertIntoGroup failed, ", err.Error(), groupInfo)

@ -1,7 +1,6 @@
package base_info package base_info
import ( import (
"Open_IM/pkg/common/db"
open_im_sdk "Open_IM/pkg/proto/sdk_ws" open_im_sdk "Open_IM/pkg/proto/sdk_ws"
) )
@ -90,7 +89,7 @@ type CreateGroupReq struct {
} }
type CreateGroupResp struct { type CreateGroupResp struct {
CommResp CommResp
GroupInfo open_im_sdk.GroupInfo `jason:-` GroupInfo open_im_sdk.GroupInfo `json:"-"`
Data map[string]interface{} `json:"data"` Data map[string]interface{} `json:"data"`
} }
@ -143,8 +142,13 @@ type QuitGroupResp struct {
} }
type SetGroupInfoReq struct { type SetGroupInfoReq struct {
db.Group GroupID string `json:"groupID" binding:"required"`
OperationID string `json:"operationID" binding:"required"` GroupName string `json:"groupName"`
Notification string `json:"notification"`
Introduction string `json:"introduction"`
FaceURL string `json:"faceURL"`
Ex string `json:"ex"`
OperationID string `json:"operationID" binding:"required"`
} }
type SetGroupInfoResp struct { type SetGroupInfoResp struct {
CommResp CommResp

@ -29,6 +29,6 @@ type GetSelfUserInfoReq struct {
} }
type GetSelfUserInfoResp struct { type GetSelfUserInfoResp struct {
CommResp CommResp
UserInfoList *open_im_sdk.UserInfo `json:"-"` UserInfo *open_im_sdk.UserInfo `json:"-"`
Data []map[string]interface{} `json:"data"` Data map[string]interface{} `json:"data"`
} }

@ -44,7 +44,7 @@ func initMysqlDB() {
db.Close() db.Close()
dsn = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local", dsn = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName+"test1") config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName)
db, err = gorm.Open("mysql", dsn) db, err = gorm.Open("mysql", dsn)
if err != nil { if err != nil {
log.NewError("0", "Open failed ", err.Error(), dsn) log.NewError("0", "Open failed ", err.Error(), dsn)

Loading…
Cancel
Save