添加修改群信息功能
This commit is contained in:
parent
f17467d451
commit
b5f01572cc
|
|
@ -265,8 +265,8 @@ func FindGroupByID(group_id int) []Group {
|
||||||
return groups
|
return groups
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateGroup(group_id int, groupName, groupInfo, groupIcon string) error {
|
func UpdateGroup(group_id int, groupName, groupInfo, groupType, groupIcon string, user_id int) error {
|
||||||
res := DB.Debug().Model(&Group{}).Where("id = ?", group_id).Updates(map[string]interface{}{"group_name": groupName, "group_info": groupInfo, "group_icon": groupIcon})
|
res := DB.Debug().Model(&Group{}).Where("id = ? and auth_id = ? ", group_id, user_id).Updates(map[string]interface{}{"group_name": groupName, "group_info": groupInfo, "group_icon": groupIcon, "group_type": groupType})
|
||||||
return res.Error
|
return res.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ type Message struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CGroup struct {
|
type CGroup struct {
|
||||||
|
ID int `json:"id" form:"id"`
|
||||||
Group_name string `json:"group_name" form:"group_name"`
|
Group_name string `json:"group_name" form:"group_name"`
|
||||||
Group_info string `json:"group_info" form:"group_info"`
|
Group_info string `json:"group_info" form:"group_info"`
|
||||||
Group_type string `json:"group_type" form:"group_type"`
|
Group_type string `json:"group_type" form:"group_type"`
|
||||||
|
|
@ -69,6 +70,7 @@ func SetUpIMGroup(router *gin.Engine) {
|
||||||
//拒绝邀请
|
//拒绝邀请
|
||||||
imGroup.POST("/reject_invite", RejectInvite)
|
imGroup.POST("/reject_invite", RejectInvite)
|
||||||
imGroup.POST("/create_group", CreateGroup)
|
imGroup.POST("/create_group", CreateGroup)
|
||||||
|
imGroup.POST("/update_group", UpdateGroup)
|
||||||
imGroup.POST("/get_group", GetGroups)
|
imGroup.POST("/get_group", GetGroups)
|
||||||
imGroup.POST("/get_group_req_user", GetFriendRequest)
|
imGroup.POST("/get_group_req_user", GetFriendRequest)
|
||||||
imGroup.GET("/sse_msg", ServerSendMsg)
|
imGroup.GET("/sse_msg", ServerSendMsg)
|
||||||
|
|
@ -120,6 +122,22 @@ func GetGroups(c *gin.Context) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdateGroup(c *gin.Context) {
|
||||||
|
id, _ := c.Get("id")
|
||||||
|
user_id := int(id.(float64))
|
||||||
|
var req CGroup
|
||||||
|
if err := c.ShouldBind(&req); err == nil {
|
||||||
|
err2 := service.UpdateGroupService(req.ID, req.Group_name, req.Group_info, req.Group_type, req.Group_icon, 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 {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func DelFriendOrGroup(c *gin.Context) {
|
func DelFriendOrGroup(c *gin.Context) {
|
||||||
var req Message
|
var req Message
|
||||||
user_id, _ := c.Get("id")
|
user_id, _ := c.Get("id")
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,13 @@ func GetFriendList(user_id int) FGRet {
|
||||||
return fg
|
return fg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdateGroupService(group_id int, group_name, group_info, group_type, group_icon string, user_id int) error {
|
||||||
|
//更新群聊
|
||||||
|
err := dao.UpdateGroup(group_id, group_name, group_info, group_type, group_icon, user_id)
|
||||||
|
return err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func GetFriendRequest(user_id int) []dao.FriendRequest {
|
func GetFriendRequest(user_id int) []dao.FriendRequest {
|
||||||
//获取好友请求
|
//获取好友请求
|
||||||
users := dao.GetFriendRequest(user_id)
|
users := dao.GetFriendRequest(user_id)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue