This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
Files
schisandra-cloud-album/api/comment_api/comment_api.go
2024-09-19 18:44:53 +08:00

29 lines
735 B
Go

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
}
}