dbr

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContactStatusRequesting int8 = iota + 1
	ContactStatusAgree
	ContactStatusReject
	ContactStatusDeleted
)
View Source
const (
	UserStatusNormal int = iota + 1
	UserStatusClosed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	*Model
	UserID    int64          `json:"user_id"`
	FileSize  int64          `json:"file_size"`
	ImgWidth  int            `json:"img_width"`
	ImgHeight int            `json:"img_height"`
	Type      AttachmentType `json:"type"`
	Content   string         `json:"content"`
}

func (*Attachment) Create

func (a *Attachment) Create(db *gorm.DB) (*Attachment, error)

type AttachmentType

type AttachmentType int
const (
	AttachmentTypeImage AttachmentType = iota + 1
	AttachmentTypeVideo
	AttachmentTypeOther
)

type Captcha

type Captcha struct {
	*Model
	Phone     string `json:"phone"`
	Captcha   string `json:"captcha"`
	UseTimes  int    `json:"use_times"`
	ExpiredOn int64  `json:"expired_on"`
}

func (*Captcha) Create

func (c *Captcha) Create(db *gorm.DB) (*Captcha, error)

func (*Captcha) Get

func (c *Captcha) Get(db *gorm.DB) (*Captcha, error)

func (*Captcha) Update

func (c *Captcha) Update(db *gorm.DB) error

type Comment

type Comment struct {
	*Model
	PostID int64  `json:"post_id"`
	UserID int64  `json:"user_id"`
	IP     string `json:"ip"`
	IPLoc  string `json:"ip_loc"`
}

func (*Comment) CommentIdsByPostId

func (c *Comment) CommentIdsByPostId(db *gorm.DB, postId int64) (ids []int64, err error)

func (*Comment) Count

func (c *Comment) Count(db *gorm.DB, conditions *ConditionsT) (int64, error)

func (*Comment) Create

func (c *Comment) Create(db *gorm.DB) (*Comment, error)

func (*Comment) Delete

func (c *Comment) Delete(db *gorm.DB) error

func (*Comment) DeleteByPostId

func (c *Comment) DeleteByPostId(db *gorm.DB, postId int64) error

func (*Comment) Format

func (c *Comment) Format() *CommentFormated

func (*Comment) Get

func (c *Comment) Get(db *gorm.DB) (*Comment, error)

func (*Comment) List

func (c *Comment) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*Comment, error)

type CommentContent

type CommentContent struct {
	*Model
	CommentID int64        `json:"comment_id"`
	UserID    int64        `json:"user_id"`
	Content   string       `json:"content"`
	Type      PostContentT `json:"type"`
	Sort      int64        `json:"sort"`
}

func (*CommentContent) Create

func (c *CommentContent) Create(db *gorm.DB) (*CommentContent, error)

func (*CommentContent) DeleteByCommentIds

func (c *CommentContent) DeleteByCommentIds(db *gorm.DB, commentIds []int64) error

func (*CommentContent) List

func (c *CommentContent) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*CommentContent, error)

func (*CommentContent) MediaContentsByCommentId

func (c *CommentContent) MediaContentsByCommentId(db *gorm.DB, commentIds []int64) (contents []string, err error)

type CommentFormated

type CommentFormated struct {
	ID         int64                   `json:"id"`
	PostID     int64                   `json:"post_id"`
	UserID     int64                   `json:"user_id"`
	User       *UserFormated           `json:"user"`
	Contents   []*CommentContent       `json:"contents"`
	Replies    []*CommentReplyFormated `json:"replies"`
	IPLoc      string                  `json:"ip_loc"`
	CreatedOn  int64                   `json:"created_on"`
	ModifiedOn int64                   `json:"modified_on"`
}

type CommentReply

type CommentReply struct {
	*Model
	CommentID int64  `json:"comment_id"`
	UserID    int64  `json:"user_id"`
	AtUserID  int64  `json:"at_user_id"`
	Content   string `json:"content"`
	IP        string `json:"ip"`
	IPLoc     string `json:"ip_loc"`
}

func (*CommentReply) Create

func (c *CommentReply) Create(db *gorm.DB) (*CommentReply, error)

func (*CommentReply) Delete

func (c *CommentReply) Delete(db *gorm.DB) error

func (*CommentReply) DeleteByCommentIds

func (c *CommentReply) DeleteByCommentIds(db *gorm.DB, commentIds []int64) error

func (*CommentReply) Format

func (c *CommentReply) Format() *CommentReplyFormated

func (*CommentReply) Get

func (c *CommentReply) Get(db *gorm.DB) (*CommentReply, error)

func (*CommentReply) List

func (c *CommentReply) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*CommentReply, error)

type CommentReplyFormated

type CommentReplyFormated struct {
	ID         int64         `json:"id"`
	CommentID  int64         `json:"comment_id"`
	UserID     int64         `json:"user_id"`
	User       *UserFormated `json:"user"`
	AtUserID   int64         `json:"at_user_id"`
	AtUser     *UserFormated `json:"at_user"`
	Content    string        `json:"content"`
	IPLoc      string        `json:"ip_loc"`
	CreatedOn  int64         `json:"created_on"`
	ModifiedOn int64         `json:"modified_on"`
}

type ConditionsT

type ConditionsT map[string]any

type Contact

type Contact struct {
	*Model
	User         *User  `json:"-" gorm:"foreignKey:ID;references:FriendId"`
	UserId       int64  `json:"user_id"`
	FriendId     int64  `json:"friend_id"`
	GroupId      int64  `json:"group_id"`
	Remark       string `json:"remark"`
	Status       int8   `json:"status"` // 1请求好友, 2已同意好友, 3已拒绝好友, 4已删除好友
	IsTop        int8   `json:"is_top"`
	IsBlack      int8   `json:"is_black"`
	NoticeEnable int8   `json:"notice_enable"`
}

func (*Contact) BeFriendIds

func (c *Contact) BeFriendIds(db *gorm.DB) (ids []int64, err error)

func (*Contact) Count

func (m *Contact) Count(db *gorm.DB, conditions ConditionsT) (int64, error)

func (*Contact) Create

func (c *Contact) Create(db *gorm.DB) (*Contact, error)

func (*Contact) FetchByUserFriendAll

func (c *Contact) FetchByUserFriendAll(db *gorm.DB) ([]*Contact, error)

func (*Contact) FetchUser

func (c *Contact) FetchUser(db *gorm.DB) (*Contact, error)

func (*Contact) GetByUserFriend

func (c *Contact) GetByUserFriend(db *gorm.DB) (*Contact, error)

func (*Contact) List

func (c *Contact) List(db *gorm.DB, conditions ConditionsT, offset, limit int) ([]*Contact, error)

func (*Contact) MyFriendIds

func (c *Contact) MyFriendIds(db *gorm.DB) (ids []string, err error)

func (*Contact) Update

func (c *Contact) Update(db *gorm.DB) error

func (*Contact) UpdateInUnscoped

func (c *Contact) UpdateInUnscoped(db *gorm.DB) error

type Message

type Message struct {
	*Model
	SenderUserID   int64    `json:"sender_user_id"`
	ReceiverUserID int64    `json:"receiver_user_id"`
	Type           MessageT `json:"type"`
	Brief          string   `json:"brief"`
	Content        string   `json:"content"`
	PostID         int64    `json:"post_id"`
	CommentID      int64    `json:"comment_id"`
	ReplyID        int64    `json:"reply_id"`
	IsRead         int8     `json:"is_read"`
}

func (*Message) Count

func (m *Message) Count(db *gorm.DB, conditions *ConditionsT) (int64, error)

func (*Message) Create

func (m *Message) Create(db *gorm.DB) (*Message, error)

func (*Message) FetchBy

func (m *Message) FetchBy(db *gorm.DB, predicates Predicates) ([]*Message, error)

