model

package
v0.0.0-...-53c3cd1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB 全局数据库连接

View Source
var RDB *redis.Client

RDB 全局Redis客户端

Functions

func InitDB

func InitDB(config config.DatabaseConfig) (*gorm.DB, error)

InitDB 初始化数据库连接

func InitRedis

func InitRedis(config config.RedisConfig) (*redis.Client, error)

InitRedis 初始化Redis连接

Types

type Article

type Article struct {
	ArticleID      int64          `gorm:"column:article_id;primaryKey;autoIncrement" json:"article_id"`
	UserID         int            `gorm:"column:user_id;not null" json:"user_id"`
	Title          string         `gorm:"column:title;size:200;not null" json:"title"`
	ArticleKey     string         `gorm:"column:article_key;size:200;not null;unique" json:"article_key"`
	Summary        string         `gorm:"column:summary;size:500" json:"summary"`
	Thumbnail      string         `gorm:"column:thumbnail;size:255" json:"thumbnail"`
	Status         int8           `gorm:"column:status;not null;default:1" json:"status"`
	ArticleType    int8           `gorm:"column:article_type;not null;default:1" json:"article_type"`
	ViewCount      int            `gorm:"column:view_count;not null;default:0" json:"view_count"`
	LikeCount      int            `gorm:"column:like_count;not null;default:0" json:"like_count"`
	CommentCount   int            `gorm:"column:comment_count;not null;default:0" json:"comment_count"`
	AllowComment   bool           `gorm:"column:allow_comment;not null;default:true" json:"allow_comment"`
	IsTop          bool           `gorm:"column:is_top;not null;default:false" json:"is_top"`
	IsRecommend    bool           `gorm:"column:is_recommend;not null;default:false" json:"is_recommend"`
	SEOTitle       string         `gorm:"column:seo_title;size:100" json:"seo_title"`
	SEOKeywords    string         `gorm:"column:seo_keywords;size:200" json:"seo_keywords"`
	SEODescription string         `gorm:"column:seo_description;size:300" json:"seo_description"`
	SourceURL      string         `gorm:"column:source_url;size:255" json:"source_url"`
	SourceName     string         `gorm:"column:source_name;size:100" json:"source_name"`
	PublishTime    time.Time      `gorm:"column:publish_time" json:"publish_time"`
	CreatedAt      time.Time      `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt      time.Time      `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
	User           User           `gorm:"foreignKey:UserID" json:"user"`
	Content        ArticleContent `gorm:"foreignKey:ArticleID" json:"content"`
	Categories     []Category     `` /* 151-byte string literal not displayed */
	Tags           []Tag          `` /* 129-byte string literal not displayed */
}

Article 文章模型

func (Article) TableName

func (Article) TableName() string

TableName 指定表名

type ArticleContent

type ArticleContent struct {
	ContentID     int64     `gorm:"column:content_id;primaryKey;autoIncrement" json:"content_id"`
	ArticleID     int64     `gorm:"column:article_id;not null" json:"article_id"`
	Content       string    `gorm:"column:content;not null" json:"content"`
	ContentFormat int8      `gorm:"column:content_format;not null;default:1" json:"content_format"`
	Version       int       `gorm:"column:version;not null;default:1" json:"version"`
	IsCurrent     bool      `gorm:"column:is_current;not null;default:true" json:"is_current"`
	CreatedAt     time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt     time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
}

ArticleContent 文章内容模型

func (ArticleContent) TableName

func (ArticleContent) TableName() string

TableName 指定表名

type ArticleCreateForm

type ArticleCreateForm struct {
	Title          string `json:"title" binding:"required,max=200" example:"文章标题"`
	ArticleKey     string `json:"article_key" binding:"required,max=200" example:"article-key"`
	Content        string `json:"content" binding:"required" example:"文章内容..."`
	ContentFormat  int8   `json:"content_format" binding:"required,oneof=1 2" example:"1"`
	Summary        string `json:"summary" binding:"omitempty,max=500" example:"文章摘要..."`
	Thumbnail      string `json:"thumbnail" binding:"omitempty,max=255" example:"http://example.com/image.jpg"`
	Status         int8   `json:"status" binding:"required,oneof=1 2 3 4" example:"1"`
	ArticleType    int8   `json:"article_type" binding:"required,oneof=1 2 3 4" example:"1"`
	CategoryIDs    []int  `json:"category_ids" binding:"required" example:"1,2"`
	TagIDs         []int  `json:"tag_ids" binding:"omitempty" example:"1,2,3"`
	AllowComment   bool   `json:"allow_comment" example:"true"`
	IsTop          bool   `json:"is_top" example:"false"`
	IsRecommend    bool   `json:"is_recommend" example:"false"`
	SEOTitle       string `json:"seo_title" binding:"omitempty,max=100" example:"SEO标题"`
	SEOKeywords    string `json:"seo_keywords" binding:"omitempty,max=200" example:"关键词1,关键词2"`
	SEODescription string `json:"seo_description" binding:"omitempty,max=300" example:"SEO描述..."`
	SourceURL      string `json:"source_url" binding:"omitempty,max=255" example:"http://example.com/source"`
	SourceName     string `json:"source_name" binding:"omitempty,max=100" example:"来源网站"`
}

ArticleCreateForm 文章创建表单

type ArticleDetailResponse

type ArticleDetailResponse struct {
	ArticleResponse
	Content        string `json:"content"`
	ContentFormat  int8   `json:"content_format"`
	SEOTitle       string `json:"seo_title"`
	SEOKeywords    string `json:"seo_keywords"`
	SEODescription string `json:"seo_description"`
	SourceURL      string `json:"source_url"`
	SourceName     string `json:"source_name"`
}

ArticleDetailResponse 文章详情响应

type ArticleQueryParams

type ArticleQueryParams struct {
	Keyword     string `form:"keyword" json:"keyword"`
	Status      int8   `form:"status" json:"status"`
	CategoryID  int    `form:"category_id" json:"category_id"`
	TagID       int    `form:"tag_id" json:"tag_id"`
	UserID      int    `form:"user_id" json:"user_id"`
	ArticleType int8   `form:"article_type" json:"article_type"`
	IsTop       *bool  `form:"is_top" json:"is_top"`
	IsRecommend *bool  `form:"is_recommend" json:"is_recommend"`
	StartTime   string `form:"start_time" json:"start_time"`
	EndTime     string `form:"end_time" json:"end_time"`
	OrderBy     string `form:"order_by" json:"order_by"`
	Page        int    `form:"page" json:"page" binding:"required,min=1" default:"1"`
	PageSize    int    `form:"page_size" json:"page_size" binding:"required,min=1,max=100" default:"10"`
}

ArticleQueryParams 文章查询参数

type ArticleResponse

