response

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

* @Author: alexander.huang * @Date: 2022-05-26 12:44:17 * @Last Modified by: alexander.huang * @Last Modified time: 2022-05-26 12:44:17

* @Author: alexander.huang * @Date: 2022-05-26 12:44:17 * @Last Modified by: alexander.huang * @Last Modified time: 2022-05-26 12:44:17

* @Author: alexander.huang * @Date: 2022-05-25 02:53:50 * @Last Modified by: alexander.huang * @Last Modified time: 2022-05-25 02:53:50

* @Author: alexander.huang * @Date: 2022-05-25 22:53:50 * @Last Modified by: alexander.huang * @Last Modified time: 2022-05-25 22:53:50

* @Author: alexander.huang * @Date: 2022-05-26 12:44:17 * @Last Modified by: alexander.huang * @Last Modified time: 2022-05-26 12:44:17

* @Author: alexander.huang * @Date: 2022-05-19 03:10:11 * @Last Modified by: alexander.huang * @Last Modified time: 2022-05-23 21:40:51

* @Author: alexander.huang * @Date: 2022-05-19 20:14:50 * @Last Modified by: alexander.huang * @Last Modified time: 2022-05-23 21:40:51

Index

Constants

This section is empty.

Variables

View Source
var ResponseSuccess = Response{
	0,
	"ok",
}

Functions

func BusinessFail

func BusinessFail(c *gin.Context, msg string)

BusinessFail 业务逻辑失败

func Fail

func Fail(c *gin.Context, errorCode int, msg string)

Fail 响应失败 ErrorCode 不为 0 表示失败

func FailByError

func FailByError(c *gin.Context, error global.CustomError)

FailByError 失败响应 返回自定义错误的错误码、错误信息

func InfoFail

func InfoFail(c *gin.Context, errorCode int, msg string)

func InfoSuccess

func InfoSuccess(c *gin.Context, user models.User)

func LoginFail

func LoginFail(c *gin.Context, errorCode int, msg string)

func LoginSuccess

func LoginSuccess(c *gin.Context, user models.User)

func RegisterFail

func RegisterFail(c *gin.Context, errorCode int, msg string)

func RegisterSuccess

func RegisterSuccess(c *gin.Context, user models.User)

func ServerError

func ServerError(c *gin.Context, err interface{})

func Success

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

Success 响应成功 ErrorCode 为 0 表示成功

func TokenFail

func TokenFail(c *gin.Context)

func ValidateFail

func ValidateFail(c *gin.Context, msg string)

ValidateFail 请求参数验证失败

Types

type Comment

type Comment struct {
	ID         uint64   `json:"id"`                                        // 评论id
	User       *UserAPI `json:"user" gorm:"embedded;embeddedPrefix:user_"` // 评论用户
	Content    string   `json:"content"`                                   // 评论内容
	CreateDate string   `json:"create_date"`                               // 评论时间
}

type CommentListResponse

type CommentListResponse struct {
	Response
	CommentList []*Comment `json:"comment_list"`
}

type CommentResponse

type CommentResponse struct {
	Response
	CommentList []*Comment `json:"comment_list"`
}

type FavoriteListResponse

type FavoriteListResponse struct {
	Response
	VideoList []*VideoAuthorApi `json:"video_list"`
}

type FeedResponse

type FeedResponse struct {
	Response
	NextTime  int64             `json:"next_time"`
	VideoList []*VideoAuthorApi `json:"video_list"`
}

type InfoResponse

type InfoResponse struct {
	Response
	User UserAPI `json:"user"`
}

type PublishListResponse

type PublishListResponse struct {
	Response
	VideoList []*VideoAuthorApi `json:"video_list"`
}

type RegisterLoginResponse

type RegisterLoginResponse struct {
	Response
	UserId uint64 `json:"user_id"`
	Token  string `json:"token"`
}

type RelationFollowListResponse

type RelationFollowListResponse struct {
	Response
	UserList []*UserAPI `json:"user_list"` // 用户信息列表
}

RelationFollowListResponse 获取关注列表响应

type RelationFollowerListResponse

type RelationFollowerListResponse struct {
	Response
	UserList []*UserAPI `json:"user_list"` // 用户信息列表
}

RelationFollowerListResponse 获取粉丝列表响应

type Response

type Response struct {
	ErrorCode int    `json:"status_code"` // 自定义错误码
	Message   string `json:"status_msg"`  // 信息
}

响应结构体

type UserAPI

type UserAPI struct {
	ID            uint64 `json:"id"`
	Name          string `json:"name"`           // 用户名称
	FollowCount   uint64 `json:"follow_count"`   // 关注总数
	FollowerCount uint64 `json:"follower_count"` // 粉丝总数
	IsFollow      bool   `json:"is_follow"`      // 是否关注
}

type VideoAuthorApi

type VideoAuthorApi struct {
	ID            uint64   `json:"id"`
	Author        *UserAPI `json:"author" gorm:"embedded;embeddedPrefix:author_"`
	PlayURL       string   `json:"play_url"`
	CoverURL      string   `json:"cover_url"`
	FavoriteCount uint64   `json:"favorite_count"`
	CommentCount  uint64   `json:"comment_count"`
	IsFavorite    bool     `json:"is_favorite"`
}

Jump to

Keyboard shortcuts

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