controllers

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: MIT Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivateAccount

func ActivateAccount(c *gin.Context)

添加激活处理函数

func ApplyShow

ApplyShow 申请展示,是侧边栏

func ApplyTop

ApplyTop 置顶申请,考虑滚动

func ChangePassword

添加修改密码的处理函数

func DeleteCategory

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

DeleteCategory 删除分类

func DeleteNotification

DeleteNotification 删除通知

func EditArticle

EditArticle 文章状态管理

func EditUserInfo

EditUserInfo 编辑用户

func FirstOr

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

func GenerateCaptcha

func GenerateCaptcha() (string, string)

生成验证码

func GenerateRSS

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

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

func GetArticlesCategory

func GetArticlesCategory() component.Response

func GetArticlesEnum

func GetArticlesEnum() component.Response

func GetArticlesPage

func GetArticlesPage(param GetArticlesPageRequest) component.Response

GetArticlesPage 文章列表

func GetCaptcha

func GetCaptcha() component.Response

func GetCategoryList

GetCategoryList 获取分类列表

func GetFileByFileName

func GetFileByFileName(c *gin.Context)

func GetNotificationList

GetNotificationList 获取通知列表

func GetNotificationTypes

GetNotificationTypes 获取所有通知类型

func GetSetupStatus

GetSetupStatus 获取安装状态

func GetSiteStatistics

func GetSiteStatistics() component.Response

func GetUnreadCount

GetUnreadCount 获取未读通知数量

func GetUserArticles

GetUserArticles 获取用户文章列表

func GetUserInfo

func GetUserInfo(req GetUserInfoReq) component.Response

GetUserInfo 游客访问某些用户时

func InitialSetup

InitialSetup 执行初始化设置

func Invitation

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

func Login

func Login(r LoginReq) component.Response

Login 登录只返回 token

func LoginHandler

func LoginHandler(c *gin.Context)

LoginHandler 处理登录请求

func LoginPage

func LoginPage(c *gin.Context)

func Logout

func Logout(c *gin.Context)

func MarkAllAsRead

MarkAllAsRead 标记所有通知为已读

func MarkAsRead

MarkAsRead 标记通知为已读

func NotFound

func NotFound(c *gin.Context)

func Register

func Register(r RegReq) component.Response

Register 注册

func RegisterHandle

func RegisterHandle(c *gin.Context)

RegisterHandle 注册

func RenderArticleDetail

func RenderArticleDetail(c *gin.Context)

RenderArticleDetail 渲染文章详情页面

func RenderArticlesPage

func RenderArticlesPage(c *gin.Context)

RenderArticlesPage 渲染文章列表页面

func RenderIndex

func RenderIndex(c *gin.Context)

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 SaveFileByGinContext

func SaveFileByGinContext(c *gin.Context)

func SendAEmail4User

func SendAEmail4User(userEntity *users.Entity) error

func Sponsors

func Sponsors(c *gin.Context)

func TakeUpTo64Chars

func TakeUpTo64Chars(s string) string

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

func UploadAvatar

func UploadAvatar(c *gin.Context)

UploadAvatar 头像上传处理函数

func UserInfo

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

UserInfo 获取登录用户信息

func UserProfile

func UserProfile(c *gin.Context)

func VerifyCaptcha

func VerifyCaptcha(captchaId, captchaCode string) bool

验证验证码

func WriteArticles

WriteArticles 写文章

func WriteArticlesOrigin

WriteArticlesOrigin 写文章

Types

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 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"`
	ViewCount      uint64   `json:"viewCount,omitempty"`
	CommentCount   uint64   `json:"commentCount,omitempty"`
	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"`
	Tags           []string `json:"tags,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 Cache

type Cache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func (*Cache[K, V]) GetOrLoad

func (c *Cache[K, V]) GetOrLoad(
	key K,
	getData func() (V, error),
	timeout time.Duration,
) (V, error)

核心调用方法(满足您要求的参数形式)

type CategoryItem

type CategoryItem struct {
	Id       uint64 `json:"id"`
	Category string `json:"category"`
	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"`
	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:"repoId"`
}

type EditArticleReq

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

type EditUserInfoReq

type EditUserInfoReq struct {
	Nickname  string `json:"nickname"`
	Email     string `json:"email"`
	Bio       string `json:"bio"`
	Signature string `json:"signature"`
	Website   string `json:"website"`
}

type EditUserReq

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

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 GetUserInfoReq

type GetUserInfoReq struct {
	UserId uint64 `json:"userId"`
}

type InitialSetupReq

type InitialSetupReq struct {
	SiteName string `json:"siteName" validate:"required"`
	SiteDesc string `json:"siteDesc"`
	// 数据库配置
	DBType     string `json:"dbType" validate:"required"`
	SqlitePath string `json:"sqlitePath" validate:"required"`
	DBHost     string `json:"dbHost" validate:"required"`
	DBPort     string `json:"dbPort" validate:"required"`
	DBName     string `json:"dbName" validate:"required"`
	DBUser     string `json:"dbUser" validate:"required"`
	DBPassword string `json:"dbPassword" validate:"required"`
	// 管理员账号配置
	AdminUsername string `json:"adminUsername" validate:"required"`
	AdminPassword string `json:"adminPassword" validate:"required"`
	AdminEmail    string `json:"adminEmail" validate:"required,email"`
}

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 LoginHandlerReq

type LoginHandlerReq struct {
	Username    string `json:"username"`
	Password    string `json:"password"`
	CaptchaId   string `json:"captchaId"`
	CaptchaCode string `json:"captchaCode"`
}

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 PermissionItem

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

type PermissionListReq

type PermissionListReq struct {
}

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"`
	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"`
	Username        string `json:"username"`
	Content         string `json:"content"`
	CreateTime      string `json:"createTime"`
	ReplyToId       uint64 `json:"replyToId,omitempty"`
	ReplyToUsername string `json:"replyToUsername,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 SetupStatusReq

type SetupStatusReq struct{}

type SiteStats

type SiteStats struct {
	UserCount    int64 `json:"userCount"`
	ArticleCount int64 `json:"articleCount"`
	Reply        int64 `json:"reply"`
}

func GetSiteStatisticsData

func GetSiteStatisticsData() SiteStats

type UserInfoShow

type UserInfoShow struct {
	UserId     uint64    `json:"userId,omitempty"`
	Username   string    `json:"username"`
	Prestige   int64     `json:"prestige"`
	AvatarUrl  string    `json:"avatarUrl"`
	UserPoint  int64     `json:"userPoint"`
	CreateTime time.Time `json:"createTime"`
}

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"`
	Email      string                              `json:"email"`
	Status     int8                                `json:"status"`
	Validate   int8                                `json:"validate"`
	Prestige   int64                               `json:"prestige"`
	RoleList   []datastruct.Option[string, uint64] `json:"roleList"`
	CreateTime string                              `json:"createTime"`
}

type UserListReq

type UserListReq struct {
	Username string `json:"username"`
	UserId   uint64 `json:"userId"`
	Email    string `json:"email"`
}

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