controllers

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: MIT Imports: 56 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func About added in v0.0.3

func About(c *gin.Context)

func ActivateAccount

func ActivateAccount(c *gin.Context)

添加激活处理函数

func Admin added in v0.0.4

func Admin(c *gin.Context)

func ApplySheet added in v0.0.3

func ApplyShow

ApplyShow 申请展示,是侧边栏

func ApplyTop

ApplyTop 置顶申请,考虑滚动

func ChangePassword

添加修改密码的处理函数

func CustomErrorPage added in v0.0.3

func CustomErrorPage(c *gin.Context, title, message string)

CustomErrorPage 自定义错误页面

func DeleteCategory

func DeleteCategory(req component.BetterRequest[struct {
	Id uint64 `json:"id"`
}]) component.Response

DeleteCategory 删除分类

func DeleteNotification

DeleteNotification 删除通知

func EditArticle

EditArticle 文章状态管理

func EditUserEmail added in v0.0.7

EditUserEmail 编辑用户

func EditUserInfo

EditUserInfo 编辑用户

func EditUsername added in v0.0.7

EditUsername 编辑用户

func FirstOr

func FirstOr[T any](d []T, defaultValue T) T

func FollowUser added in v0.0.3

func ForbiddenPage added in v0.0.3

func ForbiddenPage(c *gin.Context)

ForbiddenPage 403页面

func GenerateRSS

func GenerateRSS(title, link, description string, items []Item) (string, error)

GenerateRSS 生成符合RSS 2.0规范的XML字符串

func GetArticlesEnum

func GetArticlesEnum() component.Response

func GetCaptcha

func GetCaptcha() component.Response

func GetCategoryList

GetCategoryList 获取分类列表

func GetFileByFileName

func GetFileByFileName(c *gin.Context)
func GetFriendLinks(req component.BetterRequest[null]) component.Response

func GetLastUnread added in v0.0.3

GetLastUnread 获取未读通知数量

func GetNotificationList

GetNotificationList 获取通知列表

func GetNotificationTypes

GetNotificationTypes 获取所有通知类型

func GetSiteStatistics

func GetSiteStatistics() component.Response

func GetUnreadCount

GetUnreadCount 获取未读通知数量

func GetUserArticles

GetUserArticles 获取用户文章列表

func GetWebSettings added in v0.0.5

func GetWebSettings(req component.BetterRequest[null]) component.Response

GetWebSettings 获取网页设置

func Home added in v0.0.3

func Home(c *gin.Context)

func InternalServerErrorPage added in v0.0.3

func InternalServerErrorPage(c *gin.Context)

InternalServerErrorPage 500页面

func Invitation

func Invitation(req component.BetterRequest[null]) component.Response

func IsValidEmail added in v0.0.7

func IsValidEmail(email string) bool

func LikeArticle added in v0.0.2

func LinksView added in v0.0.3

func LinksView(c *gin.Context)

func Login

func Login(c *gin.Context)

Login 处理登录请求

func LoginView added in v0.0.3

func LoginView(c *gin.Context)

func Logout

func Logout(c *gin.Context)

func MarkAllAsRead

MarkAllAsRead 标记所有通知为已读

func MarkAsRead

MarkAsRead 标记通知为已读

func NotFound

func NotFound(c *gin.Context)

func NotFoundPage added in v0.0.3

func NotFoundPage(c *gin.Context)

NotFoundPage 404页面

func Notifications added in v0.0.3

func Notifications(c *gin.Context)

func Post added in v0.0.3

func Post(c *gin.Context)

func PostDetail added in v0.0.3

func PostDetail(c *gin.Context)

func PrivacyPolicy added in v0.0.3

func PrivacyPolicy(c *gin.Context)

PrivacyPolicy 隐私政策页面

func Profile added in v0.0.3

func Profile(c *gin.Context)

func PublishV3 added in v0.0.3

func PublishV3(c *gin.Context)

func QueryNotificationList added in v0.0.3

func Register

func Register(c *gin.Context)

Register 注册

func RenderErrorPage added in v0.0.3

func RenderErrorPage(c *gin.Context, data ErrorPageData)

RenderErrorPage 渲染错误页面的通用函数

func RenderRobotsTxt

func RenderRobotsTxt(c *gin.Context)

