xarticle

package
v0.3.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause-Clear Imports: 7 Imported by: 0

Documentation

Overview

文章模块

Index

Constants

View Source
const (
	LikeArticleLike    uint = iota // 文章点赞 - 0
	LikeArticleCollect             // 文章收藏 - 1
	LikeCommentLike                // 评论点赞 - 2
)

Variables

This section is empty.

Functions

func Audit added in v0.0.17

func Audit(edit_id uint, audit uint8, msg string, uid uint) error

审核文章信息

edit_id	编辑文章的ID
audit	审核状态
msg		审核备注
uid		审核人ID

func Brow added in v0.0.17

func Brow(id, uid uint, ip string) error

添加文章浏览量

id	文章ID
uid	浏览用户ID
ip	浏览用户IP地址

func Comment added in v0.0.17

func Comment(article_id, comment_id, user_id uint, cont string) error

文章评论

article_id	文章ID
comment_id	回复的评论ID
user_id		用户ID
cont		评论内容

func Create added in v0.0.17

func Create(ar *ArticleEdits) error

创建文章信息

ar	创建的文章标识【只有审核通过后才会将文章发布到正式文章表中】

func Like added in v0.0.17

func Like(id, uid, typ uint, ip string) error

添加文章点赞量

id	文章ID
uid	点赞用户ID
typ	点赞类型
ip	点赞用户IP地址

func Regedit

func Regedit(ac *Config)

文章模块注册

ac	配置项信息

func UnLike added in v0.0.17

func UnLike(id, uid, typ uint) error

取消文章点赞量

id	文章ID
uid	点赞用户ID
ip	点赞用户IP地址
typ	点赞类型

Types

type Article

type Article struct {
	Id           uint   `gorm:"column:id;primaryKey" json:"id" form:"id"`                                                                 // 文章ID
	Title        string `gorm:"column:title;type:varchar(200);comment:文章标题" json:"title" form:"title"`                                    // 文章标题
	Content      string `gorm:"-" json:"content" form:"content"`                                                                          // 文章内容,禁止orm直接创建
	UserId       uint   `gorm:"column:user_id;comment:创建人id" json:"user_id" form:"user_id"`                                               // 创建人id
	GiveLikeNum  uint   `gorm:"column:give_like_num;comment:点赞次数" json:"give_like_num" form:"give_like_num"`                              // 点赞次数
	BrowseNum    uint   `gorm:"column:browse_num;not null;comment:浏览次数" json:"browse_num" form:"browse_num"`                              // 浏览次数
	CollectNum   uint   `gorm:"column:collect_num;not null;comment:收藏次数" json:"collect_num" form:"collect_num"`                           // 收藏次数
	ShareNum     uint   `gorm:"column:share_num;not null;comment:分享量" json:"share_num" form:"share_num"`                                  // 分享量
	CommentNum   int    `gorm:"column:comment_num;not null;comment:评论数量" json:"comment_num" form:"comment_num"`                           // 评论数量
	DonotComment uint8  `gorm:"do_not_comment;type:TINYINT UNSIGNED;not null;comment:是否禁止评论" json:"do_not_comment" form:"do_not_comment"` // 是否禁止评论
	IsDelete     int8   `gorm:"column:is_delete;type:TINYINT UNSIGNED;comment:是否删除 1-删除 0-未删除" json:"is_delete" form:"is_delete"`         // 是否删除 1-删除 0-未删除
	CreatedAt    string `gorm:"column:created_at;type:datetime;comment:创建时间" json:"created_at" form:"created_at"`                         // 创建时间
	UpdatedAt    string `gorm:"column:updated_at;type:datetime;comment:更新时间" json:"updated_at" form:"updated_at"`                         // 更新时间
}

文章主表,用于展示文章的主要信息

func Info added in v0.0.17

func Info(id uint) (*Article, error)

获取文章详情操作

id	文章ID

func (*Article) TableName

func (c *Article) TableName() string

表名

type ArticleBrowse added in v0.0.17

type ArticleBrowse struct {
	Id        uint   `gorm:"column:id;not null;autoIncrement;primaryKey" json:"id" form:"id"`
	UserId    uint   `gorm:"column:user_id;index:user_id;comment:浏览用户id" json:"user_id" form:"user_id"`           //浏览用户id
	ArticleId uint   `gorm:"column:article_id;index:article_id;comment:文章id" json:"article_id" form:"article_id"` //文章id
	Ip        string `gorm:"column:ip;type:VARCHAR(20);comment:IPV4地址" json:"ip" form:"ip"`                       //IPV4地址
	CreatedAt string `gorm:"column:created_at;type:DATETIME;comment:查看时间" json:"created_at" form:"created_at"`    //查看时间
}

文章浏览记录表

func (*ArticleBrowse) TableName added in v0.0.17

func (c *ArticleBrowse) TableName() string

表名

type ArticleComment