func (*Message) Format

func (m *Message) Format() *MessageFormated

func (*Message) Get

func (m *Message) Get(db *gorm.DB) (*Message, error)

func (*Message) List

func (c *Message) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*Message, error)

func (*Message) Update

func (m *Message) Update(db *gorm.DB) error

type MessageFormated

type MessageFormated struct {
	ID             int64         `json:"id"`
	SenderUserID   int64         `json:"sender_user_id"`
	SenderUser     *UserFormated `json:"sender_user"`
	ReceiverUserID int64         `json:"receiver_user_id"`
	Type           MessageT      `json:"type"`
	Brief          string        `json:"brief"`
	Content        string        `json:"content"`
	PostID         int64         `json:"post_id"`
	Post           *PostFormated `json:"post"`
	CommentID      int64         `json:"comment_id"`
	Comment        *Comment      `json:"comment"`
	ReplyID        int64         `json:"reply_id"`
	Reply          *CommentReply `json:"reply"`
	IsRead         int8          `json:"is_read"`
	CreatedOn      int64         `json:"created_on"`
	ModifiedOn     int64         `json:"modified_on"`
}

type MessageT

type MessageT int8
const (
	MsgTypePost MessageT = iota + 1
	MsgtypeComment
	MsgTypeReply
	MsgTypeWhisper
	MsgTypeRequestingFriend
	MsgTypeSystem MessageT = 99

	MsgStatusUnread = 0
	MsgStatusReaded = 1
)

type Model

type Model struct {
	ID         int64                 `gorm:"primary_key" json:"id"`
	CreatedOn  int64                 `json:"created_on"`
	ModifiedOn int64                 `json:"modified_on"`
	DeletedOn  int64                 `json:"deleted_on"`
	IsDel      soft_delete.DeletedAt `gorm:"softDelete:flag" json:"is_del"`
}

Model 公共Model

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(tx *gorm.DB) (err error)

func (*Model) BeforeUpdate

func (m *Model) BeforeUpdate(tx *gorm.DB) (err error)

type Post

type Post struct {
	*Model
	UserID          int64        `json:"user_id"`
	CommentCount    int64        `json:"comment_count"`
	CollectionCount int64        `json:"collection_count"`
	UpvoteCount     int64        `json:"upvote_count"`
	Visibility      PostVisibleT `json:"visibility"`
	IsTop           int          `json:"is_top"`
	IsEssence       int          `json:"is_essence"`
	IsLock          int          `json:"is_lock"`
	LatestRepliedOn int64        `json:"latest_replied_on"`
	Tags            string       `json:"tags"`
	AttachmentPrice int64        `json:"attachment_price"`
	IP              string       `json:"ip"`
	IPLoc           string       `json:"ip_loc"`
}

func (*Post) Count

func (p *Post) Count(db *gorm.DB, conditions *ConditionsT) (int64, error)

func (*Post) CountBy

func (p *Post) CountBy(db *gorm.DB, predicates Predicates) (count int64, err error)

func (*Post) Create

func (p *Post) Create(db *gorm.DB) (*Post, error)

func (*Post) Delete

func (s *Post) Delete(db *gorm.DB) error

func (*Post) Fetch

func (p *Post) Fetch(db *gorm.DB, predicates Predicates, offset, limit int) ([]*Post, error)

func (*Post) Format

func (p *Post) Format() *PostFormated

func (*Post) Get

func (p *Post) Get(db *gorm.DB) (*Post, error)

func (*Post) List

func (p *Post) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*Post, error)

func (*Post) Update

func (p *Post) Update(db *gorm.DB) error

type PostAttachmentBill

type PostAttachmentBill struct {
	*Model
	PostID     int64 `json:"post_id"`
	UserID     int64 `json:"user_id"`
	PaidAmount int64 `json:"paid_amount"`
}

func (*PostAttachmentBill) Create

func (p *PostAttachmentBill) Create(db *gorm.DB) (*PostAttachmentBill, error)

