controllers

package
v0.0.0-...-82c29ab Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2017 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColorList = [8]string{
	"pink",
	"red",
	"orange",
	"green",
	"cyan",
	"blue",
	"purple",
}

ColorList 颜色数组

View Source
var SigningAlgorithm = "HS256"

SigningAlgorithm token加密算法

View Source
var Timeout = time.Hour * 24 * 7

Timeout token持续时间, 设置为一周

Functions

func AddArticleHandler

func AddArticleHandler(c *gin.Context)

AddArticleHandler 增加文章

func AddCategoryHandler

func AddCategoryHandler(c *gin.Context)

AddCategoryHandler 新增一个分类名

func AddTagHandler

func AddTagHandler(c *gin.Context)

AddTagHandler 增加标签

func AdminLoginHandler

func AdminLoginHandler(c *gin.Context)

AdminLoginHandler 管理员登录,没有限制同一个ip的错误登录次数,容易被爆破,以后加登录序列

func AdminLogout

func AdminLogout(c *gin.Context)

AdminLogout 管理员退出

func AdminUpdateInfoHandler

func AdminUpdateInfoHandler(c *gin.Context)

AdminUpdateInfoHandler 更改管理员信息

func AdminUpdatePasswordhandler

func AdminUpdatePasswordhandler(c *gin.Context)

AdminUpdatePasswordhandler 更改管理员密码

func AdminUploadImageHandler

func AdminUploadImageHandler(c *gin.Context)

AdminUploadImageHandler 上传管理员头像,不允许超过 4M

func GetAccesskey

func GetAccesskey(c *gin.Context)

GetAccesskey 获取临时上传 accesskey

func GetAdminInfo

func GetAdminInfo(c *gin.Context)

GetAdminInfo 获取管理员信息

func GetAllArticlesHandler

func GetAllArticlesHandler(c *gin.Context)

GetAllArticlesHandler 获取文章列表

func GetAllCategoryHandler

func GetAllCategoryHandler(c *gin.Context)

GetAllCategoryHandler 获取全部分类名或者分类名包含的博文

func GetAllTagHandler

func GetAllTagHandler(c *gin.Context)

GetAllTagHandler 获取全部标签

func GetAllUser

func GetAllUser(c *gin.Context)

GetAllUser 查询所有用户信息

func GetArticleByCategory

func GetArticleByCategory(c *gin.Context)

查询各个分类名文章详情

func GetArticleByID

func GetArticleByID(c *gin.Context)

GetArticleByID 根据id获取博文

func GetUserByUserID

func GetUserByUserID(c *gin.Context)

GetUserByUserID 根据 UserID 获取用户信息

func GetVisitCount

func GetVisitCount(c *gin.Context)

GetVisitCount 获取访问人数信息

func RegisterUser

func RegisterUser(c *gin.Context)

RegisterUser 用户注册

func UpdateCategoryHandler

func UpdateCategoryHandler(c *gin.Context)

UpdateCategoryHandler 修改某个分类名

func UpdateTagHandler

func UpdateTagHandler(c *gin.Context)

UpdateTagHandler 修改标签

func UpdateUserID

func UpdateUserID(c *gin.Context)

UpdateUserID 修改用户ID

func UpdateUserName

func UpdateUserName(c *gin.Context)

UpdateUserName 更改用户名

func UpdateUserPassword

func UpdateUserPassword(c *gin.Context)

UpdateUserPassword 更新用户密码

func UserLoginHandler

func UserLoginHandler(c *gin.Context)

UserLoginHandler 用户登录

Types

type Admin

type Admin struct {
	ID          uint   `db:"id" json:"id"`
	AdminID     string `db:"admin_id" json:"admin_id"`
	Password    string `db:"password" json:"password"`
	AdminName   string `db:"admin_name" json:"admin_name"`
	Image       string `db:"image" json:"image"`
	LastLoginAt string `db:"last_login_at" json:"last_login_at"`
	IP          string `db:"ip" json:"ip"`
}

type AdminLoginForm

type AdminLoginForm struct {
	AdminID  string `form:"admin_id" json:"admin_id" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

AdminLoginForm 登录表单

type AdminUpdateInfoForm

type AdminUpdateInfoForm struct {
	AdminID   string `form:"admin_id" json:"admin_id" binding:"required"`
	AdminName string `form:"admin_name" json:"admin_name" binding:"required"`
	Image     string `form:"image" json:"image" binding:"required"`
}

AdminUpdateInfoForm 更改管理员信息表单

type AdminUpdatePasswordForm

type AdminUpdatePasswordForm struct {
	OldPassword string `form:"old_password" json:"old_password" binding:"required"`
	NewPassword string `form:"new_password" json:"new_password" binding:"required"`
}

AdminUpdatePasswordForm 更改密码表单

type ArticleForm

type ArticleForm struct {
	ArticleTitle       string   `form:"article_title" json:"article_title" binding:"required"`
	ArticlePreviewText string   `form:"article_previewtext" json:"article_previewtext" binding:"required"`
	ArticleContent     string   `form:"article_content" json:"article_content" binding:"required"`
	Category           uint     `form:"category" json:"category" binding:"required"`
	Tags               []string `form:"tags" json:"tags" binding:"required"`
}

ArticleForm 文章表单

type ArticleRes

type ArticleRes struct {
	ID                 uint            `json:"id"`
	CreateAt           string          `json:"create_at"`
	UpdateAt           string          `json:"update_at"`
	VisitCount         uint            `json:"visit_count"`
	ReplyCount         uint            `json:"reply_count"`
	ArticleTitle       string          `json:"article_title"`
	ArticlePreviewText string          `json:"article_previewtext"`
	ArticleContent     string          `json:"article_content"`
	Top                bool            `json:"top"`
	Category           models.Category `json:"category"`
	TagList            []models.Tag    `json:"tag_list"`
}

ArticleRes 定义博文响应的结构体

type CategoryForm

type CategoryForm struct {
	Category string `form:"category" json:"category" binding:"required"`
}

CategoryForm 增加分类名表单结构

type ChangePasswordForm

type ChangePasswordForm struct {
	Password string `form:"password" json:"password" binding:"required"`
}

ChangePasswordForm 更改密码表单

type ConfigStruct

type ConfigStruct struct {
	Expiration string     `json:"expiration"`
	Conditions [][]string `json:"conditions"`
}

ConfigStruct 配置

type PolicyToken

type PolicyToken struct {
	AccessKeyID string `json:"accessid"`
	Host        string `json:"host"`
	Expire      int64  `json:"expire"`
	Signature   string `json:"signature"`
	Policy      string `json:"policy"`
	Directory   string `json:"dir"`
}

PolicyToken 安全token

type TagForm

type TagForm struct {
	Color    string `form:"color" json:"color" binding:"required"`
	TagTitle string `form:"tag_title" json:"tag_title" binding:"required"`
}

TagForm 定义提交的tag表单

type UserLoginForm

type UserLoginForm struct {
	UserID   string `form:"user_id" json:"user_id" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

UserLoginForm 用户登录表单结构

type UserRegisterForm

type UserRegisterForm struct {
	UserID   string `form:"user_id" json:"user_id" binding:"required"`
	UserName string `form:"user_name" json:"user_name" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

UserRegisterForm 用户注册表单结构

Jump to

Keyboard shortcuts

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