diff --git a/dao/im.go b/dao/im.go index e8b5d76..6c6bf6b 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.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 } 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/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/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) 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], ":")