func (*PostAttachmentBill) Get

type PostCollection

type PostCollection struct {
	*Model
	Post   *Post `json:"-"`
	PostID int64 `json:"post_id"`
	UserID int64 `json:"user_id"`
}

func (*PostCollection) Count

func (p *PostCollection) Count(db *gorm.DB, conditions *ConditionsT) (int64, error)

func (*PostCollection) Create

func (p *PostCollection) Create(db *gorm.DB) (*PostCollection, error)

func (*PostCollection) Delete

func (p *PostCollection) Delete(db *gorm.DB) error

func (*PostCollection) Get

func (p *PostCollection) Get(db *gorm.DB) (*PostCollection, error)

func (*PostCollection) List

func (p *PostCollection) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*PostCollection, error)

type PostContent

type PostContent struct {
	*Model
	PostID  int64        `json:"post_id"`
	UserID  int64        `json:"user_id"`
	Content string       `json:"content"`
	Type    PostContentT `json:"type"`
	Sort    int64        `json:"sort"`
}

func (*PostContent) Create

func (p *PostContent) Create(db *gorm.DB) (*PostContent, error)

func (*PostContent) DeleteByPostId

func (p *PostContent) DeleteByPostId(db *gorm.DB, postId int64) error

func (*PostContent) Format

func (p *PostContent) Format() *PostContentFormated

func (*PostContent) Get

func (p *PostContent) Get(db *gorm.DB) (*PostContent, error)

func (*PostContent) List

func (p *PostContent) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*PostContent, error)

func (*PostContent) MediaContentsByPostId

func (p *PostContent) MediaContentsByPostId(db *gorm.DB, postId int64) (contents []string, err error)

type PostContentFormated

type PostContentFormated struct {
	ID      int64        `json:"id"`
	PostID  int64        `json:"post_id"`
	Content string       `json:"content"`
	Type    PostContentT `json:"type"`
	Sort    int64        `json:"sort"`
}

type PostContentT

type PostContentT int

类型,1标题,2文字段落,3图片地址,4视频地址,5语音地址,6链接地址,7附件资源

const (
	ContentTypeTitle PostContentT = iota + 1
	ContentTypeText
	ContentTypeImage
	ContentTypeVideo
	ContentTypeAudio
	ContentTypeLink
	ContentTypeAttachment
	ContentTypeChargeAttachment
)

type PostFormated

type PostFormated struct {
	ID              int64                  `json:"id"`
	UserID          int64                  `json:"user_id"`
	User            *UserFormated          `json:"user"`
	Contents        []*PostContentFormated `json:"contents"`
	CommentCount    int64                  `json:"comment_count"`
	CollectionCount int64                  `json:"collection_count"`
	UpvoteCount     int64                  `json:"upvote_count"`
	Visibility      PostVisibleT           `json:"visibility"`
	IsTop           int                    `json:"is_top"`
	IsEssence       int                    `json:"is_essence"`
	IsLock          int                    `json:"is_lock"`
	LatestRepliedOn int64                  `json:"latest_replied_on"`
	CreatedOn       int64                  `json:"created_on"`
	ModifiedOn      int64                  `json:"modified_on"`
	Tags            map[string]int8        `json:"tags"`
	AttachmentPrice int64                  `json:"attachment_price"`
	IPLoc           string                 `json:"ip_loc"`
}

type PostStar

type PostStar struct {
	*Model
	Post   *Post `json:"-"`
	PostID int64 `json:"post_id"`
	UserID int64 `json:"user_id"`
}

func (*PostStar) Count

func (p *PostStar) Count(db *gorm.DB, conditions *ConditionsT) (int64, error)

func (*PostStar) Create

func (p *PostStar) Create(db *gorm.DB) (*PostStar, error)

func (*PostStar) Delete

func (p *PostStar) Delete(db *gorm.DB) error

func (*PostStar) Get

func (p *PostStar) Get(db *gorm.DB) (*PostStar, error)

