mirror of https://github.com/go-sonic/sonic.git
feat: add likes filed to comment (#358)
* feat: add likes filed to comment * fix: set likes field default valuepull/388/head
parent
5089665048
commit
0960573d8a
@ -0,0 +1,26 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/go-sonic/sonic/service"
|
||||
"github.com/go-sonic/sonic/util"
|
||||
)
|
||||
|
||||
type CommentHandler struct {
|
||||
BaseCommentService service.BaseCommentService
|
||||
}
|
||||
|
||||
func NewCommentHandler(baseCommentService service.BaseCommentService) *CommentHandler {
|
||||
return &CommentHandler{
|
||||
BaseCommentService: baseCommentService,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CommentHandler) Like(ctx *gin.Context) (interface{}, error) {
|
||||
commentID, err := util.ParamInt32(ctx, "commentID")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, c.BaseCommentService.IncreaseLike(ctx, commentID)
|
||||
}
|
Loading…
Reference in New Issue