Merge branch 'refs/heads/master' into release

# Conflicts:
#	dao/im.go
This commit is contained in:
junleea 2024-10-25 18:32:13 +08:00
commit b9025cf5d1
5 changed files with 33 additions and 24 deletions

View File

@ -265,8 +265,8 @@ func FindGroupByID(group_id int) []Group {
return groups
}
func UpdateGroup(group_id int, groupName, groupInfo, groupIcon string) error {
res := DB.Model(&Group{}).Where("id = ?", group_id).Updates(map[string]interface{}{"group_name": groupName, "group_info": groupInfo, "group_icon": groupIcon})
func UpdateGroup(group_id int, groupName, groupInfo, groupType, groupIcon string, user_id int) error {
res := DB.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
}

View File

@ -35,6 +35,7 @@ type Message struct {
}
type CGroup struct {
ID int `json:"id" form:"id"`
Group_name string `json:"group_name" form:"group_name"`
Group_info string `json:"group_info" form:"group_info"`
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("/create_group", CreateGroup)
imGroup.POST("/update_group", UpdateGroup)
imGroup.POST("/get_group", GetGroups)
imGroup.POST("/get_group_req_user", GetFriendRequest)
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) {
var req Message
user_id, _ := c.Get("id")

View File

@ -15,8 +15,8 @@ import (
// video获取视频列表请求
type gvlReq struct {
StartTime string `json:"begin" form:"begin"`
EndTime string `json:"end" form:"end"`
StartTime int64 `json:"begin" form:"begin"`
EndTime int64 `json:"end" form:"end"`
IP string `json:"ip" form:"ip"`
Token string `json:"token" form:"token"`
Hour string `json:"hour" form:"hour"`
@ -157,7 +157,10 @@ func GetVideoList(c *gin.Context) {
gvl_req.Hour = "33"
id, _ := c.Get("id")
if err := c.ShouldBind(&gvl_req); err == nil {
videos := service.GetVideoList(int(id.(float64)), gvl_req.StartTime, gvl_req.EndTime, gvl_req.Hour)
const layout = "2006-01-02 15:04:05"
tm1 := time.Unix(gvl_req.StartTime, 0).Format(layout)
tm2 := time.Unix(gvl_req.EndTime, 0).Format(layout)
videos := service.GetVideoList(int(id.(float64)), tm1, tm2, gvl_req.Hour)
c.JSON(http.StatusOK, gin.H{"data": videos, "code": proto.SuccessCode, "message": "success"})
} else {
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})

View File

@ -258,6 +258,13 @@ func GetFriendList(user_id int) FGRet {
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 {
//获取好友请求
users := dao.GetFriendRequest(user_id)

View File

@ -20,25 +20,6 @@ func GetVideoList(auth_id int, start, end, hour string) []dao.Video {
if start == "" {
return dao.FindVideoListsByAuthID(auth_id)
} else {
//s, err := time.Parse("2006/1/02 15:04:05", start)
//if err != nil {
// s, err = time.Parse("2006/01/02 15:04:05", start)
//}
//e, err2 := time.Parse("2006/1/02 15:04:05", end)
//if err2 != nil {
// e, err2 = time.Parse("2006/01/02 15:04:05", end)
//}
//if s.After(e) || err != nil || err2 != nil {
// fmt.Println(err)
// fmt.Println(err2)
// return []dao.Video{}
//}
start = strings.Replace(start, "/", "-", -1)
end = strings.Replace(end, "/", "-", -1)
start = strings.Replace(start, " ", " ", -1)
end = strings.Replace(end, " ", " ", -1)
start = start[0:5] + "0" + start[5:]
end = end[0:5] + "0" + end[5:]
if hour != "33" {
ss := strings.Split(start, " ")
ss1 := strings.Split(ss[1], ":")