func (*PostStar) List

func (p *PostStar) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*PostStar, error)

type PostVisibleT

type PostVisibleT uint8

PostVisibleT 可访问类型,0公开,1私密,2好友

const (
	PostVisitPublic PostVisibleT = iota
	PostVisitPrivate
	PostVisitFriend
	PostVisitInvalid
)

func (PostVisibleT) String

func (p PostVisibleT) String() string

type Predicates

type Predicates map[string][]any

type Tag

type Tag struct {
	*Model
	UserID   int64  `json:"user_id"`
	Tag      string `json:"tag"`
	QuoteNum int64  `json:"quote_num"`
}

func (*Tag) Create

func (t *Tag) Create(db *gorm.DB) (*Tag, error)

func (*Tag) Delete

func (t *Tag) Delete(db *gorm.DB) error

func (*Tag) Format

func (t *Tag) Format() *TagFormated

func (*Tag) Get

func (t *Tag) Get(db *gorm.DB) (*Tag, error)

func (*Tag) List

func (t *Tag) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*Tag, error)

func (*Tag) TagsFrom

func (t *Tag) TagsFrom(db *gorm.DB, tags []string) (res []*Tag, err error)

func (*Tag) Update

func (t *Tag) Update(db *gorm.DB) error

type TagFormated

type TagFormated struct {
	ID       int64         `json:"id"`
	UserID   int64         `json:"user_id"`
	User     *UserFormated `json:"user"`
	Tag      string        `json:"tag"`
	QuoteNum int64         `json:"quote_num"`
}

type User

type User struct {
	*Model
	Nickname string `json:"nickname"`
	Username string `json:"username"`
	Phone    string `json:"phone"`
	Password string `json:"password"`
	Salt     string `json:"salt"`
	Status   int    `json:"status"`
	Avatar   string `json:"avatar"`
	Balance  int64  `json:"balance"`
	IsAdmin  bool   `json:"is_admin"`
}

func (*User) Create

func (u *User) Create(db *gorm.DB) (*User, error)

func (*User) Format

func (u *User) Format() *UserFormated

func (*User) Get

func (u *User) Get(db *gorm.DB) (*User, error)

func (*User) List

func (u *User) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*User, error)

func (*User) Update

func (u *User) Update(db *gorm.DB) error

type UserFormated

type UserFormated struct {
	ID       int64  `json:"id"`
	Nickname string `json:"nickname"`
	Username string `json:"username"`
	Status   int    `json:"status"`
	Avatar   string `json:"avatar"`
	IsAdmin  bool   `json:"is_admin"`
}

type WalletRecharge

type WalletRecharge struct {
	*Model
	UserID      int64  `json:"user_id"`
	Amount      int64  `json:"amount"`
	TradeNo     string `json:"trade_no"`
	TradeStatus string `json:"trade_status"`
}

func (*WalletRecharge) Create

func (p *WalletRecharge) Create(db *gorm.DB) (*WalletRecharge, error)

func (*WalletRecharge) Get

func (p *WalletRecharge) Get(db *gorm.DB) (*WalletRecharge, error)

type WalletStatement

type WalletStatement struct {
	*Model
	UserID          int64  `json:"user_id"`
	ChangeAmount    int64  `json:"change_amount"`
	BalanceSnapshot int64  `json:"balance_snapshot"`
	Reason          string `json:"reason"`
	PostID          int64  `json:"post_id"`
}

func (*WalletStatement) Count

func (w *WalletStatement) Count(db *gorm.DB, conditions *ConditionsT) (int64, error)

func (*WalletStatement) Create

func (w *WalletStatement) Create(db *gorm.DB) (*WalletStatement, error)

func (*WalletStatement) Get

func (w *WalletStatement) Get(db *gorm.DB) (*WalletStatement, error)

func (*WalletStatement) List

func (w *WalletStatement) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*WalletStatement, error)

Jump to

Keyboard shortcuts

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