|
|
|
|
@ -203,7 +203,6 @@ func GetMessage(c *gin.Context) {
|
|
|
|
|
id := int(user_id.(float64))
|
|
|
|
|
//解析参数
|
|
|
|
|
if err := c.ShouldBind(&req); err == nil {
|
|
|
|
|
|
|
|
|
|
if req.Type == 2 {
|
|
|
|
|
msgs, err2 := dao.GetMsgGroupByIndex(req.GroupID, req.Index)
|
|
|
|
|
if err2 == nil {
|
|
|
|
|
@ -266,27 +265,52 @@ func AcceptInvite(c *gin.Context) {
|
|
|
|
|
user_id, _ := c.Get("id")
|
|
|
|
|
cid := int(user_id.(float64))
|
|
|
|
|
if err := c.ShouldBind(&req); err == nil {
|
|
|
|
|
err2 := service.AddFriendService(req.ID, cid, req.To_user_id)
|
|
|
|
|
if err2 == nil {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
|
|
|
|
if req.Type == 1 {
|
|
|
|
|
//同意添加好友
|
|
|
|
|
err2 := service.AddFriendService(req.ID, cid, req.To_user_id)
|
|
|
|
|
if err2 == nil {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
|
|
|
|
} else {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"error": err2.Error(), "code": proto.OperationFailed, "message": "failed"})
|
|
|
|
|
}
|
|
|
|
|
} else if req.Type == 2 {
|
|
|
|
|
//同意加入群聊
|
|
|
|
|
err3 := service.JoinGroupService(req.ID, cid, req.To_user_id, req.GroupID)
|
|
|
|
|
if err3 == nil {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
|
|
|
|
} else {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"error": err3.Error(), "code": proto.OperationFailed, "message": "failed"})
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"error": err2.Error(), "code": proto.OperationFailed, "message": "failed"})
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func RejectInvite(c *gin.Context) {
|
|
|
|
|
var req Message
|
|
|
|
|
user_id, _ := c.Get("id")
|
|
|
|
|
cid := int(user_id.(float64))
|
|
|
|
|
if err := c.ShouldBind(&req); err == nil {
|
|
|
|
|
err2 := service.RejectFriendService(req.ID, cid, req.To_user_id)
|
|
|
|
|
if err2 == nil {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
|
|
|
|
if req.Type == 1 {
|
|
|
|
|
//拒绝添加好友
|
|
|
|
|
err2 := service.RejectFriendService(req.ID, cid, req.To_user_id)
|
|
|
|
|
if err2 == nil {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
|
|
|
|
} else {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"error": err2.Error(), "code": proto.OperationFailed, "message": "failed"})
|
|
|
|
|
}
|
|
|
|
|
} else if req.Type == 2 {
|
|
|
|
|
//拒绝加入群聊
|
|
|
|
|
err3 := service.RejectGroupService(req.ID, cid, req.To_user_id, req.GroupID)
|
|
|
|
|
if err3 == nil {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
|
|
|
|
} else {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"error": err3.Error(), "code": proto.OperationFailed, "message": "failed"})
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"error": err2.Error(), "code": proto.OperationFailed, "message": "failed"})
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed type error"})
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
|
|
|
|
|