domain

package
v0.0.0-...-d00b715 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FeedLikeEvent      string = "feed-like"
	FeedUnlikeEvent    string = "feed-unlike"
	FeedCommentEvent   string = "feed-comment"
	FeedReplyEvent     string = "feed-reply"
	FeedCollectEvent   string = "feed-collect"
	FeedUncollectEvent string = "feed-uncollect"
	FeedPostEvent      string = "feed-post"
	FeedFollowEvent    string = "feed-follow"
	FeedUnfollowEvent  string = "feed-unfollow"
	FeedUnkonwnEvent   string = "feed-unknown"

	THRESHOLD int = 1000 // 读写扩散阈值
)
View Source
const (
	FileTypeUnknown = "unknown"
	FileTypeImage   = "image"

	FileSourceKnown = "unknown"
	FileSourceLocal = "local"
	FileSourceMinio = "minio"

	FileBucket = "go-backend"
)
View Source
const (
	DefaultOpenIMDomain = "http://localhost:10002"
	DefaultOpenIMSecret = "openIM123"
	DefaultOpenIMUserID = "imAdmin"

	Sync2OpenIMOpRegister = "register"
	Sync2OpenIMOpEdit     = "edit"
)
View Source
const (
	PostTopNKey = "post_topN"

	PostStatusHide    string = "hide"
	PostStatusPublish string = "publish"

	PromptOfPostAbstract = "" /* 167-byte string literal not displayed */
)
View Source
const (
	Follow   = true
	UnFollow = false
)
View Source
const (
	ESPostIndex    = "post_index"
	ESUserIndex    = "user_index"
	ESCommentIndex = "comment_index"
)
View Source
const (
	DefaultPage           = 0
	DefaultSize           = 10
	DefaultUserPassword   = "root"
	DefaultUserNamePrefix = "user"
)
View Source
const (
	XUserID       = "x-user-id"
	UserSessionID = "user-session-id"

	BizUserLogin = "login"
)
View Source
const (
	BizComment = "comment"
)
View Source
const (
	BizPost = "post"
)

Variables

View Source
var (
	ErrCodeSendTooFrequently   = errors.New("code send too frequently")
	ErrCodeVerifyTooFrequently = errors.New("code verify too frequently")
	ErrCodeInvalid             = errors.New("code invalid")
)
View Source
var (
	ErrBusy        = errors.New("系统繁忙")
	ErrSystemError = errors.New("系统错误")
	ErrUnKnowError = errors.New("未知错误")
	ErrBadParams   = errors.New("参数错误")
	ErrRateLimit   = errors.New("请求过于频繁")
)
View Source
var (
	ErrSync2OpenIMOpNotFound = errors.New("synchronous methods do not exist, only registration and editing are supported")
)

Functions

func UserLogoutKey

func UserLogoutKey(ssid string) string

Types

type BasePageRequest

type BasePageRequest struct {
	Page int `json:"page" form:"page"`
	Size int `json:"size" form:"size"`
}

type CodeRepository

type CodeRepository interface {
	SetCode(ctx context.Context, biz, number, code string) error
	VerifyCode(ctx context.Context, biz, number, code string) (bool, error)
}

type CodeUsecase

type CodeUsecase interface {
	Send(ctx context.Context, biz, number string) error
	Verify(ctx context.Context, biz, number, code string) (bool, error)
}

type Comment

type Comment struct {
	Model
	CommentID       int64  `gorm:"primaryKey" json:"comment_id,string"`
	ParentCommentID int64  `gorm:"index" json:"parent_comment_id,string"` // 一级评论的 parent_comment_id = 0 其他评论的 parent_comment_id = 一级评论的 comment_id
	Content         string `gorm:"not null" json:"content"`
	UserID          int64  `gorm:"not null" json:"user_id,string"`
	ToUserID        int64  `json:"to_user_id,string"` // 回复某人的时候,to_user_id = 被回复的用户的 user_id

	Biz   string `gorm:"index:idx_biz_biz_id" binding:"required" json:"biz"`
	BizID int64  `gorm:"index:idx_biz_biz_id" binding:"required" json:"biz_id,string"`

	LikeCount  int `json:"like_count"`  // 点赞数
	ReplyCount int `json:"reply_count"` // 回复数
}

