Documentation ¶
Index ¶
- Constants
- Variables
- func CommunityDetailHandler(c *gin.Context)
- func CommunityListHandler(c *gin.Context)
- func CreatePostHandler(c *gin.Context)
- func GetPostDetailHandler(c *gin.Context)
- func GetPostListHandler(c *gin.Context)
- func GetPostListOrderHandler(c *gin.Context)
- func InitTrans(locale string) (err error)
- func LoginHandler(c *gin.Context)
- func PostVoteHandler(c *gin.Context)
- func ResponsSuccess(c *gin.Context, data interface{})
- func ResponseError(c *gin.Context, code ResCode)
- func ResponseErrorWithMsg(c *gin.Context, code ResCode, msg interface{})
- func SignUpHandler(c *gin.Context)
- type ResCode
- type ResponseData
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 CommunityListHandler ¶
func GetPostListOrderHandler ¶
GetPostListHandler2 根据时间或热度,对帖子进行排序展示 1. 获取分页和排序参数 2. 去 redis 中获取对应的post_id查询结果 3. 在 mysql 中,根据post_id查询对应的帖子详情
func PostVoteHandler ¶
帖子投票功能梳理
- 接收参数,参数包含 投票人 ID,帖子 ID,以及投票方向
- 接受参数后,交由 redis 处理,分别存储三个 zset {
- PostID:Time // 按照时间排序的 zset
- PostID:Score // 按照分数排序的 zset
- PostId: // 某篇帖子投票的用户 zset }
func ResponsSuccess ¶
func ResponseError ¶
func ResponseErrorWithMsg ¶
Types ¶
type ResponseData ¶
type ResponseData struct { Code ResCode `json:"code"` Msg interface{} `json:"msg"` Data interface{} `json:"data"` }
Click to show internal directories.
Click to hide internal directories.