✨ add comment and reply framework
This commit is contained in:
@@ -3,6 +3,7 @@ package api
|
||||
import (
|
||||
"schisandra-cloud-album/api/captcha_api"
|
||||
"schisandra-cloud-album/api/client_api"
|
||||
"schisandra-cloud-album/api/comment_api"
|
||||
"schisandra-cloud-album/api/oauth_api"
|
||||
"schisandra-cloud-album/api/permission_api"
|
||||
"schisandra-cloud-album/api/role_api"
|
||||
@@ -21,6 +22,7 @@ type Apis struct {
|
||||
RoleApi role_api.RoleAPI
|
||||
PermissionApi permission_api.PermissionAPI
|
||||
ClientApi client_api.ClientAPI
|
||||
CommonApi comment_api.CommentAPI
|
||||
}
|
||||
|
||||
// Api new函数实例化,实例化完成后会返回结构体地指针类型
|
||||
|
@@ -1,3 +1,7 @@
|
||||
package comment_api
|
||||
|
||||
import "schisandra-cloud-album/service"
|
||||
|
||||
type CommentAPI struct{}
|
||||
|
||||
var commentReplyService = service.Service.CommentReplyService
|
||||
|
@@ -1 +1,28 @@
|
||||
package comment_api
|
||||
|
||||
import (
|
||||
ginI18n "github.com/gin-contrib/i18n"
|
||||
"github.com/gin-gonic/gin"
|
||||
"schisandra-cloud-album/api/comment_api/dto"
|
||||
"schisandra-cloud-album/common/result"
|
||||
)
|
||||
|
||||
// CommentSubmit 提交评论
|
||||
func (CommentAPI) CommentSubmit(c *gin.Context) {
|
||||
commentRequest := dto.CommentRequest{}
|
||||
err := c.ShouldBindJSON(&commentRequest)
|
||||
if err != nil {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "ParamsError"), c)
|
||||
return
|
||||
}
|
||||
content := commentRequest.Content
|
||||
images := commentRequest.Images
|
||||
if content == "" {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "RequestParamsNotEmpty"), c)
|
||||
return
|
||||
}
|
||||
if len(images) > 5 {
|
||||
result.FailWithMessage(ginI18n.MustGetMessage(c, "TooManyImages"), c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
6
api/comment_api/dto/request_dto.go
Normal file
6
api/comment_api/dto/request_dto.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package dto
|
||||
|
||||
type CommentRequest struct {
|
||||
Content string `json:"content"`
|
||||
Images []string `json:"images"`
|
||||
}
|
Reference in New Issue
Block a user