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("/create_group", group.CreateGroup) //1
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1 groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
groupRouterGroup.POST("join_group", group.JoinGroup) 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("/group_application_response", group.ApplicationGroupResponse)
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner)
groupRouterGroup.POST("/get_group_applicationList", group.GetGroupApplicationList) 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()) log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
_, err := imdb.GetUserByUserID(req.OpUserID) _, err := imdb.GetUserByUserID(req.OpUserID)
if err != nil { 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 return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
var groupRequest imdb.GroupRequest var groupRequest imdb.GroupRequest
utils.CopyStructFields(&groupRequest, req) groupRequest.UserID = req.OpUserID
groupRequest.ReqMsg = req.ReqMessage
groupRequest.GroupID = req.GroupID
err = imdb.UpdateGroupRequest(groupRequest) err = imdb.UpdateGroupRequest(groupRequest)
if err != nil { if err != nil {
log.NewError(req.OperationID, "UpdateGroupRequest ", err.Error(), groupRequest) log.NewError(req.OperationID, "UpdateGroupRequest ", err.Error(), groupRequest)

@ -116,7 +116,7 @@ func GetOwnerManagerByGroupID(groupID string) ([]GroupMember, error) {
return nil, err return nil, err
} }
var groupMemberList []GroupMember 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 { if err != nil {
return nil, err return nil, err
} }

@ -3,6 +3,7 @@ package im_mysql_model
import ( import (
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db" "Open_IM/pkg/common/db"
"Open_IM/pkg/utils"
"time" "time"
) )
@ -23,11 +24,17 @@ func UpdateGroupRequest(groupRequest GroupRequest) error {
if err != nil { if err != nil {
return err return err
} }
err = dbConn.Table("group_request").Where("group_id=? and user_id=?", groupRequest.GroupID, groupRequest.UserID).Update(&groupRequest).Error
if err != nil { if groupRequest.HandledTime.Unix() < 0 {
return err 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
} }
return nil
} }
func InsertIntoGroupRequest(toInsertInfo GroupRequest) error { func InsertIntoGroupRequest(toInsertInfo GroupRequest) error {
@ -35,7 +42,12 @@ func InsertIntoGroupRequest(toInsertInfo GroupRequest) error {
if err != nil { if err != nil {
return err 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 err = dbConn.Table("group_request").Create(&toInsertInfo).Error
if err != nil { if err != nil {
return err return err

@ -118,7 +118,7 @@ type GroupRequest struct {
GroupID string `gorm:"column:group_id;primaryKey;"` GroupID string `gorm:"column:group_id;primaryKey;"`
HandleResult int32 `gorm:"column:handle_result"` HandleResult int32 `gorm:"column:handle_result"`
ReqMsg string `gorm:"column:req_msg"` 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"` ReqTime time.Time `gorm:"column:req_time"`
HandleUserID string `gorm:"column:handle_user_id"` HandleUserID string `gorm:"column:handle_user_id"`
HandledTime time.Time `gorm:"column:handle_time"` HandledTime time.Time `gorm:"column:handle_time"`

Loading…
Cancel
Save