帖子 一级评论 某个用户回复该帖子 commentid userid content 二级评论 在某个一级评论下回复 commentid userid content parentid(一级评论的commentid) 二级评论 在某个一级评论下回复某人 commentid userid content parentid(一级评论的commentid) to_userid

func (Comment) TableName

func (Comment) TableName() string

type CommentCreateRequest

type CommentCreateRequest struct {
	Biz     string `json:"biz" binding:"required"`
	BizID   string `json:"biz_id" binding:"required"`
	Content string `json:"content" binding:"required"`

	ParentID string `json:"parent_id"`  // default 0 表示回复的是帖子
	ToUserID string `json:"to_user_id"` // default 0 表示回复的是帖子 or 一级评论
}

type CommentInfo

type CommentInfo struct {
	Comment
	UserProfile   Profile `json:"user_profile,omitempty"`
	ToUserProfile Profile `json:"to_user_profile,omitempty"`
	Liked         bool    `json:"liked"`
	LikeCount     int     `json:"like_cnt"`
}

type CommentListRequest

type CommentListRequest struct {
	Biz      string `json:"biz" form:"biz"`
	BizID    string `json:"biz_id" form:"biz_id"`
	MinID    string `json:"min_id" form:"min_id"`
	Limit    int    `json:"limit" form:"limit"`
	ParentID string `json:"parent_id" form:"parent_id"` // default 0 表示查找一级评论
}

type CommentRepository

type CommentRepository interface {
	Create(c context.Context, comment *Comment) error
	Delete(c context.Context, id int64) error                                                            // 删除本节点和其对应的子节点
	Find(c context.Context, biz string, bizID, parentID, minID int64, limit int) ([]Comment, int, error) // 查找一级评论则 parentID=0
	Count(c context.Context, biz string, bizID int64) (int, error)
}

type CommentUsecase

type CommentUsecase interface {
	Create(c context.Context, comment *Comment) error
	Delete(c context.Context, id int64) error
	Find(c context.Context, biz string, bizID, parentID, minID int64, limit int) ([]Comment, int, error)
	Count(c context.Context, biz string, bizID int64) (int, error)
}

type CreateTagBizRequest

type CreateTagBizRequest struct {
	Biz    string  `json:"biz" form:"biz" binding:"required"`
	BizID  int64   `json:"biz_id" form:"biz_id" binding:"required"`
	TagIDs []int64 `json:"tag_ids" form:"tag_ids" binding:"required"`
}

type ESSearch

type ESSearch interface {
	Search()
}

type ESSync

type ESSync interface {
	InputAny(ctx context.Context, item interface{}) error

	InputUser(ctx context.Context, item User) error
	InputPost(ctx context.Context, item Post) error
}

type Feed

type Feed struct {
	Model
	UserID    int64
	Type      string
	Content   FeedContent
	CreatedAt time.Time
}

type FeedContent

type FeedContent map[string]string

type FeedHandler

type FeedHandler interface {
	CreateFeedEvent(c context.Context, t string, content FeedContent) error
	FindFeedEvent(c context.Context, userID, timestamp, limit int64) ([]Feed, error)
}

FeedHandler 具体业务的处理逻辑 按照 type 类型来分,因为 type 天然的标记业务

type FeedPull

type FeedPull struct {
	Model
	UserID    int64 `gorm:"index;not null"` // 发件人
	Type      string
	Content   string
	CreatedAt int64 `gorm:"index"`
}

FeedPull 拉模型 - 读扩散

func (FeedPull) TableName

func (FeedPull) TableName() string

type FeedPush

type FeedPush struct {
	Model
	UserID    int64  `gorm:"index;not null"` // 收件人
	Type      string // 标记事件类型 决定Content解读方式
	Content   string
	CreatedAt int64 `gorm:"index"`
}

FeedPush 推模型 - 写扩散 - 收件箱

func (FeedPush) TableName

func (FeedPush) TableName() string

type FeedRepository

