controller

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAccountBanned = errors.New("账户已被封禁")

Functions

This section is empty.

Types

type APIController

type APIController struct {
	R *gin.Engine
}

type APIRouter

type APIRouter struct {
}

func (*APIRouter) Auth

func (ar *APIRouter) Auth(c *gin.Context, authType AuthenticationType) (int64, error)

鉴权 如果是服务鉴权,则拿Authorization头对比service.token 其他的都是用户鉴权,直接尝试从GetUin取uin

func (*APIRouter) CheckIfBanned

func (ar *APIRouter) CheckIfBanned(c *gin.Context, as service.AccountService, uin int64) bool

检查当前用户是否被封禁

func (*APIRouter) Fail

func (ar *APIRouter) Fail(c *gin.Context, code int, msg string)

func (*APIRouter) GetBearerToken

func (ar *APIRouter) GetBearerToken(c *gin.Context) (string, error)

func (*APIRouter) GetUin

func (ar *APIRouter) GetUin(c *gin.Context) (int64, error)

从jwt取uin

func (*APIRouter) StatusCode

func (ar *APIRouter) StatusCode(c *gin.Context, code int, msg string)

func (*APIRouter) Success

func (ar *APIRouter) Success(c *gin.Context, data interface{})

type AccountBanBody

type AccountBanBody struct {
	// 被封禁的uin
	Uin int64 `json:"uin" binding:"required"`

	// 封禁原因
	Comment string `json:"comment" binding:"required"`

	// 结束时间
	EndTime int64 `json:"end_time" binding:"required"`
}

type AccountChangePasswordBody

type AccountChangePasswordBody struct {
	// 新密码
	NewPasswd string `json:"new_passwd" binding:"required"`
}

type AccountCreateBody

type AccountCreateBody struct {
	// Uin 账户的uin 必须
	Uin int64 `json:"uin" binding:"required"`
}

type AccountLoginBody

type AccountLoginBody struct {
	// Uin 账户的uin 必须
	Uin int64 `json:"uin" binding:"required"`

	// Pwd 账户的密码 必须
	Passwd string `json:"passwd" binding:"required"`
}

type AccountRouter

type AccountRouter struct {
	APIRouter
	AccountService service.AccountService
}

func NewAccountRouter

func NewAccountRouter(rg *gin.RouterGroup, as service.AccountService) *AccountRouter

func (*AccountRouter) BanAccount

func (ar *AccountRouter) BanAccount(c *gin.Context)

封禁用户

func (*AccountRouter) ChangePassword

func (ar *AccountRouter) ChangePassword(c *gin.Context)

修改密码

func (*AccountRouter) ChangeUserGroup

func (ar *AccountRouter) ChangeUserGroup(c *gin.Context)

更改用户组

func (*AccountRouter) CheckToken

func (ar *AccountRouter) CheckToken(c *gin.Context)

检查token

func (*AccountRouter) CreateAccount

func (ar *AccountRouter) CreateAccount(c *gin.Context)

创建账户

func (*AccountRouter) GetAccountList

func (ar *AccountRouter) GetAccountList(c *gin.Context)

获取账号列表

func (*AccountRouter) GetBanList

func (ar *AccountRouter) GetBanList(c *gin.Context)

获取封禁记录

func (*AccountRouter) LoginAccount

func (ar *AccountRouter) LoginAccount(c *gin.Context)

登录

func (*AccountRouter) ResetPassword

func (ar *AccountRouter) ResetPassword(c *gin.Context)

重置密码

func (*AccountRouter) UnbanAccount

func (ar *AccountRouter) UnbanAccount(c *gin.Context)

解封用户

type AccountUnbanBody

type AccountUnbanBody struct {
	// 被封禁的uin
	Uin int64 `json:"uin" binding:"required"`
}

type AdminRouter

type AdminRouter struct {
	APIRouter
	AdminService   service.AdminService
	AccountService service.AccountService
}

func (*AdminRouter) AddOAuth2App

func (ar *AdminRouter) AddOAuth2App(c *gin.Context)

添加一个OAuth2应用

func (*AdminRouter) DeleteOAuth2App

func (ar *AdminRouter) DeleteOAuth2App(c *gin.Context)

删除一个OAuth2应用

func (*AdminRouter) GetOAuth2AppList

func (ar *AdminRouter) GetOAuth2AppList(c *gin.Context)

获取 OAuth2 应用列表

func (*AdminRouter) Init

func (ar *AdminRouter) Init(c *gin.Context)

初始化

func (*AdminRouter) IsInit

func (ar *AdminRouter) IsInit(c *gin.Context)

检查是否初始化

type AuthenticationType

type AuthenticationType int
const (
	UserOnly    AuthenticationType = 1
	ServiceOnly AuthenticationType = 2
	Both        AuthenticationType = 3
)

type ChangeUserGroupBody

type ChangeUserGroupBody struct {
	// 被操作的uin
	Uin int64 `json:"uin" binding:"required"`

	// 新的用户组
	NewGroup database.UserGroup `json:"new_group" binding:"required"`
}

type GetAccountsBody

type GetAccountsBody struct {
	// uin
	Uin int64 `json:"uin" binding:"required"`

	// 用户组
	UserGroup database.UserGroup `json:"user_group" binding:"required"`

	// time_order
	TimeOrder *int `json:"time_order" binding:"required"`

	// page
	Page *int `json:"page" binding:"required"`

	// page_size
	PageSize *int `json:"page_size" binding:"required"`
}

type GetBanListBody

type GetBanListBody struct {
	// uin
	Uin int64 `json:"uin" binding:"required"`

	// 仅有效的
	OnlyValid *bool `json:"only_valid" binding:"required"`

	// 页码
	Page *int `json:"page" binding:"required"`

	// 每页数量
	PageSize *int `json:"page_size" binding:"required"`

	// 时间排序
	TimeOrder *int `json:"time_order" binding:"required"`
}

type GetPostsBody

type GetPostsBody struct {
	// uin
	Uin int64 `json:"uin" binding:"required"`

	GetSelfPostsBody
}

type GetSelfPostsBody

type GetSelfPostsBody struct {
	// 状态
	Status database.PostStatus `json:"status" binding:"required"`

	// 时间排序
	TimeOrder *int `json:"time_order" binding:"required"`

	// 页码
	Page *int `json:"page" binding:"required"`

	// 每页数量
	PageSize *int `json:"page_size" binding:"required"`
}

type InitBody

type InitBody struct {
	// 管理员uin
	AdminUin int64 `json:"admin_uin" binding:"required"`

	// 管理员密码
	AdminPasswd string `json:"admin_passwd" binding:"required"`
}

type MiscRouter

type MiscRouter struct {
	APIRouter
	MiscService service.MiscService
}

func NewMiscRouter

func NewMiscRouter(rg *gin.RouterGroup, ms service.MiscService) *MiscRouter

func (*MiscRouter) GetMetadata

func (mr *MiscRouter) GetMetadata(c *gin.Context)

获取元数据

func (*MiscRouter) GetMetadataList

func (mr *MiscRouter) GetMetadataList(c *gin.Context)

获取元数据列表

func (*MiscRouter) GetVersion

func (mr *MiscRouter) GetVersion(c *gin.Context)

获取版本信息

func (*MiscRouter) SaveMetadata

func (mr *MiscRouter) SaveMetadata(c *gin.Context)

保存元数据

func (*MiscRouter) SetMetadata

func (mr *MiscRouter) SetMetadata(c *gin.Context)

设置元数据

type OAuth2AppCreateBody

type OAuth2AppCreateBody struct {
	// 名称
	Name string `json:"name" binding:"required"`

	// emoji
	Emoji string `json:"emoji" binding:"required"`
}

type OAuth2AuthorizeBody

type OAuth2AuthorizeBody struct {
	// 应用id
	ClientID string `json:"client_id" binding:"required"`
}

type OAuth2GetAccessTokenBody

type OAuth2GetAccessTokenBody struct {
	// 应用id
	ClientID string `json:"client_id" binding:"required"`

	// 应用密钥
	ClientSecret string `json:"client_secret" binding:"required"`

	// 授权码
	Code string `json:"code" binding:"required"`
}

type OAuth2Router

type OAuth2Router struct {
	APIRouter
	OAuth2Service service.OAuth2Service
}

func NewOAuth2Router

