-
Notifications
You must be signed in to change notification settings - Fork 9
/
delrecs.go
50 lines (40 loc) · 1.31 KB
/
delrecs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package v1
import (
"net/http"
"github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin"
"github.com/haibeichina/gin_video_server/0commonpkg/e"
"github.com/haibeichina/gin_video_server/scheduler/pkg/app"
"github.com/haibeichina/gin_video_server/scheduler/pkg/logging"
"github.com/haibeichina/gin_video_server/scheduler/service/delrecsservice"
)
// AddDelRec 新增删除记录
// @Summary add a new record for delete video
// @Accept json
// @Produce json
// @Param vid-id path string true "video id"
// @Success 200 {string} json "{"code":200,"msg":"ok","data":nil}"
// @Failure 400 {string} json "{"code":400,"msg":"","data":nil}"
// @Failure 500 {string} json "{"code":500,"msg":"","data":nil}"
// @Router /api/v1/user/{username} [get]
func AddDelRec(c *gin.Context) {
appG := app.Gin{C: c}
vid := c.Param("vid-id")
valid := validation.Validation{}
valid.Required(vid, "vid-id").Message("视频id不能为空")
if valid.HasErrors() {
// app.MarkErrors(valid.Errors)
logging.Info(valid.Errors)
appG.ResponseErr(http.StatusBadRequest, e.INVALID_PARAMS)
return
}
commentSer := delrecsservice.DelRecs{
VideoID: vid,
}
if err := commentSer.AddDelRec(); err != nil {
logging.Info(err)
appG.ResponseErr(http.StatusInternalServerError, e.ERROR_ADD_DELRECS_FAIL)
return
}
appG.ResponseOk(e.SUCCESS)
}