type FeedRepository interface {
	CreatePush(c context.Context, feed ...Feed) error
	CreatePull(c context.Context, feed ...Feed) error
	// FindPull Get from other outbox
	FindPull(c context.Context, userIDs []int64, timestamp, limit int64) ([]Feed, error)
	// FindPush Get from inbox
	FindPush(c context.Context, userID, timestamp, limit int64) ([]Feed, error)

	FindPullWithType(c context.Context, event string, userIDs []int64, timestamp, limit int64) ([]Feed, error)
	FindPushWithType(c context.Context, event string, userID, timestamp, limit int64) ([]Feed, error)
}

type FeedUsecase

type FeedUsecase interface {
	CreateFeedEvent(c context.Context, feed Feed) error
	GetFeedEventList(c context.Context, userID, timestamp, limit int64) ([]Feed, error)
}

FeedUsecase 处理业务公共部分 并且负责找出 Handler 来处理业务的个性部分

type File

type File struct {
	Model
	FileID int64  `json:"file_id" gorm:"primaryKey"`
	Name   string `json:"name"`
	Path   string `json:"path"`
	Type   string `json:"type"`
	Source string `json:"source"`
	Hash   string `json:"hash" gorm:"unique"`
}

func (File) TableName

func (File) TableName() string

type FileListRequest

type FileListRequest struct {
	BasePageRequest
	Type   string `json:"type" from:"type"`
	Source string `json:"source" from:"source"`
}

type FileRepository

type FileRepository interface {
	Upload(c context.Context, file *File) error
	Uploads(c context.Context, files []*File) error
	FileList(c context.Context, fileType, fileSource string, page, size int) ([]File, int, error)
	FindByHash(c context.Context, hash string) (File, error)
}

type FileUploadsResponse

type FileUploadsResponse struct {
	Data map[string]interface{} `json:"data"` // 文件上传状态
}

type FileUsecase

type FileUsecase interface {
	Upload(c context.Context, file *multipart.FileHeader) (File, error) // 文件上传
	Uploads(c context.Context, files []*multipart.FileHeader) (FileUploadsResponse, error)
	FileList(c context.Context, fileType, fileSource string, page, size int) ([]File, int, error)
}

type GetAdminTokenRequest

type GetAdminTokenRequest struct {
	Secret string `json:"secret"`
	UserID string `json:"userID"`
}

type GetAdminTokenResponse

type GetAdminTokenResponse struct {
	ErrCode int    `json:"errCode"`
	ErrMsg  string `json:"errMsg"`
	ErrDlt  string `json:"errDlt"`
	Data    struct {
		Token             string `json:"token"`
		ExpireTimeSeconds int    `json:"expireTimeSeconds"`
	} `json:"data"`
}

type GetFeedEventListReq

type GetFeedEventListReq struct {
	Last  int64 `json:"last,string" form:"last"`
	Limit int64 `json:"limit,string" form:"limit"`
}

type GetTagsByBizRequest

type GetTagsByBizRequest struct {
	Biz   string `json:"biz" form:"biz" binding:"required"`
	BizID int64  `json:"biz_id" form:"biz_id" binding:"required"`
}

type GetUserTokenRequest

type GetUserTokenRequest struct {
	PlatformID int    `json:"platformID"`
	UserID     string `json:"userID"`
}

type GetUserTokenResponse

type GetUserTokenResponse struct {
	ErrCode int    `json:"errCode"`
	ErrMsg  string `json:"errMsg"`
	ErrDlt  string `json:"errDlt"`
	Data    struct {
		Token             string `json:"token"`
		ExpireTimeSeconds int    `json:"expireTimeSeconds"`
	} `json:"data"`
}

type Interaction

type Interaction struct {
	Model
	// idx_biz select * from . where biz ==
	// idx_bizID_biz 联合索引 (bizID区分度高)
	BizID int64 `json:"biz_id" gorm:"uniqueIndex:idx_interaction_bizID_biz"`
	//Biz   string `gorm:"uniqueIndex:idx_interaction_bizID_biz"`
	Biz        string `json:"biz" gorm:"type:varchar(255);uniqueIndex:idx_interaction_bizID_biz"` // MYSQL 写法
	ReadCnt    int    `json:"read_cnt"`
	LikeCnt    int    `json:"like_cnt"`
	CollectCnt int    `json:"collect_cnt"` // 3个cnt 相比较 type+cnt 在读性能友好, 每次只需要读一行
}

func (Interaction) TableName

func (Interaction) TableName() string

type InteractionRepository

type InteractionRepository interface {
	IncrReadCount(c context.Context, biz string, id int64) error
	BatchIncrReadCount(c context.Context, biz []string, id []int64) error
	Like(c context.Context, biz string, bizID, userID int64) error
	CancelLike(c context.Context, biz string, bizID, userID int64) error
	Stat(c context.Context, biz string, bizID, userID int64) (Interaction, UserInteractionStat, error)
	Collect(c context.Context, biz string, bizID, userID, collectionID int64) error
	CancelCollect(c context.Context, biz string, bizID, userID, collectionID int64) error
	GetByIDs(c context.Context, biz string, id []int64) (map[int64]Interaction, error)
}

type InteractionUseCase

type InteractionUseCase interface {
	IncrReadCount(c context.Context, biz string, id int64) error
	Like(c context.Context, biz string, bizID, userID int64) error
	CancelLike(c context.Context, biz string, bizID, userID int64) error
	Info(c context.Context, biz string, bizID, userID int64) (Interaction, UserInteractionStat, error)
	Collect(c context.Context, biz string, bizID, userID, collectionID int64) error
	CancelCollect(c context.Context, biz string, bizID, userID, collectionID int64) error
}

type JwtCustomClaims

type JwtCustomClaims struct {
	Name string `json:"name"`
	ID   int64  `json:"id"`
	SSID string `json:"ssid"`
	jwt.RegisteredClaims
}

type JwtCustomRefreshClaims

type JwtCustomRefreshClaims struct {
	ID   int64  `json:"id"`
	SSID string `json:"ssid"`
	jwt.RegisteredClaims
}

type LoginByPhoneReq

type LoginByPhoneReq struct {
	Phone    string `form:"phone" json:"phone" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

type LoginBySmsReq

type LoginBySmsReq struct {
	Phone string `form:"phone" json:"phone" binding:"required"`
	Code  string `form:"code" json:"code" binding:"required"`
}

type LoginReq

type LoginReq struct {
	Email    string `form:"email" json:"email" binding:"required"`
	Password string `form:"password" json:"password" binding:"required"`
}

type LoginResp

type LoginResp struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

type Model

type Model struct {
	ID        uint  `gorm:"primarykey" json:"-"`
	CreatedAt int64 `json:"created_at"`
	UpdatedAt int64 `json:"updated_at"`
}

type Post

type Post struct {
	Model
	PostID int64 `json:"post_id,string" gorm:"primaryKey"`

	Title    string `json:"title" form:"title"`
	Abstract string `json:"abstract" form:"abstract"`
	Content  string `json:"content" form:"content"`
	AuthorID int64  `json:"author_id,string" form:"author_id"`
	Status   string `json:"status" form:"status" binding:"required"`

	Images string `json:"images" form:"images"`
}

func (Post) TableName

func (Post) TableName() string

type PostDeleteRequest

type PostDeleteRequest struct {
	PostID int64 `json:"post_id,string" form:"post_id"`
}

type PostInfoResponse

type PostInfoResponse struct {
	Post         PostResponse        `json:"post"`
	Interaction  Interaction         `json:"interaction"`
	Stat         UserInteractionStat `json:"stat"`
	CommentCount int                 `json:"comment_count"`
}

type PostListRequest

type PostListRequest struct {
	Page     int    `json:"page" form:"page"`
	Size     int    `json:"size" form:"size"`
	AuthorID int64  `json:"author_id,string" form:"author_id"`
	Status   string `json:"status" form:"status"`
	Last     int64  `json:"last,string" form:"last"`
}

type PostRepository

type PostRepository interface {
	Create(c context.Context, post *Post) error
	Delete(c context.Context, postID int64) error
	GetByID(c context.Context, id int64) (Post, error)
	FindMany(c context.Context, filter interface{}) ([]Post, error) // Modify
	List(c context.Context, filter interface{}, page, size int) ([]Post, error)
	ListByLastID(c context.Context, filter interface{}, size int, lastID int64) ([]Post, error)
	FindTopNPage(c context.Context, page, size int, begin time.Time) ([]Post, error)
	Count(c context.Context, filter interface{}) (int64, error)
	Update(c context.Context, id int64, post *Post) error
	Search(c context.Context, keyword string, page, size int, rule []SortRule) ([]Post, int, error)
}

type PostResponse

type PostResponse struct {
	Model
	PostID int64 `json:"post_id,string"`

	Title    string `json:"title"`
	Abstract string `json:"abstract"`
	Content  string `json:"content" `
	// AuthorID int64  `json:"author_id,string" form:"author_id"`
	Status string   `json:"status"`
	Author Profile  `json:"author"`
	Images []string `json:"images"`
}

type PostSearchRequest

type PostSearchRequest struct {
	Keyword string     `json:"keyword" form:"keyword"`
	Page    int        `json:"page" form:"page"`
	Size    int        `json:"size" form:"size"`
	Sort    []SortRule `json:"sort" form:"sort"`
}

type PostUsecase

type PostUsecase interface {
	Create(c context.Context, post *Post) error
	Delete(c context.Context, postID int64) error
	List(c context.Context, filter interface{}, page, size int) ([]Post, int64, error)
	ListByLastID(c context.Context, filter interface{}, size int, lastID int64) ([]Post, int64, error)
	Info(c context.Context, postID int64) (Post, error)
	TopN(c context.Context) ([]Post, error)
	Count(c context.Context, filter interface{}) (int64, error)
	Search(c context.Context, keyword string, page, size int, rule []SortRule) ([]Post, int, error)
}

type Profile

type Profile struct {
	UserID       int64        `json:"user_id,string"`
	UserName     string       `json:"user_name"`
	NickName     string       `json:"nick_name"`
	Email        string       `json:"email"`
	AboutMe      string       `json:"about_me"`
	Birthday     time.Time    `json:"birthday"`
	Avatar       string       `json:"avatar"`
	RelationStat RelationStat `json:"relation_stat"`
	PostCnt      int64        `json:"post_cnt"`
	CreatedAt    time.Time    `json:"created_at"`
}

type RankRepository

type RankRepository interface {
	ReplaceTopN(c context.Context, items []Post, expiration time.Duration) error
	GetTopN(c context.Context) ([]Post, error)
}

type RankUsecase

type RankUsecase interface {
	TopN(c context.Context) error
}

type RefreshTokenRequest

type RefreshTokenRequest struct {
	RefreshToken string `form:"refresh_token" json:"refresh_token" binding:"required"`
}

type RefreshTokenResponse

type RefreshTokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

type RefreshTokenUsecase

type RefreshTokenUsecase interface {
	GetUserByID(c context.Context, id int64) (User, error)
	CreateAccessToken(user User, ssid string, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user User, ssid string, secret string, expiry int) (refreshToken string, err error)
	ExtractIDAndSSIDFromToken(requestToken string, secret string) (int64, string, error)
}

type Relation

type Relation struct {
	Model
	RelationID int64 `gorm:"primaryKey"`
	Followee   int64 `gorm:"not null;uniqueIndex:idx_followee_follower"` // Follower 关注了 Followee
	Follower   int64 `gorm:"not null;uniqueIndex:idx_followee_follower;index:idx_follower"`
	// 典型场景:某个人关注列表follower 某个人的粉丝列表followee 我都要
	Status bool // true 关注 false 取消关注
}

func (Relation) TableName

func (Relation) TableName() string

type RelationRepository

type RelationRepository interface {
	Follow(c context.Context, follower, followee int64) error
	CancelFollow(c context.Context, follower, followee int64) error
	GetFollower(c context.Context, follower int64, page, size int) ([]Relation, error) // 粉丝列表
	GetFollowee(c context.Context, follower int64, page, size int) ([]Relation, error) // 关注者列表
	Detail(c context.Context, follower, followee int64) bool                           // 关注状态
	FollowerCnt(c context.Context, userID int64) (int64, error)                        // 粉丝数
	FolloweeCnt(c context.Context, userID int64) (int64, error)                        // 关注数
}

type RelationStat

type RelationStat struct {
	UserID       int64 `json:"user_id,string" gorm:"unique"`
	Follower     int   `json:"follower"`      // 粉丝数
	Followee     int   `json:"followee"`      // 关注数
	FollowStatus int   `json:"follow_status"` // 0 未关注 1 已关注 2 互相关注
}

type RelationUsecase

type RelationUsecase interface {
	Follow(c context.Context, follower, followee int64) error
	CancelFollow(c context.Context, follower, followee int64) error
	GetFollower(c context.Context, userID int64, page, size int) ([]User, int, error) // 粉丝列表
	GetFollowee(c context.Context, userID int64, page, size int) ([]User, int, error) // 关注者列表
	Detail(c context.Context, follower, followee int64) bool                          // 关注状态
	Stat(c context.Context, userID int64) (RelationStat, error)
}

type ResetPasswordReq

type ResetPasswordReq struct {
	FromPassword string `form:"from_password" json:"from_password" binding:"required"`
	ToPassword   string `form:"to_password" json:"to_password" binding:"required"`
}

type Response

type Response struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
	Error   string      `json:"error"`
}

func ErrorResp

func ErrorResp(msg string, err error) Response

func SuccessResp

func SuccessResp(data interface{}) Response

type SearchRepository

type SearchRepository interface {
	SearchUser(ctx context.Context, keywords ...string) ([]User, error)
	SearchPost(ctx context.Context, userID int64, keywords ...string) ([]Post, error)
}

type SearchResult

type SearchResult struct {
	Users []User
	Posts []Post
}

type SearchUsecase

type SearchUsecase interface {
	Search(ctx context.Context, userID int64, cmd string) error // 用户画像和表达式
}

type SendSMSCodeReq

type SendSMSCodeReq struct {
	Phone string `form:"phone" json:"phone" binding:"required"`
}

type SignupReq

type SignupReq struct {
	UserName string `form:"user_name" json:"user_name" binding:"required"`
	Email    string `form:"email" json:"email" binding:"required,email"`
	Password string `form:"password" json:"password" binding:"required"`
}

type SignupResp

type SignupResp struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

type SortRule

type SortRule struct {
	Column string `json:"column" form:"column"`
	Order  string `json:"order" form:"order"`
}

type Sync2OpenIMUsecase

type Sync2OpenIMUsecase interface {
	GetAdminToken(ctx context.Context) (string, error)
	GetUserToken(ctx context.Context, PlatformID int, userID int64) (string, error)
	SyncUser(ctx context.Context, user User, op string) error
}

type Sync2OpenIMUser

type Sync2OpenIMUser struct {
	UserID   string `json:"userID"`
	NickName string `json:"nickname"`
	FaceUrl  string `json:"faceURL"`
}

type SyncUserRequest

type SyncUserRequest struct {
	Users []Sync2OpenIMUser `json:"users"`
}

type SyncUserResponse

type SyncUserResponse struct {
	ErrCode int    `json:"errCode"`
	ErrMsg  string `json:"errMsg"`
	ErrDlt  string `json:"errDlt"`
}

type Tag

type Tag struct {
	Model
	TagID   int64 `gorm:"primaryKey"`
	UserID  int64 `gorm:"index"`
	TagName string
}

func (Tag) TableName

func (Tag) TableName() string

type TagBiz

type TagBiz struct {
	Model
	Biz    string `gorm:"index:idx_tagBiz_biz_bizId"`
	BizID  int64  `gorm:"index:idx_tagBiz_biz_bizId"`
	UserID int64  `gorm:"index"`
	TagID  int64  `gorm:"index"`
}

SELECT * FROM tag_biz WHERE biz = ? and biz_id = ?

func (TagBiz) TableName

func (TagBiz) TableName() string

type TagRepository

type TagRepository interface {
	CreateTag(c context.Context, tag Tag) error                                                  // 用户创建Tag
	CreateTagBiz(c context.Context, userID int64, biz string, bizID int64, tagIDs []int64) error // 用户为某个资源加Tag
	GetTagsByUserID(c context.Context, userID int64) ([]Tag, error)                              // 查询用户所有Tag
	GetTagsByBiz(c context.Context, userID int64, biz string, bizID int64) ([]Tag, error)        // 查询用户在某个资源上打的的Tag
}

type TagUsecase

type TagUsecase interface {
	CreateTag(c context.Context, tag Tag) error
	CreateTagBiz(c context.Context, userID int64, biz string, bizID int64, tagIDs []int64) error
	GetTagsByUserID(c context.Context, userID int64) ([]Tag, error)
	GetTagsByBiz(c context.Context, userID int64, biz string, bizID int64) ([]Tag, error)
}

type Task

type Task struct {
	Model
	TaskID int64  `json:"task_id"`
	Title  string `json:"title" form:"title"`
	UserID int64  `json:"user_id,string" form:"user_id"`
}

func (Task) TableName

func (Task) TableName() string

type TaskRepository

type TaskRepository interface {
	Create(c context.Context, task Task) error
	Delete(c context.Context, taskID int64) error
}

type TaskUsecase

type TaskUsecase interface {
	Create(c context.Context, task Task) error
	Delete(c context.Context, taskID int64) error
}

type User

type User struct {
	Model
	UserID   int64     `json:"user_id,string" gorm:"primaryKey"`
	UserName string    `json:"user_name" gorm:"unique"`
	NickName string    `json:"nick_name" gorm:"size:256"`
	Email    string    `json:"email" gorm:"default:null;unique"`
	Password string    `json:"-" gorm:"size:256"`
	AboutMe  string    `json:"about_me" gorm:"size:256"`
	Birthday time.Time `json:"birthday" gorm:"default:null"`
	Phone    string    `json:"phone" gorm:"default:null;unique"`
	Region   string    `json:"region" gorm:"default:null"`
	Avatar   string    `json:"avatar" gorm:"size:1024"`
}

func (User) TableName

func (User) TableName() string

type UserBatchProfileReq

type UserBatchProfileReq struct {
	UserIDs []string `form:"user_ids" json:"user_ids"`
}

type UserCollect

type UserCollect struct {
	Model
	UserID       int64  `gorm:"uniqueIndex:idx_userCollect_userID_bizID_biz"`
	BizID        int64  `gorm:"uniqueIndex:idx_userCollect_userID_bizID_biz"`
	Biz          string `gorm:"type:varchar(255);uniqueIndex:idx_userCollect_userID_bizID_biz"`
	CollectionID int64  `gorm:"index"`
	Status       bool
}

func (UserCollect) TableName

func (UserCollect) TableName() string

type UserInteractionStat

type UserInteractionStat struct {
	Liked     bool `json:"liked"`
	Collected bool `json:"collected"`
}

type UserLike

type UserLike struct {
	Model
	UserID int64  `gorm:"uniqueIndex:idx_userLike_userID_bizID_biz"`
	BizID  int64  `gorm:"uniqueIndex:idx_userLike_userID_bizID_biz"`
	Biz    string `gorm:"type:varchar(255);uniqueIndex:idx_userLike_userID_bizID_biz"`
	Status bool   // true 点赞 false 取消点赞

}

func (UserLike) TableName

func (UserLike) TableName() string

type UserRepository

type UserRepository interface {
	Create(c context.Context, user *User) error
	GetByEmail(c context.Context, email string) (User, error)
	GetByID(c context.Context, id int64) (User, error)
	GetByPhone(c context.Context, phone string) (User, error)
	FindByUserIDs(c context.Context, userIDs []int64, page, size int) ([]User, error)
	InvalidToken(c context.Context, ssid string, exp time.Duration) error
	Update(c context.Context, id int64, user *User) error
	Search(c context.Context, keyword string, page, size int) ([]User, int, error)
}

type UserSearchReq

type UserSearchReq struct {
	Page    int    `form:"page" json:"page"`
	Size    int    `form:"size" json:"size"`
	Keyword string `form:"keyword" json:"keyword" binding:"required"`
}

type UserUsecase

type UserUsecase interface {
	GetProfileByID(c context.Context, userID int64) (Profile, error)
	BatchGetProfileByID(c context.Context, userIDs []int64) ([]Profile, error)
	UpdateProfile(c context.Context, userID int64, user *User) error
	Logout(c context.Context, SSID string, tokenExpiry time.Duration) error

	GetUserByEmail(c context.Context, email string) (User, error)
	GetUserByUserID(c context.Context, userID int64) (User, error)
	CreateAccessToken(user User, ssid string, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user User, ssid string, secret string, expiry int) (refreshToken string, err error)

	Create(c context.Context, user *User) error

	GetUserByPhone(c context.Context, phone string) (User, error)
	Search(c context.Context, keyword string, page, size int) ([]User, int, error)
}

Directories

Path Synopsis
Package domain_mock is a generated GoMock package.
Package domain_mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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