logic

package
v0.0.0-...-a93d61e Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OneWeekInSeconds = 7 * 86400
	ScorePerVote     = 432
)
View Source
const (
	PasswordSalt = "20210407160200"
)

Variables

View Source
var (
	ErrorUserExist         = errors.New("用户已存在")
	ErrorUserNotExist      = errors.New("用户不存在")
	ErrorInvalidPassword   = errors.New("密码错误")
	ErrorGenerateTokenFail = errors.New("token 生成失败")
)
View Source
var (
	ErrVoteTimeExpire = errors.New("投票时间已过")
	ErrVoted          = errors.New("请勿重复投票")
)

Functions

func CreatePost

func CreatePost(c *gin.Context, param *models.CreatePostReq) error

CreatePost 创建帖子

func GetCommunityDetail

func GetCommunityDetail(c *gin.Context, id int64) (*mysql.Community, error)

GetCommunityDetail 获取社区详情

func GetCommunityList

func GetCommunityList(c *gin.Context) ([]mysql.Community, error)

GetCommunityList 获取社区列表

func GetPosts

func GetPosts(c *gin.Context, param *models.PostsReq) ([]mysql.Post, error)

GetPosts 帖子列表

func Signup

func Signup(param *models.SignupReq) error

Signup 注册

func VoteForPost

func VoteForPost(c *gin.Context, userId int64, param *models.VoteReq) error

VoteForPost 投票

Types

type PostDetail

type PostDetail struct {
	AuthorName string `json:"author_name"`
	VoteNum    int64  `json:"vote_num"`
	mysql.Post
	Community mysql.Community `json:"community"`
}

func GetPostDetail

func GetPostDetail(c *gin.Context, postId int64) (*PostDetail, error)

GetPostDetail 获取帖子详情

func GetPosts2

func GetPosts2(c *gin.Context, param *models.PostsReq) ([]PostDetail, error)

GetPosts2 帖子列表2

type TokenResp

type TokenResp struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

func Login

func Login(param *models.LoginReq) (*TokenResp, error)

Login 登录

func RefreshToken

func RefreshToken(c *gin.Context, aToken, rToken string) (*TokenResp, error)

RefreshToken 刷新token

Jump to

Keyboard shortcuts

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