controller

package
v0.0.0-...-d50d8eb Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostOrderByTime  = "time"
	PostOrderByScore = "score"
)
View Source
const (
	CodeUrlQueryID   = "id"
	ContextUserIDKey = "userID"
	CodeUrlQueryPage = "page"
	CodeUrlQuerySize = "size"
)

Variables

View Source
var ErrorUserNotLogin = errors.New("用户未登录")

Functions

func CommunityDetailHandler

func CommunityDetailHandler(c *gin.Context)

func CommunityListHandler

func CommunityListHandler(c *gin.Context)

func CreatePostHandler

func CreatePostHandler(c *gin.Context)

CreatePostHandler 创建帖子

func GetPostDetailHandler

func GetPostDetailHandler(c *gin.Context)

GetPostDetailHandler 获取帖子详细内容

func GetPostListHandler

func GetPostListHandler(c *gin.Context)

GetPostListHandler 获取帖子列表

func GetPostListOrderHandler

func GetPostListOrderHandler(c *gin.Context)

GetPostListHandler2 根据时间或热度,对帖子进行排序展示 1. 获取分页和排序参数 2. 去 redis 中获取对应的post_id查询结果 3. 在 mysql 中,根据post_id查询对应的帖子详情

func InitTrans

func InitTrans(locale string) (err error)

InitTrans 初始化翻译器

func LoginHandler

func LoginHandler(c *gin.Context)

LoginHandler 处理登录请求

func PostVoteHandler

func PostVoteHandler(c *gin.Context)

帖子投票功能梳理

  1. 接收参数,参数包含 投票人 ID,帖子 ID,以及投票方向
  2. 接受参数后,交由 redis 处理,分别存储三个 zset {
  3. PostID:Time // 按照时间排序的 zset
  4. PostID:Score // 按照分数排序的 zset
  5. PostId: // 某篇帖子投票的用户 zset }

func ResponsSuccess

func ResponsSuccess(c *gin.Context, data interface{})

func ResponseError

func ResponseError(c *gin.Context, code ResCode)

func ResponseErrorWithMsg

func ResponseErrorWithMsg(c *gin.Context, code ResCode, msg interface{})

func SignUpHandler

func SignUpHandler(c *gin.Context)

SignUpHandler 处理注册请求

Types

type ResCode

type ResCode int64
const (
	CodeSuccess ResCode = 1000 + iota
	CodeInvalidParam
	CodeUserExist
	CodeUserNotExist
	CodeInvalidPassword
	CodeServerBusy
	CodeNeedLogin
	CodeInvildToken
)

func (ResCode) Msg

func (c ResCode) Msg() string

type ResponseData

type ResponseData struct {
	Code ResCode     `json:"code"`
	Msg  interface{} `json:"msg"`
	Data interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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