-
Notifications
You must be signed in to change notification settings - Fork 7
/
comment.go
57 lines (51 loc) · 1.47 KB
/
comment.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
51
52
53
54
55
56
57
/*
* @Author: alexander.huang
* @Date: 2022-05-26 12:44:17
* @Last Modified by: alexander.huang
* @Last Modified time: 2022-05-26 12:44:17
*/
package app
import (
"github.com/Anzz-bot/DouYin_demo/app/common/request"
"github.com/Anzz-bot/DouYin_demo/app/services"
"github.com/Anzz-bot/DouYin_demo/global"
"github.com/Anzz-bot/DouYin_demo/utils"
"github.com/gin-gonic/gin"
"net/http"
)
func Comment(c *gin.Context) {
var form request.Comment
user_id := global.NowUserID
token := c.Query("token")
video_id := utils.StrToUint64(c.Query("video_id"))
comment_id := utils.StrToUint64(c.Query("comment_id"))
action_type := utils.StrToInt32(c.Query("action_type"))
comment_text := c.Query("comment_text")
form = request.Comment{
UserId: user_id,
Token: token,
VideoId: video_id,
ActionType: action_type,
CommentId: comment_id,
CommentText: comment_text,
}
if err, commentResponse := services.CommentService.Comment(form); err != nil {
c.JSON(http.StatusBadRequest, commentResponse)
} else {
c.JSON(http.StatusOK, commentResponse)
}
}
func CommentList(c *gin.Context) {
var form request.CommentList
token := c.Query("token")
videoId := c.Query("video_id")
form = request.CommentList{
VideoId: utils.StrToUint64(videoId),
Token: token,
}
if err, commentListResponse := services.CommentService.CommentList(form); err != nil {
c.JSON(http.StatusBadRequest, commentListResponse)
} else {
c.JSON(http.StatusOK, commentListResponse)
}
}