func NewOAuth2Router(rg *gin.RouterGroup, oas service.OAuth2Service) *OAuth2Router

func (*OAuth2Router) Authorize

func (oar *OAuth2Router) Authorize(c *gin.Context)

func (*OAuth2Router) GetAccessToken

func (oar *OAuth2Router) GetAccessToken(c *gin.Context)

func (*OAuth2Router) GetOAuth2AppInfo

func (oar *OAuth2Router) GetOAuth2AppInfo(c *gin.Context)

func (*OAuth2Router) GetUserInfo

func (oar *OAuth2Router) GetUserInfo(c *gin.Context)

type PostInfo

type PostInfo struct {
	database.PostPO
	TimeStamp int64 `json:"time_stamp" bson:"time_stamp"` // 时间戳
}

稿件信息响应

type PostLogBody

type PostLogBody struct {
	PostID  int                 `json:"post_id" bson:"post_id"`   // 稿件ID
	Op      int64               `json:"op" bson:"op"`             // 操作者ID -1表示系统
	OldStat database.PostStatus `json:"old_stat" bson:"old_stat"` // 旧状态
	NewStat database.PostStatus `json:"new_stat" bson:"new_stat"` // 新状态
	Comment string              `json:"comment" bson:"comment"`   // 备注
}

type PostNewBody

type PostNewBody struct {

	// UUID UUID 必须
	UUID string `json:"uuid" binding:"required"`

	// Text 正文 必须
	Text string `json:"text" binding:"required"`

	// Anon 是否匿名
	Anon *bool `json:"anon" binding:"required"`

	// Images 图片
	Images []string `json:"images"`
}

type PostReviewBody

type PostReviewBody struct {
	// 稿件id
	PostID int `json:"post_id" binding:"required"`

	// 审核选项
	Option database.ReviewOption `json:"option" binding:"required"`

	// 审核意见
	Comment *string `json:"comment" binding:"required"`
}

稿件审核

type PostRouter

type PostRouter struct {
	APIRouter
	PostService    service.PostService
	AccountService service.AccountService
}

func (*PostRouter) DownloadImage

func (pr *PostRouter) DownloadImage(c *gin.Context)

下载图片

func (*PostRouter) GetPostInfo

func (pr *PostRouter) GetPostInfo(c *gin.Context)

func (*PostRouter) GetPostLog

func (pr *PostRouter) GetPostLog(c *gin.Context)

获取稿件日志

func (*PostRouter) GetPosts

func (pr *PostRouter) GetPosts(c *gin.Context)

获取稿件列表

func (*PostRouter) GetSelfPosts

func (pr *PostRouter) GetSelfPosts(c *gin.Context)

获取用户自己的帖子

func (*PostRouter) PostNew

func (pr *PostRouter) PostNew(c *gin.Context)

发布新稿件

func (*PostRouter) PostPostLog

func (pr *PostRouter) PostPostLog(c *gin.Context)

推送稿件日志

func (*PostRouter) ReviewPost

func (pr *PostRouter) ReviewPost(c *gin.Context)

提交稿件审核

func (*PostRouter) SubmitPostVerbose

func (pr *PostRouter) SubmitPostVerbose(c *gin.Context)

提交稿件发布详细信息

func (*PostRouter) UploadImage

func (pr *PostRouter) UploadImage(c *gin.Context)

上传图片

func (*PostRouter) UserCancelPost

func (pr *PostRouter) UserCancelPost(c *gin.Context)

取消投稿

type PostVerboseBody

type PostVerboseBody struct {
	PostID int                    `json:"post_id" binding:"required"`
	Key    string                 `json:"key" binding:"required"`
	Values map[string]interface{} `json:"values" binding:"required"`
}

type SaveMetadataBody

type SaveMetadataBody struct {
	// 元数据列表
	MetadataList []database.Metadata `json:"list" binding:"required"`
}

type SetMetadataBody

type SetMetadataBody struct {
	// 键
	Key string `json:"key" binding:"required"`

	// 值
	Value string `json:"value" binding:"required"`
}

type UserCancelPostBody

type UserCancelPostBody struct {
	PostID *int `json:"post_id" binding:"required"`
}

Jump to

Keyboard shortcuts

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