RenderRobotsTxt 渲染 robots.txt

func RenderRssV2

func RenderRssV2(c *gin.Context)

func RenderSitemapXml

func RenderSitemapXml(c *gin.Context)

RenderSitemapXml 渲染 sitemap.xml

func SaveCategory

SaveCategory 保存分类

func SaveImgByGinContext added in v0.0.6

func SaveImgByGinContext(c *gin.Context)

SaveImgByGinContext 处理图片上传请求 包含文件大小限制、格式验证、内容检查等安全措施

func SaveWebSettings added in v0.0.5

SaveWebSettings 保存网页设置

func SendAEmail4User

func SendAEmail4User(userEntity *users.EntityComplete) error

func SponsorsView added in v0.0.3

func SponsorsView(c *gin.Context)

func TakeUpTo64Chars

func TakeUpTo64Chars(s string) string

TakeUpTo64Chars 按字符数截取字符串,最多取 64 个字符

func TermsOfService added in v0.0.3

func TermsOfService(c *gin.Context)

TermsOfService 用户协议页面

func UnauthorizedPage added in v0.0.3

func UnauthorizedPage(c *gin.Context)

UnauthorizedPage 401页面

func UploadAvatar

func UploadAvatar(c *gin.Context)

UploadAvatar 头像上传处理函数

func User added in v0.0.3

func User(c *gin.Context)

func UserInfo

func UserInfo(req component.BetterRequest[null]) component.Response

UserInfo 获取登录用户信息

func ValidatePassword added in v0.0.3

func ValidatePassword(password string) error

ValidatePassword 验证密码复杂度

func ValidateUsername added in v0.0.3

func ValidateUsername(username string) bool

func WriteArticles

WriteArticles 写文章

func WriteArticlesOrigin

WriteArticlesOrigin 写文章

Types

type ApplyAddLinkReq added in v0.0.3

type ApplyAddLinkReq struct {
	SiteName string `json:"siteName" validate:"required"`
	SiteUrl  string `json:"siteUrl" validate:"required"`
	SiteDesc string `json:"siteDesc" validate:"required"`
	Email    string `json:"email"`
	Contact  string `json:"contact"`
}

type ApplySheetListReq added in v0.0.3

type ApplySheetListReq struct {
	Page     int    `form:"page"`
	PageSize int    `form:"pageSize"`
	Search   string `form:"search"`
	UserId   uint64 `form:"userId"`
}

type ApplyShowReq

type ApplyShowReq struct {
	Title     string   `json:"comment"`
	Desc      string   `json:"desc"`
	ImageList []string `json:"imageList"`
}

type ApplyTopReq

type ApplyTopReq struct {
	ArticleId uint64 `json:"articleId"`
}

type ArticleReplyId

type ArticleReplyId struct {
	ArticleId uint64 `json:"articleId"`
	Content   string `json:"content"`
	ReplyId   uint64 `json:"replyId"`
}

type ArticlesInfoAdminDto added in v0.0.4

type ArticlesInfoAdminDto struct {
	Id            uint64 `json:"id"`
	Title         string `json:"title"`
	Description   string `json:"description"`
	Type          int8   `json:"type"`   // 文章类型:0 博文,1教程,2问答,3分享
	UserId        uint64 `json:"userId"` //
	Username      string `json:"username"`
	UserAvatarUrl string `json:"userAvatarUrl"`
	ArticleStatus int8   `json:"articleStatus"` // 文章状态:0 草稿 1 发布
	ProcessStatus int8   `json:"processStatus"` // 管理状态:0 正常 1 封禁
	ViewCount     uint64 `json:"viewCount"`
	ReplyCount    uint64 `json:"replyCount"`
	LikeCount     uint64 `json:"likeCount"`
	CreatedAt     string `json:"createdAt"` // 改为 string 类型
	UpdatedAt     string `json:"updatedAt"` // 改为 string 类型
}

type ArticlesInfoDto

type ArticlesInfoDto struct {
	Id            uint64 `json:"id"`
	Title         string `json:"title"`
	Type          int8   `json:"type"`   // 文章类型:0 博文,1教程,2问答,3分享
	UserId        uint64 `json:"userId"` //
	Username      string `json:"username"`
	ArticleStatus int8   `json:"articleStatus"` // 文章状态:0 草稿 1 发布
	ProcessStatus int8   `json:"processStatus"` // 管理状态:0 正常 1 封禁
	CreatedAt     string `json:"createdAt"`     // 改为 string 类型
	UpdatedAt     string `json:"updatedAt"`     // 改为 string 类型
}

type ArticlesListReq

type ArticlesListReq struct {
	Page     int    `form:"page"`
	PageSize int    `form:"pageSize"`
	Search   string `form:"search"`
	UserId   uint64 `form:"userId"`
}

type ArticlesSimpleDto

type ArticlesSimpleDto struct {
	Id             uint64   `json:"id"`
	Title          string   `json:"title,omitempty"`
	Content        string   `json:"content,omitempty"`
	CreateTime     string   `json:"createTime,omitempty"`
	LastUpdateTime string   `json:"lastUpdateTime,omitempty"`
	Username       string   `json:"username,omitempty"`
	AuthorId       uint64   `json:"authorId,omitempty"`
	ViewCount      uint64   `json:"viewCount,omitempty"`
	CommentCount   uint64   `json:"commentCount"`
	Type           int8     `json:"type,omitempty"`
	TypeStr        string   `json:"typeStr,omitempty"`
	Category       string   `json:"category,omitempty"`
	Categories     []string `json:"categories,omitempty"`
	CategoriesId   []uint64 `json:"categoriesId,omitempty"`
	AvatarUrl      string   `json:"avatarUrl,omitempty"`
}

type CDATA

type CDATA string

func (CDATA) MarshalXML

func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type CategoryItem

type CategoryItem struct {
	Id       uint64 `json:"id"`
	Category string `json:"category"`
	Desc     string `json:"desc"`
	Sort     int    `json:"sort"`
	Status   int8   `json:"status"`
}

type CategoryListReq

type CategoryListReq struct {
	Page     int `json:"page"`
	PageSize int `json:"pageSize"`
}

type CategorySaveReq

type CategorySaveReq struct {
	Id       uint64 `json:"id"`
	Category string `json:"category" validate:"required"`
	Desc     string `json:"desc"`
	Sort     int    `json:"sort"`
	Status   int8   `json:"status"`
}

type ChangePasswordReq

type ChangePasswordReq struct {
	OldPassword string `json:"oldPassword" validate:"required"`
	NewPassword string `json:"newPassword" validate:"required"`
}

添加新的请求结构体

type Channel

type Channel struct {
	Title       string `xml:"title"`
	Link        string `xml:"link"`
	Description string `xml:"description"`
	PubDate     string `xml:"pubDate"`
	Items       []Item `xml:"item"`
}

type DeleteNotificationReq

type DeleteNotificationReq struct {
	NotificationId uint64 `json:"notificationId" validate:"required"`
}

DeleteNotificationReq 删除通知请求

type DeleteReplyId

type DeleteReplyId struct {
	ReplyId uint64 `json:"replyId"`
}

type EditArticleReq

type EditArticleReq struct {
	Id            uint64 `json:"id" validate:"required"`
	ProcessStatus int8   `json:"processStatus" validate:"oneof=0 1"` // 0正常 1封禁
}

type EditUserEmailReq added in v0.0.7

type EditUserEmailReq struct {
	Email string `json:"email" validate:"required,email"`
}

type EditUserInfoReq

type EditUserInfoReq struct {
	Nickname            string                    `json:"nickname"`
	Bio                 string                    `json:"bio"`
	Signature           string                    `json:"signature"`
	Website             string                    `json:"website"`
	WebsiteName         string                    `json:"websiteName"`
	ExternalInformation users.ExternalInformation `json:"externalInformation"`
}

type EditUserReq

type EditUserReq struct {
	UserId   uint64 `json:"userId"`
	Status   int8   `json:"status"`
	Validate int8   `json:"validate"`
	RoleId   uint64 `json:"roleId"`
}

type EditUsernameReq added in v0.0.7

type EditUsernameReq struct {
	Username string `json:"username" validate:"required"`
}

type ErrorPageData added in v0.0.3

type ErrorPageData struct {
	Title      string
	Message    string
	ErrorCode  string
	StatusCode int
}

ErrorPageData 错误页面数据结构

type FollowUserReq added in v0.0.3

type FollowUserReq struct {
	Id     uint64 `json:"id"`
	Action int    `json:"action" validate:"min=1,max=2"` // 1 like 2 cancel
}

type ForumInfo added in v0.0.4

type ForumInfo struct {
	Title        string
	Desc         string
	Independence bool
}

func GetGooseForumInfo added in v0.0.4

func GetGooseForumInfo() ForumInfo

type GetAllRoleItemReq

type GetAllRoleItemReq struct {
}

type GetArticlesDetailRequest

type GetArticlesDetailRequest struct {
	Id           uint64 `json:"id"`
	MaxCommentId uint64 `json:"maxCommentId"`
	PageSize     int    `json:"pageSize"`
}

type GetArticlesPageRequest

type GetArticlesPageRequest struct {
	Page       int    `form:"page"`
	PageSize   int    `form:"pageSize"`
	Search     string `form:"search"`
	Categories []int  `form:"categories"`
}

type GetNotificationListReq

type GetNotificationListReq struct {
	Page       int  `json:"page" validate:"required,min=1"`
	PageSize   int  `json:"pageSize" validate:"required,min=1,max=100"`
	UnreadOnly bool `json:"unreadOnly"`
}

GetNotificationListReq 获取通知列表请求

type GetNotificationTypesReq

type GetNotificationTypesReq struct{}

GetNotificationTypesReq 获取通知类型请求

type GetUnreadCountReq

type GetUnreadCountReq struct{}

GetUnreadCountReq 获取未读数量请求

type GetUserArticlesRequest

type GetUserArticlesRequest struct {
	Page     int `json:"page"`
	PageSize int `json:"pageSize"`
}

添加新的请求结构体

type Item

type Item struct {
	Title       string `xml:"title"`
	Link        string `xml:"link"`
	Description CDATA  `xml:"description"`
	PubDate     string `xml:"pubDate"`
	GUID        string `xml:"guid"` // 可选唯一标识符
}

type LikeArticleReq added in v0.0.2

type LikeArticleReq struct {
	Id     uint64 `json:"id"`
	Action int    `json:"action" validate:"min=1,max=2"` // 1 like 2 cancel
}

type LinkStatistics added in v0.0.5

type LinkStatistics struct {
	Name       string
	Counter    int
	Proportion int
}

type LinkStatisticsInfo added in v0.0.5

type LinkStatisticsInfo struct {
	Community LinkStatistics
	Blog      LinkStatistics
	Tool      LinkStatistics
}

type LoginReq

type LoginReq struct {
	Username    string `json:"username" validate:"required"` // 可以是用户名或邮箱
	Password    string `json:"password" validate:"required"`
	CaptchaId   string `json:"captchaId"`
	CaptchaCode string `json:"captchaCode"`
}

type MarkAllAsReadReq

type MarkAllAsReadReq struct{}

MarkAllAsReadReq 标记所有通知已读请求

type MarkAsReadReq

type MarkAsReadReq struct {
	NotificationId uint64 `json:"notificationId" validate:"required"`
}

MarkAsReadReq 标记通知已读请求

type OptRecordPageReq

type OptRecordPageReq struct {
}

type PageButton added in v0.0.2

type PageButton struct {
	Index int
	Page  int
}

type PermissionItem

type PermissionItem struct {
	Id   uint64 `json:"id"`
	Name string `json:"name"`
}

type PermissionListReq

type PermissionListReq struct {
}

type QueryNotificationListReq added in v0.0.3

type QueryNotificationListReq struct {
	StartId    int  `json:"startId"`
	PageSize   int  `json:"pageSize" validate:"required,min=1,max=100"`
	UnreadOnly bool `json:"unreadOnly"`
}

QueryNotificationListReq 获取通知列表请求

type RSS

type RSS struct {
	XMLName xml.Name `xml:"rss"`
	Version string   `xml:"version,attr"`
	Channel Channel  `xml:"channel"`
}

RSS 2.0规范核心结构体

type RegReq

type RegReq struct {
	Email          string `json:"email" validate:"required,email"`
	Username       string `json:"userName"  validate:"required"`
	Password       string `json:"passWord"  validate:"required"`
	InvitationCode string `json:"invitationCode,omitempty"`
	CaptchaId      string `json:"captchaId" validate:"required"`
	CaptchaCode    string `json:"captchaCode" validate:"required"`
}