type ArticleComment struct {
	Id          uint   `gorm:"column:id;primaryKey;not null;autoIncrement" json:"id" form:"id"`                                  // 评论ID
	ArticleId   uint   `gorm:"column:article_id;not null;comment:文章ID" json:"article_id" form:"article_id"`                      // 文章ID
	CommentId   uint   `gorm:"column:comment_id;not null;comment:回复评论ID" json:"comment_id" form:"comment_id"`                    // 回复评论ID
	UserId      uint   `gorm:"column:user_id;not null;comment:创建人id" json:"user_id" form:"user_id"`                              // 创建人id
	GiveLikeNum uint   `gorm:"column:give_like_num;not null;comment:点赞次数" json:"give_like_num" form:"give_like_num"`             // 点赞次数
	Content     string `gorm:"column:content;type:varchar(200);comment:文章评论 200字内" json:"content" form:"content"`                // 文章评论 200字内
	IsDelete    int8   `gorm:"column:is_delete;type:TINYINT UNSIGNED;comment:是否删除 1-删除 0-未删除" json:"is_delete" form:"is_delete"` // 是否删除 1-删除 0-未删除
	CreatedAt   string `gorm:"column:created_at;type:datetime;comment:创建时间" json:"created_at" form:"created_at"`                 // 创建时间
}

文章评论表

func (*ArticleComment) TableName

func (c *ArticleComment) TableName() string

表名

type ArticleContent

type ArticleContent struct {
	ArticleId uint   `gorm:"column:id;primaryKey;comment:文章ID" json:"id" form:"id"`                   // 文章ID
	Content   string `gorm:"column:content;type:longtext;comment:文章内容" json:"content" form:"content"` // 文章内容
}

文章详情表,用于存储文章的详情内容

func (*ArticleContent) TableName

func (c *ArticleContent) TableName() string

表名

type ArticleEdits

type ArticleEdits struct {
	Id          uint   `gorm:"column:id;primaryKey;not null;autoIncrement" json:"id" form:"id"`       // 自增ID
	ArticleId   uint   `gorm:"column:article_id;comment:文章ID" json:"article_id" form:"article_id"`    // 文章ID
	Title       string `gorm:"column:title;type:varchar(200);comment:文章标题" json:"title" form:"title"` // 文章标题
	Content     string `gorm:"-" json:"content" form:"content"`                                       // 文章详情,不直接使用orm进行存储
	UserId      uint   `gorm:"column:user_id;comment:创建人id" json:"user_id" form:"user_id"`            // 创建人id
	AuditStatus uint8  ``                                                                             // 审核状态 0-未审核 98-审核拒绝 99-审核通过 97-放弃审核(编辑以后再次编辑时,会将之前的编辑文章调整为放弃审核状态)
	/* 255-byte string literal not displayed */
	AuditError  string `gorm:"column:audit_error;type:VARCHAR(200);comment:审核通过/拒绝原因" json:"audit_error" form:"audit_error"` // 审核通过/拒绝原因
	AuditUserId uint   `gorm:"column:audit_user_id;comment:审核人id" json:"audit_user_id" form:"audit_user_id"`                 // 审核人id
	CreatedAt   string `gorm:"column:created_at;type:datetime;comment:创建时间" json:"created_at" form:"created_at"`             // 创建时间
	UpdatedAt   string `gorm:"column:updated_at;type:datetime;comment:审核时间" json:"updated_at" form:"updated_at"`             // 审核时间
}

文章编辑表,该表每次编辑都会重新生成一条记录

func EditInfo added in v0.0.17

func EditInfo(id uint, con bool) (*ArticleEdits, error)

获取edit详情信息

id	edit详情ID
con	是否要获取详情

func (*ArticleEdits) TableName

func (c *ArticleEdits) TableName() string

表名

type ArticleEditsContent

type ArticleEditsContent struct {
	ArticleEditsId uint   `gorm:"column:id;primaryKey;comment:文章编辑条目ID" json:"id" form:"id"`               // 文章编辑条目ID
	Content        string `gorm:"column:content;type:longtext;comment:文章内容" json:"content" form:"content"` // 文章内容
}

文章编辑表对应的内容,审核通过后会将该内容替换到文章表中

func (*ArticleEditsContent) TableName

func (c *ArticleEditsContent) TableName() string

表名

type ArticleLike added in v0.0.17

type ArticleLike struct {
	Id        uint   `gorm:"column:id;not null;autoIncrement;primaryKey" json:"id" form:"id"`
	UserId    uint   `gorm:"column:user_id;index:like_index,unique;comment:点赞用户id" json:"user_id" form:"user_id"`               // 点赞用户id
	ArticleId uint   `gorm:"column:article_id;index:like_index,unique;comment:点赞对象id" json:"article_id" form:"article_id"`      // 点赞对象id
	LikeType  uint   `gorm:"column:like_type;index:like_index,unique;comment:点赞类型【0~10已被占用】" json:"like_type" form:"like_type"` // 点赞类型【0~10已被占用】
	Ip        string `gorm:"column:ip;type:VARCHAR(20);comment:IPV4地址" json:"ip" form:"ip"`                                     // IPV4地址
	CreatedAt string `gorm:"column:created_at;type:DATETIME;comment:查看时间" json:"created_at" form:"created_at"`                  // 查看时间
}

文章浏览记录表

func (*ArticleLike) TableName added in v0.0.17

func (c *ArticleLike) TableName() string

表名

type Config added in v0.0.17

type Config struct {
	DB                      *gorm.DB // 数据库操作句柄
	ArticleName             string   // 文章主表表名
	ArticleContentName      string   // 文章内容表表名
	ArticleCommentName      string   // 文章评论表表名
	ArticleEditsName        string   // 文章内容修改表表名
	ArticleEditsContentName string   // 文章内容修改表(内容)表名
	ArticleBrowseName       string   // 文章浏览记录表
	ArticleLikeName         string   // 文章点赞记录表
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL