修复查询视频时间范围错误
This commit is contained in:
parent
420d652e6b
commit
f17467d451
|
|
@ -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"})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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], ":")
|
||||
|
|
|
|||
Loading…
Reference in New Issue