From fa0781c353a59fd4c4d30e6351f025fa8d84dade Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Mon, 21 Oct 2024 13:02:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/userService.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/service/userService.go b/service/userService.go index d090431..39dd27a 100644 --- a/service/userService.go +++ b/service/userService.go @@ -1,6 +1,7 @@ package service import ( + "fmt" "regexp" "videoplayer/dao" "videoplayer/proto" @@ -44,6 +45,7 @@ func GetUserByNameLike(name string) []proto.User { func UpdateUser(user_id int, req proto.UpdateUserInfoReq) (int, error) { cur_user := dao.FindUserByID2(user_id) + fmt.Println("cur_user:", cur_user, "req:", req) if user_id == req.ID { dao.UpdateUserByID2(user_id, req) return user_id, nil From f17467d45171a174b424501dc1c6103996ff9d8d Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Fri, 25 Oct 2024 18:04:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/video.go | 9 ++++++--- service/userService.go | 2 -- service/videoService.go | 19 ------------------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/handler/video.go b/handler/video.go index 36badc6..5246d4f 100644 --- a/handler/video.go +++ b/handler/video.go @@ -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"}) diff --git a/service/userService.go b/service/userService.go index 39dd27a..d090431 100644 --- a/service/userService.go +++ b/service/userService.go @@ -1,7 +1,6 @@ package service import ( - "fmt" "regexp" "videoplayer/dao" "videoplayer/proto" @@ -45,7 +44,6 @@ func GetUserByNameLike(name string) []proto.User { func UpdateUser(user_id int, req proto.UpdateUserInfoReq) (int, error) { cur_user := dao.FindUserByID2(user_id) - fmt.Println("cur_user:", cur_user, "req:", req) if user_id == req.ID { dao.UpdateUserByID2(user_id, req) return user_id, nil diff --git a/service/videoService.go b/service/videoService.go index 8527207..c94046a 100644 --- a/service/videoService.go +++ b/service/videoService.go @@ -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], ":") From b5f01572ccbd6eac866db74ea84742c9d449d150 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Fri, 25 Oct 2024 18:23:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=BE=A4=E4=BF=A1=E6=81=AF=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/im.go | 4 ++-- handler/im.go | 18 ++++++++++++++++++ service/imService.go | 7 +++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/dao/im.go b/dao/im.go index f5848a5..75212be 100644 --- a/dao/im.go +++ b/dao/im.go @@ -265,8 +265,8 @@ func FindGroupByID(group_id int) []Group { return groups } -func UpdateGroup(group_id int, groupName, groupInfo, groupIcon string) error { - res := DB.Debug().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.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 } diff --git a/handler/im.go b/handler/im.go index ab7b407..bc872a1 100644 --- a/handler/im.go +++ b/handler/im.go @@ -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") diff --git a/service/imService.go b/service/imService.go index 6aa1e42..60185c3 100644 --- a/service/imService.go +++ b/service/imService.go @@ -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)