Documentation
¶
Overview ¶
The article module containing the article CRUD operation and relationship CRUD.
model.go: definition of orm based data model
routers.go: router binding and core logic
serializers.go: definition the schema of return data
validators.go: definition the validator of form data
Index ¶
- func ArticleCommentCreate(c *gin.Context)
- func ArticleCommentDelete(c *gin.Context)
- func ArticleCommentList(c *gin.Context)
- func ArticleCreate(c *gin.Context)
- func ArticleDelete(c *gin.Context)
- func ArticleFavorite(c *gin.Context)
- func ArticleFeed(c *gin.Context)
- func ArticleList(c *gin.Context)
- func ArticleRetrieve(c *gin.Context)
- func ArticleUnfavorite(c *gin.Context)
- func ArticleUpdate(c *gin.Context)
- func ArticlesAnonymousRegister(router *gin.RouterGroup)
- func ArticlesRegister(router *gin.RouterGroup)
- func DeleteArticleModel(condition interface{}) error
- func DeleteCommentModel(condition interface{}) error
- func SaveOne(data interface{}) error
- func TagList(c *gin.Context)
- func TagsAnonymousRegister(router *gin.RouterGroup)
- type ArticleModel
- type ArticleModelValidator
- type ArticleResponse
- type ArticleSerializer
- type ArticleUserModel
- type ArticleUserSerializer
- type ArticlesSerializer
- type CommentModel
- type CommentModelValidator
- type CommentResponse
- type CommentSerializer
- type CommentsSerializer
- type FavoriteModel
- type TagModel
- type TagSerializer
- type TagsSerializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArticleCommentCreate ¶
func ArticleCommentDelete ¶
func ArticleCommentList ¶
func ArticleCreate ¶
func ArticleDelete ¶
func ArticleFavorite ¶
func ArticleFeed ¶
func ArticleList ¶
func ArticleRetrieve ¶
func ArticleUnfavorite ¶
func ArticleUpdate ¶
func ArticlesAnonymousRegister ¶
func ArticlesAnonymousRegister(router *gin.RouterGroup)
func ArticlesRegister ¶
func ArticlesRegister(router *gin.RouterGroup)
func DeleteArticleModel ¶
func DeleteArticleModel(condition interface{}) error
func DeleteCommentModel ¶
func DeleteCommentModel(condition interface{}) error
func TagsAnonymousRegister ¶
func TagsAnonymousRegister(router *gin.RouterGroup)
Types ¶
type ArticleModel ¶
type ArticleModel struct {
gorm.Model
Slug string `gorm:"unique_index"`
Title string
Description string `gorm:"size:2048"`
Body string `gorm:"size:2048"`
Author ArticleUserModel
AuthorID uint
Tags []TagModel `gorm:"many2many:article_tags;"`
Comments []CommentModel `gorm:"ForeignKey:ArticleID"`
}
func FindManyArticle ¶
func FindManyArticle(tag, author, limit, offset, favorited string) ([]ArticleModel, int, error)
func FindOneArticle ¶
func FindOneArticle(condition interface{}) (ArticleModel, error)
func (*ArticleModel) Update ¶
func (model *ArticleModel) Update(data interface{}) error
type ArticleModelValidator ¶
type ArticleModelValidator struct {
Article struct {
Title string `form:"title" json:"title" binding:"exists,min=4"`
Description string `form:"description" json:"description" binding:"max=2048"`
Body string `form:"body" json:"body" binding:"max=2048"`
Tags []string `form:"tagList" json:"tagList"`
} `json:"article"`
// contains filtered or unexported fields
}
func NewArticleModelValidator ¶
func NewArticleModelValidator() ArticleModelValidator
func NewArticleModelValidatorFillWith ¶
func NewArticleModelValidatorFillWith(articleModel ArticleModel) ArticleModelValidator
type ArticleResponse ¶
type ArticleResponse struct {
ID uint `json:"-"`
Title string `json:"title"`
Slug string `json:"slug"`
Description string `json:"description"`
Body string `json:"body"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Author users.ProfileResponse `json:"author"`
Tags []string `json:"tagList"`
Favorite bool `json:"favorited"`
FavoritesCount uint `json:"favoritesCount"`
}
type ArticleSerializer ¶
type ArticleSerializer struct {
C *gin.Context
ArticleModel
}
func (*ArticleSerializer) Response ¶
func (s *ArticleSerializer) Response() ArticleResponse
type ArticleUserModel ¶
type ArticleUserModel struct {
gorm.Model
UserModel users.UserModel
UserModelID uint
ArticleModels []ArticleModel `gorm:"ForeignKey:AuthorID"`
FavoriteModels []FavoriteModel `gorm:"ForeignKey:FavoriteByID"`
}
func GetArticleUserModel ¶
func GetArticleUserModel(userModel users.UserModel) ArticleUserModel
func (*ArticleUserModel) GetArticleFeed ¶
func (self *ArticleUserModel) GetArticleFeed(limit, offset string) ([]ArticleModel, int, error)
type ArticleUserSerializer ¶
type ArticleUserSerializer struct {
C *gin.Context
ArticleUserModel
}
func (*ArticleUserSerializer) Response ¶
func (s *ArticleUserSerializer) Response() users.ProfileResponse
type ArticlesSerializer ¶
type ArticlesSerializer struct {
C *gin.Context
Articles []ArticleModel
}
func (*ArticlesSerializer) Response ¶
func (s *ArticlesSerializer) Response() []ArticleResponse
type CommentModel ¶
type CommentModel struct {
gorm.Model
Article ArticleModel
ArticleID uint
Author ArticleUserModel
AuthorID uint
Body string `gorm:"size:2048"`
}
type CommentModelValidator ¶
type CommentModelValidator struct {
Comment struct {
Body string `form:"body" json:"body" binding:"max=2048"`
} `json:"comment"`
// contains filtered or unexported fields
}
func NewCommentModelValidator ¶
func NewCommentModelValidator() CommentModelValidator
type CommentResponse ¶
type CommentSerializer ¶
type CommentSerializer struct {
C *gin.Context
CommentModel
}
func (*CommentSerializer) Response ¶
func (s *CommentSerializer) Response() CommentResponse
type CommentsSerializer ¶
type CommentsSerializer struct {
C *gin.Context
Comments []CommentModel
}
func (*CommentsSerializer) Response ¶
func (s *CommentsSerializer) Response() []CommentResponse
type FavoriteModel ¶
type FavoriteModel struct {
gorm.Model
Favorite ArticleModel
FavoriteID uint
FavoriteBy ArticleUserModel
FavoriteByID uint
}
type TagModel ¶
type TagModel struct {
gorm.Model
Tag string `gorm:"unique_index"`
ArticleModels []ArticleModel `gorm:"many2many:article_tags;"`
}
type TagSerializer ¶
func (*TagSerializer) Response ¶
func (s *TagSerializer) Response() string
type TagsSerializer ¶
func (*TagsSerializer) Response ¶
func (s *TagsSerializer) Response() []string
Click to show internal directories.
Click to hide internal directories.