type ArticleResponse struct {
	ArticleID       int64     `json:"article_id"`
	UserID          int       `json:"user_id"`
	Author          string    `json:"author"`
	Title           string    `json:"title"`
	ArticleKey      string    `json:"article_key"`
	Summary         string    `json:"summary"`
	Thumbnail       string    `json:"thumbnail"`
	Status          int8      `json:"status"`
	StatusName      string    `json:"status_name"`
	ArticleType     int8      `json:"article_type"`
	ArticleTypeName string    `json:"article_type_name"`
	ViewCount       int       `json:"view_count"`
	LikeCount       int       `json:"like_count"`
	CommentCount    int       `json:"comment_count"`
	AllowComment    bool      `json:"allow_comment"`
	IsTop           bool      `json:"is_top"`
	IsRecommend     bool      `json:"is_recommend"`
	PublishTime     time.Time `json:"publish_time"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	Categories      []string  `json:"categories"`
	Tags            []string  `json:"tags"`
}

ArticleResponse 文章信息响应

type ArticleUpdateForm

type ArticleUpdateForm struct {
	Title          string `json:"title" binding:"omitempty,max=200" example:"文章标题"`
	ArticleKey     string `json:"article_key" binding:"omitempty,max=200" example:"article-key"`
	Content        string `json:"content" binding:"omitempty" example:"文章内容..."`
	ContentFormat  int8   `json:"content_format" binding:"omitempty,oneof=1 2" example:"1"`
	Summary        string `json:"summary" binding:"omitempty,max=500" example:"文章摘要..."`
	Thumbnail      string `json:"thumbnail" binding:"omitempty,max=255" example:"http://example.com/image.jpg"`
	Status         int8   `json:"status" binding:"omitempty,oneof=1 2 3 4" example:"1"`
	ArticleType    int8   `json:"article_type" binding:"omitempty,oneof=1 2 3 4" example:"1"`
	CategoryIDs    []int  `json:"category_ids" binding:"omitempty" example:"1,2"`
	TagIDs         []int  `json:"tag_ids" binding:"omitempty" example:"1,2,3"`
	AllowComment   bool   `json:"allow_comment" example:"true"`
	IsTop          bool   `json:"is_top" example:"false"`
	IsRecommend    bool   `json:"is_recommend" example:"false"`
	SEOTitle       string `json:"seo_title" binding:"omitempty,max=100" example:"SEO标题"`
	SEOKeywords    string `json:"seo_keywords" binding:"omitempty,max=200" example:"关键词1,关键词2"`
	SEODescription string `json:"seo_description" binding:"omitempty,max=300" example:"SEO描述..."`
	SourceURL      string `json:"source_url" binding:"omitempty,max=255" example:"http://example.com/source"`
	SourceName     string `json:"source_name" binding:"omitempty,max=100" example:"来源网站"`
}

ArticleUpdateForm 文章更新表单

type Category

type Category struct {
	CategoryID     int         `gorm:"column:category_id;primaryKey;autoIncrement" json:"category_id"`
	ParentID       *int        `gorm:"column:parent_id" json:"parent_id"`
	CategoryName   string      `gorm:"column:category_name;size:50;not null" json:"category_name"`
	CategoryKey    string      `gorm:"column:category_key;size:50;not null;unique" json:"category_key"`
	Path           string      `gorm:"column:path;not null" json:"path"`
	Description    string      `gorm:"column:description" json:"description"`
	Thumbnail      string      `gorm:"column:thumbnail;size:255" json:"thumbnail"`
	Icon           string      `gorm:"column:icon;size:100" json:"icon"`
	SortOrder      int16       `gorm:"column:sort_order;not null;default:0" json:"sort_order"`
	IsVisible      bool        `gorm:"column:is_visible;not null;default:true" json:"is_visible"`
	SEOTitle       string      `gorm:"column:seo_title;size:100" json:"seo_title"`
	SEOKeywords    string      `gorm:"column:seo_keywords;size:200" json:"seo_keywords"`
	SEODescription string      `gorm:"column:seo_description;size:300" json:"seo_description"`
	ArticleCount   int         `gorm:"column:article_count;not null;default:0" json:"article_count"`
	CreatedAt      time.Time   `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt      time.Time   `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
	Parent         *Category   `gorm:"foreignKey:ParentID" json:"parent,omitempty"`
	Children       []*Category `gorm:"foreignKey:ParentID" json:"children,omitempty"`
	Articles       []Article   `` /* 159-byte string literal not displayed */
}

Category 分类模型

func (Category) TableName

func (Category) TableName() string

TableName 指定表名

type CategoryCreateForm

type CategoryCreateForm struct {
	ParentID       *int   `json:"parent_id" example:"0"`
	CategoryName   string `json:"category_name" binding:"required,max=50" example:"技术文章"`
	CategoryKey    string `json:"category_key" binding:"required,max=50" example:"tech"`
	Description    string `json:"description" binding:"omitempty" example:"技术相关文章分类"`
	Thumbnail      string `json:"thumbnail" binding:"omitempty,max=255" example:"http://example.com/image.jpg"`
	Icon           string `json:"icon" binding:"omitempty,max=100" example:"code"`
	SortOrder      int16  `json:"sort_order" binding:"omitempty" example:"1"`
	IsVisible      bool   `json:"is_visible" example:"true"`
	SEOTitle       string `json:"seo_title" binding:"omitempty,max=100" example:"技术文章分类"`
	SEOKeywords    string `json:"seo_keywords" binding:"omitempty,max=200" example:"技术,编程,开发"`
	SEODescription string `json:"seo_description" binding:"omitempty,max=300" example:"包含各种技术相关文章的分类"`
}

CategoryCreateForm 分类创建表单

type CategoryDetailResponse

type CategoryDetailResponse struct {
	CategoryResponse
	SEOTitle       string `json:"seo_title"`
	SEOKeywords    string `json:"seo_keywords"`
	SEODescription string `json:"seo_description"`
	Path           string `json:"path"`
}

CategoryDetailResponse 分类详情响应

type CategoryResponse

type CategoryResponse struct {
	CategoryID   int                 `json:"category_id"`
	ParentID     *int                `json:"parent_id"`
	CategoryName string              `json:"category_name"`
	CategoryKey  string              `json:"category_key"`
	Description  string              `json:"description"`
	Thumbnail    string              `json:"thumbnail"`
	Icon         string              `json:"icon"`
	SortOrder    int16               `json:"sort_order"`
	IsVisible    bool                `json:"is_visible"`
	ArticleCount int                 `json:"article_count"`
	CreatedAt    time.Time           `json:"created_at"`
	UpdatedAt    time.Time           `json:"updated_at"`
	Children     []*CategoryResponse `json:"children,omitempty"`
}

CategoryResponse 分类信息响应

type CategoryUpdateForm

type CategoryUpdateForm struct {
	ParentID       *int   `json:"parent_id" example:"0"`
	CategoryName   string `json:"category_name" binding:"omitempty,max=50" example:"技术文章"`
	CategoryKey    string `json:"category_key" binding:"omitempty,max=50" example:"tech"`
	Description    string `json:"description" binding:"omitempty" example:"技术相关文章分类"`
	Thumbnail      string `json:"thumbnail" binding:"omitempty,max=255" example:"http://example.com/image.jpg"`
	Icon           string `json:"icon" binding:"omitempty,max=100" example:"code"`
	SortOrder      int16  `json:"sort_order" binding:"omitempty" example:"1"`
	IsVisible      bool   `json:"is_visible" example:"true"`
	SEOTitle       string `json:"seo_title" binding:"omitempty,max=100" example:"技术文章分类"`
	SEOKeywords    string `json:"seo_keywords" binding:"omitempty,max=200" example:"技术,编程,开发"`
	SEODescription string `json:"seo_description" binding:"omitempty,max=300" example:"包含各种技术相关文章的分类"`
}

CategoryUpdateForm 分类更新表单

type Comment

type Comment struct {
	CommentID    int64      `gorm:"column:comment_id;primaryKey;autoIncrement" json:"comment_id"`
	ArticleID    int64      `gorm:"column:article_id;not null" json:"article_id"`
	UserID       int        `gorm:"column:user_id;not null" json:"user_id"`
	ParentID     *int64     `gorm:"column:parent_id" json:"parent_id"`
	RootID       *int64     `gorm:"column:root_id" json:"root_id"`
	Content      string     `gorm:"column:content;not null" json:"content"`
	IPAddress    string     `gorm:"column:ip_address" json:"ip_address"`
	UserAgent    string     `gorm:"column:user_agent" json:"user_agent"`
	LikedCount   int        `gorm:"column:liked_count;not null;default:0" json:"liked_count"`
	IsApproved   bool       `gorm:"column:is_approved;not null;default:false" json:"is_approved"`
	IsAdminReply bool       `gorm:"column:is_admin_reply;not null;default:false" json:"is_admin_reply"`
	CreatedAt    time.Time  `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt    time.Time  `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
	User         User       `gorm:"foreignKey:UserID" json:"user"`
	Article      Article    `gorm:"foreignKey:ArticleID" json:"article"`
	Parent       *Comment   `gorm:"foreignKey:ParentID" json:"parent,omitempty"`
	Children     []*Comment `gorm:"foreignKey:ParentID" json:"children,omitempty"`
}

Comment 评论模型

func (Comment) TableName

func (Comment) TableName() string

TableName 指定表名

type CommentCreateForm

type CommentCreateForm struct {
	ArticleID int64  `json:"article_id" binding:"required" example:"1"`
	ParentID  *int64 `json:"parent_id" example:"0"`
	Content   string `json:"content" binding:"required" example:"这是一条评论内容"`
}

CommentCreateForm 评论创建表单

type CommentQueryParams

type CommentQueryParams struct {
	ArticleID  int64  `form:"article_id" json:"article_id"`
	UserID     int    `form:"user_id" json:"user_id"`
	IsApproved *bool  `form:"is_approved" json:"is_approved"`
	Keyword    string `form:"keyword" json:"keyword"`
	StartTime  string `form:"start_time" json:"start_time"`
	EndTime    string `form:"end_time" json:"end_time"`
	Page       int    `form:"page" json:"page" binding:"required,min=1" default:"1"`
	PageSize   int    `form:"page_size" json:"page_size" binding:"required,min=1,max=100" default:"10"`
}

CommentQueryParams 评论查询参数

type CommentResponse

type CommentResponse struct {
	CommentID    int64              `json:"comment_id"`
	ArticleID    int64              `json:"article_id"`
	ArticleTitle string             `json:"article_title"`
	UserID       int                `json:"user_id"`
	Username     string             `json:"username"`
	Nickname     string             `json:"nickname"`
	Avatar       string             `json:"avatar"`
	ParentID     *int64             `json:"parent_id"`
	RootID       *int64             `json:"root_id"`
	Content      string             `json:"content"`
	LikedCount   int                `json:"liked_count"`
	IsApproved   bool               `json:"is_approved"`
	IsAdminReply bool               `json:"is_admin_reply"`
	CreatedAt    time.Time          `json:"created_at"`
	UpdatedAt    time.Time          `json:"updated_at"`
	Children     []*CommentResponse `json:"children,omitempty"`
}

CommentResponse 评论信息响应

type CommentUpdateForm

type CommentUpdateForm struct {
	Content    string `json:"content" binding:"required" example:"更新后的评论内容"`
	IsApproved bool   `json:"is_approved" example:"true"`
}

CommentUpdateForm 评论更新表单

type ConfigCreateForm

type ConfigCreateForm struct {
	ConfigName  string `json:"config_name" binding:"required,max=100" example:"网站名称"`
	ConfigKey   string `json:"config_key" binding:"required,max=100" example:"site_name"`
	ConfigValue string `json:"config_value" binding:"required" example:"我的博客"`
	ValueType   int8   `json:"value_type" binding:"required,oneof=1 2 3 4" example:"1"`
	ConfigGroup string `json:"config_group" binding:"required,max=50" example:"site"`
	IsBuiltin   bool   `json:"is_builtin" example:"false"`
	IsFrontend  bool   `json:"is_frontend" example:"true"`
	SortOrder   int16  `json:"sort_order" binding:"omitempty" example:"1"`
	Remark      string `json:"remark" binding:"omitempty,max=200" example:"网站名称配置"`
}

ConfigCreateForm 配置创建表单

type ConfigQueryParams

type ConfigQueryParams struct {
	ConfigGroup string `form:"config_group" json:"config_group"`
	ConfigKey   string `form:"config_key" json:"config_key"`
	Keyword     string `form:"keyword" json:"keyword"`
	IsFrontend  *bool  `form:"is_frontend" json:"is_frontend"`
	IsBuiltin   *bool  `form:"is_builtin" json:"is_builtin"`
	Page        int    `form:"page" json:"page" binding:"required,min=1" default:"1"`
	PageSize    int    `form:"page_size" json:"page_size" binding:"required,min=1,max=100" default:"10"`
}

ConfigQueryParams 配置查询参数

type ConfigResponse

type ConfigResponse struct {
	ConfigID    int       `json:"config_id"`
	ConfigName  string    `json:"config_name"`
	ConfigKey   string    `json:"config_key"`
	ConfigValue string    `json:"config_value"`
	ValueType   int8      `json:"value_type"`
	ConfigGroup string    `json:"config_group"`
	IsBuiltin   bool      `json:"is_builtin"`
	IsFrontend  bool      `json:"is_frontend"`
	SortOrder   int16     `json:"sort_order"`
	Remark      string    `json:"remark"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

ConfigResponse 配置信息响应

type ConfigUpdateForm

type ConfigUpdateForm struct {
	ConfigName  string `json:"config_name" binding:"omitempty,max=100" example:"网站名称"`
	ConfigValue string `json:"config_value" binding:"required" example:"我的博客"`
	ValueType   int8   `json:"value_type" binding:"omitempty,oneof=1 2 3 4" example:"1"`
	ConfigGroup string `json:"config_group" binding:"omitempty,max=50" example:"site"`
	IsFrontend  bool   `json:"is_frontend" example:"true"`
	SortOrder   int16  `json:"sort_order" binding:"omitempty" example:"1"`
	Remark      string `json:"remark" binding:"omitempty,max=200" example:"网站名称配置"`
}

ConfigUpdateForm 配置更新表单

type CustomClaims

type CustomClaims struct {
	UserID   int    `json:"user_id"`
	Username string `json:"username"`
	RoleIDs  []int  `json:"role_ids"`
	jwt.RegisteredClaims
}

CustomClaims 自定义JWT声明

type EnumItem

type EnumItem struct {
	Value int    `json:"value"` // 枚举值
	Label string `json:"label"` // 枚举标签
}

EnumItem 枚举项结构

type File

type File struct {
	FileID       int64     `gorm:"column:file_id;primaryKey;autoIncrement" json:"file_id"`
	UserID       *int      `gorm:"column:user_id" json:"user_id"`
	OriginalName string    `gorm:"column:original_name;size:255;not null" json:"original_name"`
	FileName     string    `gorm:"column:file_name;size:100;not null" json:"file_name"`
	FilePath     string    `gorm:"column:file_path;size:255;not null" json:"file_path"`
	FileExt      string    `gorm:"column:file_ext;size:20;not null" json:"file_ext"`
	FileSize     int64     `gorm:"column:file_size;not null" json:"file_size"`
	MimeType     string    `gorm:"column:mime_type;size:100;not null" json:"mime_type"`
	StorageType  int8      `gorm:"column:storage_type;not null;default:1" json:"storage_type"`
	UseTimes     int       `gorm:"column:use_times;not null;default:0" json:"use_times"`
	IsPublic     bool      `gorm:"column:is_public;not null;default:true" json:"is_public"`
	CreatedAt    time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt    time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
	User         *User     `gorm:"foreignKey:UserID" json:"user,omitempty"`
}

File 文件模型

func (File) TableName

func (File) TableName() string

TableName 指定表名

type FileQueryParams

type FileQueryParams struct {
	UserID      *int   `form:"user_id" json:"user_id"`
	FileExt     string `form:"file_ext" json:"file_ext"`
	StorageType *int8  `form:"storage_type" json:"storage_type"`
	IsPublic    *bool  `form:"is_public" json:"is_public"`
	Keyword     string `form:"keyword" json:"keyword"`
	StartTime   string `form:"start_time" json:"start_time"`
	EndTime     string `form:"end_time" json:"end_time"`
	Page        int    `form:"page" json:"page" binding:"required,min=1" default:"1"`
	PageSize    int    `form:"page_size" json:"page_size" binding:"required,min=1,max=100" default:"10"`
}

FileQueryParams 文件查询参数

type FileResponse

type FileResponse struct {
	FileID       int64     `json:"file_id"`
	UserID       *int      `json:"user_id"`
	Username     string    `json:"username,omitempty"`
	OriginalName string    `json:"original_name"`
	FileName     string    `json:"file_name"`
	FilePath     string    `json:"file_path"`
	FileExt      string    `json:"file_ext"`
	FileSize     int64     `json:"file_size"`
	MimeType     string    `json:"mime_type"`
	StorageType  int8      `json:"storage_type"`
	UseTimes     int       `json:"use_times"`
	IsPublic     bool      `json:"is_public"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	URL          string    `json:"url"`
}

FileResponse 文件信息响应

type FileUploadForm

type FileUploadForm struct {
	IsPublic bool `form:"is_public" json:"is_public" example:"true"`
}

FileUploadForm 文件上传表单

type IDRequest

type IDRequest struct {
	ID int `json:"id" binding:"required" example:"1"` // ID
}

IDRequest ID请求

type IDsRequest

type IDsRequest struct {
	IDs []int `json:"ids" binding:"required" example:"[1,2,3]"` // ID列表
}

IDsRequest IDs请求

type LoginResult

type LoginResult struct {
	Token        string `json:"token"`         // 访问令牌
	RefreshToken string `json:"refresh_token"` // 刷新令牌
	ExpiresIn    int    `json:"expires_in"`    // 过期时间(秒)
	TokenType    string `json:"token_type"`    // 令牌类型
}

LoginResult 登录结果

type Option

type Option struct {
	Label string      `json:"label"` // 选项标签
	Value interface{} `json:"value"` // 选项值
}

Option 选项结构

type PageResult

type PageResult struct {
	List     interface{} `json:"list"`      // 数据列表
	Total    int64       `json:"total"`     // 总记录数
	Page     int         `json:"page"`      // 当前页码
	PageSize int         `json:"page_size"` // 每页记录数
	Pages    int         `json:"pages"`     // 总页数
}

PageResult 分页结果

func NewPageResult

func NewPageResult(list interface{}, total int64, page, pageSize int) *PageResult

NewPageResult 创建分页结果

type PasswordUpdateForm

type PasswordUpdateForm struct {
	OldPassword string `json:"old_password" binding:"required" example:"123456"`
	NewPassword string `json:"new_password" binding:"required,min=6,max=20" example:"654321"`
}

PasswordUpdateForm 密码更新表单

type Permission

type Permission struct {
	PermID    int           `gorm:"column:perm_id;primaryKey;autoIncrement" json:"perm_id"`
	PermName  string        `gorm:"column:perm_name;size:50;not null" json:"perm_name"`
	PermKey   string        `gorm:"column:perm_key;size:50;not null;unique" json:"perm_key"`
	PermType  int8          `gorm:"column:perm_type;not null;default:1" json:"perm_type"`
	ParentID  *int          `gorm:"column:parent_id" json:"parent_id"`
	Path      string        `gorm:"column:path" json:"path"`
	APIPath   string        `gorm:"column:api_path;size:200" json:"api_path"`
	Component string        `gorm:"column:component;size:100" json:"component"`
	Perms     string        `gorm:"column:perms;size:100" json:"perms"`
	Icon      string        `gorm:"column:icon;size:100" json:"icon"`
	MenuSort  int16         `gorm:"column:menu_sort;not null;default:0" json:"menu_sort"`
	IsVisible bool          `gorm:"column:is_visible;not null;default:true" json:"is_visible"`
	IsEnabled bool          `gorm:"column:is_enabled;not null;default:true" json:"is_enabled"`
	CreatedAt time.Time     `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time     `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
	Roles     []Role        `` /* 130-byte string literal not displayed */
	Children  []*Permission `gorm:"-" json:"children,omitempty"`
}

Permission 权限模型

func (Permission) TableName

func (Permission) TableName() string

TableName 指定表名

type PermissionCreateForm

type PermissionCreateForm struct {
	PermName  string `json:"perm_name" binding:"required,max=50" example:"用户管理"`
	PermKey   string `json:"perm_key" binding:"required,max=50" example:"system:user:list"`
	PermType  int8   `json:"perm_type" binding:"required,oneof=1 2 3" example:"1"`
	ParentID  *int   `json:"parent_id" example:"0"`
	APIPath   string `json:"api_path" binding:"omitempty,max=200" example:"/api/v1/users"`
	Component string `json:"component" binding:"omitempty,max=100" example:"system/user/index"`
	Perms     string `json:"perms" binding:"omitempty,max=100" example:"system:user:list"`
	Icon      string `json:"icon" binding:"omitempty,max=100" example:"user"`
	MenuSort  int16  `json:"menu_sort" binding:"omitempty" example:"1"`
	IsVisible bool   `json:"is_visible" example:"true"`
	IsEnabled bool   `json:"is_enabled" example:"true"`
}

PermissionCreateForm 权限创建表单

type PermissionResponse

type PermissionResponse struct {
	PermID    int                   `json:"perm_id"`
	PermName  string                `json:"perm_name"`
	PermKey   string                `json:"perm_key"`
	PermType  int8                  `json:"perm_type"`
	ParentID  *int                  `json:"parent_id"`
	Path      string                `json:"path"`
	APIPath   string                `json:"api_path"`
	Component string                `json:"component"`
	Perms     string                `json:"perms"`
	Icon      string                `json:"icon"`
	MenuSort  int16                 `json:"menu_sort"`
	IsVisible bool                  `json:"is_visible"`
	IsEnabled bool                  `json:"is_enabled"`
	CreatedAt time.Time             `json:"created_at"`
	UpdatedAt time.Time             `json:"updated_at"`
	Children  []*PermissionResponse `json:"children,omitempty"`
}

PermissionResponse 权限信息响应

type PermissionUpdateForm

type PermissionUpdateForm struct {
	PermName  string `json:"perm_name" binding:"omitempty,max=50" example:"用户管理"`
	PermKey   string `json:"perm_key" binding:"omitempty,max=50" example:"system:user:list"`
	PermType  int8   `json:"perm_type" binding:"omitempty,oneof=1 2 3" example:"1"`
	ParentID  *int   `json:"parent_id" example:"0"`
	APIPath   string `json:"api_path" binding:"omitempty,max=200" example:"/api/v1/users"`
	Component string `json:"component" binding:"omitempty,max=100" example:"system/user/index"`
	Perms     string `json:"perms" binding:"omitempty,max=100" example:"system:user:list"`
	Icon      string `json:"icon" binding:"omitempty,max=100" example:"user"`
	MenuSort  int16  `json:"menu_sort" binding:"omitempty" example:"1"`
	IsVisible bool   `json:"is_visible" example:"true"`
	IsEnabled bool   `json:"is_enabled" example:"true"`
}

PermissionUpdateForm 权限更新表单

type RefreshClaims

type RefreshClaims struct {
	UserID int `json:"user_id"`
	jwt.RegisteredClaims
}

RefreshClaims 刷新令牌声明

type RefreshTokenResult

type RefreshTokenResult struct {
	Token     string `json:"token"`      // 新的访问令牌
	ExpiresIn int    `json:"expires_in"` // 过期时间(秒)
}

RefreshTokenResult 刷新令牌结果

type Role

type Role struct {
	RoleID      int          `gorm:"column:role_id;primaryKey;autoIncrement" json:"role_id"`
	RoleName    string       `gorm:"column:role_name;size:50;not null;unique" json:"role_name"`
	RoleKey     string       `gorm:"column:role_key;size:50;not null;unique" json:"role_key"`
	RoleSort    int16        `gorm:"column:role_sort;not null;default:0" json:"role_sort"`
	RoleDesc    string       `gorm:"column:role_desc;size:200" json:"role_desc"`
	IsDefault   bool         `gorm:"column:is_default;not null;default:false" json:"is_default"`
	IsEnabled   bool         `gorm:"column:is_enabled;not null;default:true" json:"is_enabled"`
	CreatedAt   time.Time    `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt   time.Time    `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
	Permissions []Permission `` /* 136-byte string literal not displayed */
	Users       []User       `gorm:"many2many:sys_user_roles;foreignKey:RoleID;joinForeignKey:RoleID;References:UserID;joinReferences:UserID" json:"users"`
}

Role 角色模型

func (Role) TableName

func (Role) TableName() string

TableName 指定表名

type RoleCreateForm

type RoleCreateForm struct {
	RoleName  string `json:"role_name" binding:"required,max=50" example:"编辑角色"`
	RoleKey   string `json:"role_key" binding:"required,max=50" example:"editor"`
	RoleSort  int16  `json:"role_sort" binding:"omitempty" example:"5"`
	RoleDesc  string `json:"role_desc" binding:"omitempty,max=200" example:"负责内容编辑的角色"`
	IsDefault bool   `json:"is_default" example:"false"`
	IsEnabled bool   `json:"is_enabled" example:"true"`
}

RoleCreateForm 角色创建表单

type RolePermissionForm

type RolePermissionForm struct {
	PermissionIDs []int `json:"permission_ids" binding:"required" example:"1,2,3,4"`
}

RolePermissionForm 角色权限分配表单

type RoleResponse

type RoleResponse struct {
	RoleID      int       `json:"role_id"`
	RoleName    string    `json:"role_name"`
	RoleKey     string    `json:"role_key"`
	RoleSort    int16     `json:"role_sort"`
	RoleDesc    string    `json:"role_desc"`
	IsDefault   bool      `json:"is_default"`
	IsEnabled   bool      `json:"is_enabled"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Permissions []string  `json:"permissions,omitempty"`
}

RoleResponse 角色信息响应

type RoleUpdateForm

type RoleUpdateForm struct {
	RoleName  string `json:"role_name" binding:"omitempty,max=50" example:"编辑角色"`
	RoleKey   string `json:"role_key" binding:"omitempty,max=50" example:"editor"`
	RoleSort  int16  `json:"role_sort" binding:"omitempty" example:"5"`
	RoleDesc  string `json:"role_desc" binding:"omitempty,max=200" example:"负责内容编辑的角色"`
	IsDefault bool   `json:"is_default" example:"false"`
	IsEnabled bool   `json:"is_enabled" example:"true"`
}

RoleUpdateForm 角色更新表单

type StatusRequest

type StatusRequest struct {
	Status int8 `json:"status" binding:"required" example:"1"` // 状态值
}

StatusRequest 状态请求

type SysConfig

type SysConfig struct {
	ConfigID    int       `gorm:"column:config_id;primaryKey;autoIncrement" json:"config_id"`
	ConfigName  string    `gorm:"column:config_name;size:100;not null" json:"config_name"`
	ConfigKey   string    `gorm:"column:config_key;size:100;not null;unique" json:"config_key"`
	ConfigValue string    `gorm:"column:config_value;not null" json:"config_value"`
	ValueType   int8      `gorm:"column:value_type;not null;default:1" json:"value_type"`
	ConfigGroup string    `gorm:"column:config_group;size:50;not null;default:'default'" json:"config_group"`
	IsBuiltin   bool      `gorm:"column:is_builtin;not null;default:false" json:"is_builtin"`
	IsFrontend  bool      `gorm:"column:is_frontend;not null;default:false" json:"is_frontend"`
	SortOrder   int16     `gorm:"column:sort_order;not null;default:0" json:"sort_order"`
	Remark      string    `gorm:"column:remark;size:200" json:"remark"`
	CreatedAt   time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt   time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
}

SysConfig 系统配置模型

func (SysConfig) TableName

func (SysConfig) TableName() string

TableName 指定表名

type Tag

type Tag struct {
	TagID        int       `gorm:"column:tag_id;primaryKey;autoIncrement" json:"tag_id"`
	TagName      string    `gorm:"column:tag_name;size:50;not null;unique" json:"tag_name"`
	TagKey       string    `gorm:"column:tag_key;size:50;not null;unique" json:"tag_key"`
	Description  string    `gorm:"column:description" json:"description"`
	Thumbnail    string    `gorm:"column:thumbnail;size:255" json:"thumbnail"`
	SortOrder    int16     `gorm:"column:sort_order;not null;default:0" json:"sort_order"`
	IsVisible    bool      `gorm:"column:is_visible;not null;default:true" json:"is_visible"`
	ArticleCount int       `gorm:"column:article_count;not null;default:0" json:"article_count"`
	CreatedAt    time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt    time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
	Articles     []Article `` /* 143-byte string literal not displayed */
}

Tag 标签模型

func (Tag) TableName

func (Tag) TableName() string

TableName 指定表名

type TagCreateForm

type TagCreateForm struct {
	TagName     string `json:"tag_name" binding:"required,max=50" example:"Go语言"`
	TagKey      string `json:"tag_key" binding:"required,max=50" example:"golang"`
	Description string `json:"description" binding:"omitempty" example:"Go语言相关文章标签"`
	Thumbnail   string `json:"thumbnail" binding:"omitempty,max=255" example:"http://example.com/image.jpg"`
	SortOrder   int16  `json:"sort_order" binding:"omitempty" example:"1"`
	IsVisible   bool   `json:"is_visible" example:"true"`
}

TagCreateForm 标签创建表单

type TagResponse

type TagResponse struct {
	TagID        int       `json:"tag_id"`
	TagName      string    `json:"tag_name"`
	TagKey       string    `json:"tag_key"`
	Description  string    `json:"description"`
	Thumbnail    string    `json:"thumbnail"`
	SortOrder    int16     `json:"sort_order"`
	IsVisible    bool      `json:"is_visible"`
	ArticleCount int       `json:"article_count"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

TagResponse 标签信息响应

type TagUpdateForm

type TagUpdateForm struct {
	TagName     string `json:"tag_name" binding:"omitempty,max=50" example:"Go语言"`
	TagKey      string `json:"tag_key" binding:"omitempty,max=50" example:"golang"`
	Description string `json:"description" binding:"omitempty" example:"Go语言相关文章标签"`
	Thumbnail   string `json:"thumbnail" binding:"omitempty,max=255" example:"http://example.com/image.jpg"`
	SortOrder   int16  `json:"sort_order" binding:"omitempty" example:"1"`
	IsVisible   bool   `json:"is_visible" example:"true"`
}

TagUpdateForm 标签更新表单

type TreeNode

type TreeNode struct {
	ID       interface{} `json:"id"`       // 节点ID
	Label    string      `json:"label"`    // 节点标签
	Value    interface{} `json:"value"`    // 节点值
	Children []*TreeNode `json:"children"` // 子节点
}

TreeNode 树节点结构

type UploadResult

type UploadResult struct {
	FileID       int64  `json:"file_id"`       // 文件ID
	OriginalName string `json:"original_name"` // 原始文件名
	FileName     string `json:"file_name"`     // 存储文件名
	FileExt      string `json:"file_ext"`      // 文件扩展名
	FileSize     int64  `json:"file_size"`     // 文件大小(字节)
	URL          string `json:"url"`           // 文件URL
}

UploadResult 上传结果

type User

type User struct {
	UserID         int       `gorm:"column:user_id;primaryKey;autoIncrement" json:"user_id"`
	Username       string    `gorm:"column:username;size:30;not null;unique" json:"username"`
	PasswordHash   string    `gorm:"column:password_hash;size:100" json:"-"`
	Email          string    `gorm:"column:email;size:100;unique" json:"email"`
	Mobile         string    `gorm:"column:mobile;size:20;unique" json:"mobile"`
	WechatOpenID   string    `gorm:"column:wechat_openid;size:50;unique" json:"-"`
	WechatUnionID  string    `gorm:"column:wechat_unionid;size:50;unique" json:"-"`
	Avatar         string    `gorm:"column:avatar;size:255" json:"avatar"`
	Nickname       string    `gorm:"column:nickname;size:50" json:"nickname"`
	RealName       string    `gorm:"column:real_name;size:50" json:"real_name"`
	Gender         int8      `gorm:"column:gender;default:0" json:"gender"`
	Birthday       time.Time `gorm:"column:birthday" json:"birthday"`
	Status         int8      `gorm:"column:status;not null;default:1" json:"status"`
	RegisterSource int8      `gorm:"column:register_source;not null;default:1" json:"register_source"`
	LastLogin      time.Time `gorm:"column:last_login" json:"last_login"`
	LoginCount     int       `gorm:"column:login_count;not null;default:0" json:"login_count"`
	CreatedAt      time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt      time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
	Roles          []Role    `gorm:"many2many:sys_user_roles;foreignKey:UserID;joinForeignKey:UserID;References:RoleID;joinReferences:RoleID" json:"roles"`
}

User 用户模型

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) error

BeforeCreate 创建前的钩子

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(tx *gorm.DB) error

BeforeUpdate 更新前的钩子

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

CheckPassword 检查密码是否正确

func (User) TableName

func (User) TableName() string

TableName 指定表名

type UserLoginForm

type UserLoginForm struct {
	Username string `json:"username" binding:"required" example:"admin"`
	Password string `json:"password" binding:"required" example:"123456"`
}

UserLoginForm 用户登录表单

type UserRegisterForm

type UserRegisterForm struct {
	Username string `json:"username" binding:"required,min=4,max=30" example:"newuser"`
	Password string `json:"password" binding:"required,min=6,max=20" example:"123456"`
	Email    string `json:"email" binding:"required,email" example:"user@example.com"`
	Mobile   string `json:"mobile" binding:"omitempty,len=11" example:"13800138000"`
	Nickname string `json:"nickname" binding:"omitempty,max=50" example:"新用户"`
}

UserRegisterForm 用户注册表单

type UserResponse

type UserResponse struct {
	UserID         int       `json:"user_id"`
	Username       string    `json:"username"`
	Email          string    `json:"email"`
	Mobile         string    `json:"mobile"`
	Avatar         string    `json:"avatar"`
	Nickname       string    `json:"nickname"`
	Gender         int8      `json:"gender"`
	Status         int8      `json:"status"`
	RegisterSource int8      `json:"register_source"`
	LastLogin      time.Time `json:"last_login"`
	CreatedAt      time.Time `json:"created_at"`
	Roles          []string  `json:"roles"`
}

UserResponse 用户信息响应

type UserUpdateForm

type UserUpdateForm struct {
	Nickname string    `json:"nickname" binding:"omitempty,max=50" example:"新昵称"`
	Avatar   string    `json:"avatar" binding:"omitempty,max=255" example:"http://example.com/avatar.jpg"`
	Gender   int8      `json:"gender" binding:"omitempty,oneof=0 1 2" example:"1"`
	Birthday time.Time `json:"birthday" binding:"omitempty" example:"1990-01-01T00:00:00Z"`
	Email    string    `json:"email" binding:"omitempty,email" example:"newemail@example.com"`
	Mobile   string    `json:"mobile" binding:"omitempty,len=11" example:"13900139000"`
}

UserUpdateForm 用户信息更新表单

Jump to

Keyboard shortcuts

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