Documentation ¶
Overview ¶
@Title controller @Description 社区相关 @Author CaptainLee1024 2020-10-06 @Update CaptainLee1024 2020-10-06
@Title controller @Description 帖子相关 @Author CaptainLee1024 2020-10-07 @Update CaptainLee1024 2020-10-07
@Title controller @Description requets @Author CaptainLee1024 2020-10-02 @Update CaptainLee1024 2020-10-02
Package controller provides ...
Package controller provides ...
Index ¶
- Constants
- Variables
- func CommunityDetailHandler(c *gin.Context)
- func CommunityHandler(c *gin.Context)
- func CreatePostHandler(c *gin.Context)
- func GetCurrentUserID(c *gin.Context) (userID int64, err error)
- func GetPostDetailHandler(c *gin.Context)
- func GetPostListHandler(c *gin.Context)
- func GetPostListHandler2(c *gin.Context)
- func InitTrans(locale string) (err error)
- func LoginHandler(c *gin.Context)
- func ParamSignUpStructLevelValidation(sl validator.StructLevel)
- func PostVoteHandler(c *gin.Context)
- func ResponseError(c *gin.Context, code ResCode)
- func ResponseErrorWithMsg(c *gin.Context, code ResCode, msg interface{})
- func ResponseSuccess(c *gin.Context, data interface{})
- func SignUpHandler(c *gin.Context)
- type ResCode
- type ResponseData
Constants ¶
const CtxUserIDKey = "userID"
Variables ¶
var ErrorUserNotLogin = errors.New("用户未登录")
Functions ¶
func CommunityDetailHandler ¶
CommunityDetailHandler 社区分类详情
func CommunityHandler ¶
func CreatePostHandler ¶
CreatePostHandler 创建帖子 @Summary 创建帖子接口 @Description 根据用户输入的数据创建一个帖子 @Tags 帖子相关接口 @Accept application/json @Produce application/json @Param Authorization header string true "Bearer JWT" @Param object body models.Post false "帖子参数" @Security ApiKeyAuth @Success 200 {object} _ResponsePostList @Router /post [post]
func GetCurrentUserID ¶
GetCurrentUserID 获取当前登录用户的 ID
func GetPostDetailHandler ¶
GetPostDetailHandler 获取帖子详情的接口 @Summary 获取帖子详情的接口 @Description 根据传入的postid查询帖子的详细信息 @Tags 帖子相关接口 @Accept application/json @Produce application/json @Param Authorization header string true "Bearer JWT" @Param id path string true "帖子ID" @Security ApiKeyAuth @Success 200 {object} _ResponsePostList @Router /post/{id} [get]
func GetPostListHandler ¶
GetPostListHandler 获取帖子列表的接口 @Summary 获取帖子列表的接口 @Description 获取所有帖子列表,根据传递的参数进行分页,按照发部顺序进行排序 @Tags 帖子相关接口 @Accept application/json @Produce application/json @Param Authorization header string true "Bearer JWT" @Param page query int false "页码" @Param size query int false "每页数量" @Security ApiKeyAuth @Success 200 {object} _ResponsePostList @Router /posts [get]
func GetPostListHandler2 ¶
GetPostListHandler2 升级版帖子列表接口 根据前端传来的参数动态的获取帖子列表 按创建时间或者按分数进行排序 @Summary 升级版帖子列表接口 @Description 可按社区时间或分数排序查询帖子列表接口 @Tags 帖子相关接口 @Accept application/json @Produce application/json @Param Authorization header string true "Bearer 用户令牌" @Param object query models.ParamPostList false "查询参数" Security ApiKeyAuth @Success 200 {object} _ResponsePostList @Router /posts2 [get]
func ParamSignUpStructLevelValidation ¶
func ParamSignUpStructLevelValidation(sl validator.StructLevel)
为 ParamSignUp 自定义一个校验方法,用于比较密码和确认密码,并返回错误信息
func ResponseErrorWithMsg ¶
ResponseErrorWithMsg 返回自定义的错误状态码和信息
func ResponseSuccess ¶
ResponseSuccess 成功时返回定义好的状态码、信息
Types ¶
type ResCode ¶
type ResCode int64
type ResponseData ¶
type ResponseData struct { Code ResCode `json:"code"` // 业务状态码 Msg interface{} `json:"msg"` // 提示信息 Data interface{} `json:"data,omitempty"` // 数据 }