diff --git a/dao/video.go b/dao/video.go index d7c437e..6c31edc 100644 --- a/dao/video.go +++ b/dao/video.go @@ -59,9 +59,10 @@ func FindVideoByID(id, auth_id int) Video { return video } +// 根据用户id查找视频列表,返回最新30条 func FindVideoListsByAuthID(auth_id int) []Video { var videos []Video - DB.Debug().Where("auth_id = ?", auth_id).Where("isdelete = ?", 0).Limit(30).Find(&videos) + DB.Debug().Where("auth_id = ? and isdelete =? ", auth_id, 0).Order("create_time DESC").Limit(30).Find(&videos) return videos } diff --git a/handler/video.go b/handler/video.go index c4a6ab9..45cba1d 100644 --- a/handler/video.go +++ b/handler/video.go @@ -5,6 +5,7 @@ import ( "github.com/gin-gonic/gin" "net/http" "os" + "strconv" "time" "videoplayer/service" ) @@ -174,9 +175,9 @@ func DelayVideo(c *gin.Context) { cnt = service.DelayVideo(delay_req.ID, int(id.(float64)), delay_req.Day) } if cnt == 0 { - c.JSON(http.StatusOK, gin.H{"code": 1, "data": "延迟失败影响数据", "message": "failed,cnt:" + string(cnt)}) + c.JSON(http.StatusOK, gin.H{"code": 1, "data": "延迟失败影响数据", "message": "failed,cnt:" + strconv.Itoa(cnt)}) } else { - c.JSON(http.StatusOK, gin.H{"code": 0, "data": "延迟成功,cnt=" + string(cnt), "message": "success cnt:" + string(cnt)}) + c.JSON(http.StatusOK, gin.H{"code": 0, "data": "延迟成功,影响记录:" + strconv.Itoa(cnt), "message": "success cnt:" + strconv.Itoa(cnt)}) } } else { c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": 1, "message": "failed"})