response

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrResp

func ErrResp(c *gin.Context)

func ErrRespWithData

func ErrRespWithData(c *gin.Context, msg string, data map[string]interface{})

func ErrRespWithMsg

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

func Msg

func Msg(code Code) string

func OKResp

func OKResp(c *gin.Context)

func OKRespWithData

func OKRespWithData(c *gin.Context, data map[string]interface{})

Types

type AuthResponse

type AuthResponse struct {
	StatusCode    int    `json:"status_code"`
	StatusMessage string `json:"status_msg"`
}

type Code

type Code int
const (
	OK Code = iota
	Error
	UnknownError
)

type CommentResponse

type CommentResponse struct {
	CommentID  int64        `json:"id"`          // 评论ID
	User       UserResponse `json:"user"`        // 评论用户
	Content    string       `json:"content"`     // 评论内容
	CreateDate string       `json:"create_date"` // 评论发布日期,格式 mm-dd
}

type FriendUserResponse

type FriendUserResponse struct {
	UserResponse
	Message string `json:"message"`  // 和该好友的最新聊天消息
	MsgType int64  `json:"msg_type"` // message消息的类型,0 => 当前请求用户接收的消息, 1 => 当前请求用户发送的消息
}

type MessageResponse

type MessageResponse struct {
	ID         int64  `json:"id"`           // 消息ID
	ToUserID   int64  `json:"to_user_id"`   // 消息接收者id
	FromUserID int64  `json:"from_user_id"` // 消息发送者id
	Content    string `json:"content"`      // 消息内容
	CreateTime string `json:"create_time"`  // 消息发送时间 yyyy-MM-dd HH:MM:ss
}

type UserResponse

type UserResponse struct {
	UserID         int64  `json:"id"`               // 用户ID
	Username       string `json:"name"`             // 用户名
	FollowCount    int64  `json:"follow_count"`     // 该用户关注了多少个其他用户
	FollowerCount  int64  `json:"follower_count"`   // 该用户粉丝总数
	IsFollow       bool   `json:"is_follow"`        // true: 已关注 false: 未关注
	Avatar         string `json:"avatar"`           // 头像
	BackGroudImage string `json:"background_image"` // 背景大图
	Signature      string `json:"signature"`        // 个人简介
	TotalFavorite  int64  `json:"total_favorite"`   // 该用户获赞总量
	WorkCount      int64  `json:"work_count"`       // 作品数量
	FavoriteCount  int64  `json:"favorite_count"`   // 喜欢的作品数量
}

func GetUserResponseByID

func GetUserResponseByID(targetID int64, ownerID int64) (*UserResponse, error)

GetUserResponseByID 返回用户信息,targetID 为目标用户 id,ownerID 为当前登录用户 id

func GetUserResponseByOwnerId

func GetUserResponseByOwnerId(ownerID int64) (*UserResponse, error)

GetUserResponseByOwnerId 返回用户信息,ownerID 为当前登录用户 id

type VideoResponse

type VideoResponse struct {
	VideoID       int64        `json:"id"`             // 视频唯一标识
	Author        UserResponse `json:"author"`         // 视频作者信息
	PlayURL       string       `json:"play_url"`       // 视频播放地址
	CoverURL      string       `json:"cover_url"`      // 视频封面地址
	FavoriteCount int64        `json:"favorite_count"` // 视频的点赞总数
	CommentCount  int64        `json:"comment_count"`  // 视频的评论总数
	IsFavorite    bool         `json:"is_favorite"`    // true-已点赞,false-未点赞
	Title         string       `json:"title"`          // 视频标题
}

func GetFavoriteVideoListResponseByOwnerID

func GetFavoriteVideoListResponseByOwnerID(ownerID int64) ([]VideoResponse, error)

GetFavoriteVideoListResponseByOwnerID 根据用户 id 获取喜欢列表

func GetVideoListResponseByID

func GetVideoListResponseByID(targetID, ownerID int64) ([]VideoResponse, error)

GetVideoListResponseByID 根据两个用户 id 来获取视频列表

func GetVideoListResponseByIDAndLatestTime

func GetVideoListResponseByIDAndLatestTime(targetID, ownerID int64, latestTime string) ([]VideoResponse, error)

GetVideoListResponseByIDAndLatestTime 根据两个用户 id 来获取视频列表,如果 targetID 或者 ownerID 为 0,则通过时间戳来获取视频, 即未登录状态

func GetVideoListResponseByOwnerIDAndLatestTime

func GetVideoListResponseByOwnerIDAndLatestTime(ownerID int64, latestTime string) ([]VideoResponse, error)

GetVideoListResponseByOwnerIDAndLatestTime 根据 当前登录用户 id 和 时间戳 来获取视频列表

func GetVideoResponseByVideoAndOwnerID

func GetVideoResponseByVideoAndOwnerID(video *model.Video, ownerID int64) (*VideoResponse, error)

GetVideoResponseByVideoAndOwnerID 根据 video 和 ownerID 来获取视频

Jump to

Keyboard shortcuts

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