type ReplyDto

type ReplyDto struct {
	Id              uint64 `json:"id"`
	ArticleId       uint64 `json:"articleId"`
	UserId          uint64 `json:"userId"`
	UserAvatarUrl   string `json:"userAvatarUrl"`
	Username        string `json:"username"`
	Content         string `json:"content"`
	CreateTime      string `json:"createTime"`
	ReplyToId       uint64 `json:"replyToId,omitempty"`
	ReplyToUsername string `json:"replyToUsername,omitempty"`
	ReplyToUserId   uint64 `json:"replyToUserId,omitempty"`
}

type RoleItem

type RoleItem struct {
	RoleId      uint64           `json:"roleId"`
	RoleName    string           `json:"roleName"`
	Effective   int              `json:"effective"`
	Permissions []PermissionItem `json:"permissions"`
	CreateTime  string           `json:"createTime"`
}

type RoleListReq

type RoleListReq struct {
}

type RoleSaveDel

type RoleSaveDel struct {
	Id uint `json:"id"`
}

type RoleSaveReq

type RoleSaveReq struct {
	Id          uint     `json:"id"`
	RoleName    string   `json:"roleName" validate:"required"`
	Permissions []uint64 `json:"permissions" validate:"required,min=1,max=100"`
}

type SaveFriendLinksReq added in v0.0.3

type SaveFriendLinksReq struct {
	LinksInfo []pageConfig.FriendLinksGroup `json:"linksInfo"`
}

type SaveWebSettingsReq added in v0.0.5

type SaveWebSettingsReq struct {
	Settings pageConfig.WebSettingsConfig `json:"settings"`
}

type SiteStats

type SiteStats struct {
	UserCount         int64 `json:"userCount"`
	UserMonthCount    int64 `json:"userMonthCount"`
	ArticleCount      int64 `json:"articleCount"`
	ArticleMonthCount int64 `json:"articleMonthCount"`
	Reply             int64 `json:"reply"`
	LinksCount        int   `json:"linksCount"`
}

func GetSiteStatisticsData

func GetSiteStatisticsData() SiteStats

type UserInfoShow

type UserInfoShow struct {
	UserId              uint64                    `json:"userId,omitempty"`
	Username            string                    `json:"username"`
	Bio                 string                    `json:"bio"`
	Signature           string                    `json:"Signature"`
	Prestige            int64                     `json:"prestige"`
	AvatarUrl           string                    `json:"avatarUrl"`
	UserPoint           int64                     `json:"userPoint"`
	CreateTime          time.Time                 `json:"createTime"`
	IsAdmin             bool                      `json:"isAdmin"`
	ExternalInformation users.ExternalInformation `json:"externalInformation"`
}

func GetLoginUser

func GetLoginUser(c *gin.Context) UserInfoShow

func GetUserShowByUserId

func GetUserShowByUserId(userId uint64) UserInfoShow

type UserItem

type UserItem struct {
	UserId     uint64                              `json:"userId"`
	Username   string                              `json:"username"`
	AvatarUrl  string                              `json:"avatarUrl"`
	Email      string                              `json:"email"`
	Status     int8                                `json:"status"`
	Validate   int8                                `json:"validate"`
	Prestige   int64                               `json:"prestige"`
	RoleList   []datastruct.Option[string, uint64] `json:"roleList"`
	RoleId     uint64                              `json:"roleId,omitempty"`
	CreateTime string                              `json:"createTime"`
}

type UserListReq

type UserListReq struct {
	Username string `json:"username"`
	UserId   uint64 `json:"userId"`
	Email    string `json:"email"`
	Page     int    `json:"page"`
	PageSize int    `json:"pageSize"`
}

type WriteArticleReq

type WriteArticleReq struct {
	Id         int64    `json:"id"`
	Content    string   `json:"content" validate:"required"`
	Title      string   `json:"title" validate:"required"`
	Type       int8     `json:"type"`
	CategoryId []uint64 `json:"categoryId" validate:"min=1,max=3"`
}

type WriteArticlesOriginReq

type WriteArticlesOriginReq struct {
	Id int64 `json:"id"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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