service

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	Id         uint64 `json:"id,omitempty"`
	User       User   `json:"user"`
	Content    string `json:"content,omitempty"`
	CreateDate string `json:"create_date,omitempty"`
}

type CommentActionResponse

type CommentActionResponse struct {
	Response
	Comment Comment `json: "comment"`
}

type CommentListResponse

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

type FeedResponse

type FeedResponse struct {
	Response
	VideoList []Video `json:"video_list,omitempty"`
	NextTime  int64   `json:"next_time,omitempty"`
}

type Response

type Response struct {
	StatusCode int32  `json:"status_code"`
	StatusMsg  string `json:"status_msg,omitempty"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(cfg *config.Config, db *gorm.DB,
	rds *redis.Client,
	logger *zap.Logger,
	producer sarama.AsyncProducer,
	s3 s3Object.S3ObjectAPI) *Service

启动一个新的service实例,当然是单例模式

func (*Service) DeleteComment

func (s *Service) DeleteComment(selfId uint64, commentId uint64) (*CommentActionResponse, error)

func (*Service) Follow

func (s *Service) Follow(userId uint64, to_userId uint64) Response

func (*Service) GetCommentList

func (s *Service) GetCommentList(selfId uint64, videoId uint64) (*CommentListResponse, error)

func (*Service) GetCoverFileName

func (s *Service) GetCoverFileName(filename string) string

func (*Service) GetCoverFromVideoFile

func (s *Service) GetCoverFromVideoFile(data io.Reader) (io.Reader, error)

func (*Service) GetFeed

func (s *Service) GetFeed(ctx context.Context, userId uint64, isnew bool, isTour bool, lasttime time.Time) (*FeedResponse, error)

func (*Service) GetFollowList

func (s *Service) GetFollowList(selfId uint64, userId uint64) UserListResponse

func (*Service) GetFollowerList

func (s *Service) GetFollowerList(selfId uint64, userId uint64) UserListResponse

func (*Service) GetLikeList

func (s *Service) GetLikeList(selfId uint64, userId uint64) *VideoListResponse

func (*Service) GetUserInfo

func (s *Service) GetUserInfo(selfId uint64, UserID uint64) (*UserResponse, error)

func (*Service) GetVideoList

func (s *Service) GetVideoList(ctx context.Context, selfId uint64, userId uint64) *VideoListResponse

func (*Service) Hash

func (s *Service) Hash(data []byte) string

func (*Service) LikeDisliakeVideo

func (s *Service) LikeDisliakeVideo(userId uint64, videoId uint64, like bool) *Response

func (*Service) Login

func (s *Service) Login(username string, password string) (*UserLoginResponse, error)

func (*Service) PreSignUrl

func (s *Service) PreSignUrl(filename *string) (string, error)

func (*Service) PublishComment

func (s *Service) PublishComment(userId uint64, videoId uint64, content string) (*CommentActionResponse, error)

func (*Service) PublishVideo

func (s *Service) PublishVideo(ctx context.Context, UserID uint64, filename string, videodata io.Reader, title string) Response

上传video的部分,上传到s3是异步的,所以这里不需要等待立刻返回

func (*Service) PutVideoInfoToRedis

func (s *Service) PutVideoInfoToRedis(ctx context.Context, video *model.Video)

func (*Service) Register

func (s *Service) Register(username string, password string) (*UserRegisterResponse, error)

func (*Service) UnFollow

func (s *Service) UnFollow(userId uint64, to_userId uint64) Response

func (*Service) UploadCoverToS3

func (s *Service) UploadCoverToS3(ctx context.Context, filename string, coverdata io.Reader)

func (*Service) UploadToS3

func (s *Service) UploadToS3(ctx context.Context, filename string, data io.Reader, contenttype string)

func (*Service) UploadVideoToS3

func (s *Service) UploadVideoToS3(ctx context.Context, filename string, videodata io.Reader)

type User

type User struct {
	ID            uint64 `json:"id"`
	Username      string `json:"name"`
	FollowCount   int64  `json:"follow_count"`
	FollowerCount int64  `json:"follower_count"`
	IsFollow      bool   `json:"is_follow"`
}

type UserListResponse

type UserListResponse struct {
	Response
	UserList []User `json:"user_list"`
}

type UserLoginResponse

type UserLoginResponse struct {
	Response
	UserID uint64 `json:"user_id,omitempty"`
	Token  string `json:"token"`
}

type UserRegisterResponse

type UserRegisterResponse struct {
	Response
	UserID uint64 `json:"user_id,omitempty"`
	Token  string `json:"token"`
}

type UserResponse

type UserResponse struct {
	Response
	User User `json:"user"`
}

type Video

type Video struct {
	Id            uint64 `json:"id,omitempty"`
	Author        User   `json:"author"`
	PlayUrl       string `json:"play_url,omitempty"`
	CoverUrl      string `json:"cover_url,omitempty"`
	FavoriteCount uint64 `json:"favorite_count,omitempty"`
	CommentCount  uint64 `json:"comment_count,omitempty"`
	IsFavorite    bool   `json:"is_favorite,omitempty"`
	Title         string `json:"title,omitempty"`
}

type VideoListResponse

type VideoListResponse struct {
	Response
	VideoList []Video `json:"video_list"`
}

Jump to

Keyboard shortcuts

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