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()})
return
}
req := &rpc.CreateGroupReq{}
utils.CopyStructFields(req, &params)
req := &rpc.CreateGroupReq{GroupInfo: &open_im_sdk.GroupInfo{}}
utils.CopyStructFields(req.GroupInfo, &params)
for _, v := range params.MemberList {
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"})
return
}
req.OwnerUserID = req.OpUserID
req.OperationID = params.OperationID
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)
@ -447,7 +450,7 @@ func SetGroupInfo(c *gin.Context) {
return
}
req := &rpc.SetGroupInfoReq{GroupInfo: &open_im_sdk.GroupInfo{}}
utils.CopyStructFields(req.GroupInfo, &params.Group)
utils.CopyStructFields(req.GroupInfo, &params)
req.OperationID = params.OperationID
var ok bool
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))

@ -115,13 +115,12 @@ func GetSelfUserInfo(c *gin.Context) {
return
}
if len(RpcResp.UserInfoList) == 1 {
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: RpcResp.UserInfoList[0]}
resp.Data = jsonData.JsonDataList(resp.UserInfoList)
resp := api.GetSelfUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfo: RpcResp.UserInfoList[0]}
resp.Data = jsonData.JsonDataOne(resp.UserInfo)
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
c.JSON(http.StatusOK, resp)
} else {
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)
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
groupId := utils.Md5(strconv.FormatInt(time.Now().UnixNano(), 10))
//to group
groupInfo := db.Group{GroupID: groupId}
groupInfo := db.Group{}
utils.CopyStructFields(&groupInfo, req.GroupInfo)
groupInfo.CreatorUserID = req.OpUserID
groupInfo.GroupID = groupId
err := imdb.InsertIntoGroup(groupInfo)
if err != nil {
log.NewError(req.OperationID, "InsertIntoGroup failed, ", err.Error(), groupInfo)

@ -1,7 +1,6 @@
package base_info
import (
"Open_IM/pkg/common/db"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
)
@ -90,7 +89,7 @@ type CreateGroupReq struct {
}
type CreateGroupResp struct {
CommResp
GroupInfo open_im_sdk.GroupInfo `jason:-`
GroupInfo open_im_sdk.GroupInfo `json:"-"`
Data map[string]interface{} `json:"data"`
}
@ -143,8 +142,13 @@ type QuitGroupResp struct {
}
type SetGroupInfoReq struct {
db.Group
OperationID string `json:"operationID" binding:"required"`
GroupID string `json:"groupID" 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 {
CommResp

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

@ -44,7 +44,7 @@ func initMysqlDB() {
db.Close()
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)
if err != nil {
log.NewError("0", "Open failed ", err.Error(), dsn)

Loading…
Cancel
Save