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

pull/131/head
Gordon 3 years ago
commit f582967711

@ -50,7 +50,7 @@ func main() {
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
groupRouterGroup.POST("join_group", group.JoinGroup)
groupRouterGroup.POST("/quit_group", group.QuitGroup)
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse)
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner)
groupRouterGroup.POST("/get_group_applicationList", group.GetGroupApplicationList)

@ -453,12 +453,15 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
_, err := imdb.GetUserByUserID(req.OpUserID)
if err != nil {
log.NewError(req.OperationID, "FindUserByUID failed ", err.Error(), req.OpUserID)
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OpUserID)
return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
var groupRequest imdb.GroupRequest
utils.CopyStructFields(&groupRequest, req)
groupRequest.UserID = req.OpUserID
groupRequest.ReqMsg = req.ReqMessage
groupRequest.GroupID = req.GroupID
err = imdb.UpdateGroupRequest(groupRequest)
if err != nil {
log.NewError(req.OperationID, "UpdateGroupRequest ", err.Error(), groupRequest)

@ -116,7 +116,7 @@ func GetOwnerManagerByGroupID(groupID string) ([]GroupMember, error) {
return nil, err
}
var groupMemberList []GroupMember
err = dbConn.Table("group_member").Where("group_id=? and role_level>0", groupID).Find(&groupMemberList).Error
err = dbConn.Table("group_member").Where("group_id=? and role_level>?", groupID, constant.GroupOrdinaryUsers).Find(&groupMemberList).Error
if err != nil {
return nil, err
}

@ -3,6 +3,7 @@ package im_mysql_model
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
"Open_IM/pkg/utils"
"time"
)
@ -23,19 +24,30 @@ func UpdateGroupRequest(groupRequest GroupRequest) error {
if err != nil {
return err
}
err = dbConn.Table("group_request").Where("group_id=? and user_id=?", groupRequest.GroupID, groupRequest.UserID).Update(&groupRequest).Error
if err != nil {
return err
if groupRequest.HandledTime.Unix() < 0 {
groupRequest.HandledTime = utils.UnixSecondToTime(0)
}
//RowsAffected
if dbConn.Table("group_request").Where("group_id=? and user_id=?", groupRequest.GroupID, groupRequest.UserID).Update(&groupRequest).RowsAffected == 0 {
return InsertIntoGroupRequest(groupRequest)
} else {
return nil
}
}
func InsertIntoGroupRequest(toInsertInfo GroupRequest) error {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return err
}
toInsertInfo.HandledTime = time.Now()
toInsertInfo.ReqTime = time.Now()
if toInsertInfo.HandledTime.Unix() < 0 {
toInsertInfo.HandledTime = utils.UnixSecondToTime(0)
}
err = dbConn.Table("group_request").Create(&toInsertInfo).Error
if err != nil {
return err

@ -118,7 +118,7 @@ type GroupRequest struct {
GroupID string `gorm:"column:group_id;primaryKey;"`
HandleResult int32 `gorm:"column:handle_result"`
ReqMsg string `gorm:"column:req_msg"`
HandledMsg string `gorm:"column:handled_msg"`
HandledMsg string `gorm:"column:handle_msg"`
ReqTime time.Time `gorm:"column:req_time"`
HandleUserID string `gorm:"column:handle_user_id"`
HandledTime time.Time `gorm:"column:handle_time"`

Loading…
Cancel
Save