topics

package
v0.2.63 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CantWriteNew

func CantWriteNew(userId uint64, maxCount int64) bool

func Create

func Create(entity *Entity) error

func DecrementLike

func DecrementLike(entity Entity) int64

func DecrementPostFast

func DecrementPostFast(topicId uint64, posters []Poster, lastPostID uint64, lastPostedAt time.Time) error

func Delete

func Delete(entity *Entity) int64

func GetMapByIds

func GetMapByIds(ids []uint64) map[uint64]Entity

func GetMaxId

func GetMaxId() uint64

func GetPointerMapByIds

func GetPointerMapByIds(ids []uint64) map[uint64]*Entity

func IncrementLike

func IncrementLike(entity Entity) int64

func IncrementPostFast

func IncrementPostFast(topicId uint64, posters []Poster, lastPostID uint64, lastPostedAt time.Time) error

func IncrementPostFastWithDB added in v0.2.61

func IncrementPostFastWithDB(db *gorm.DB, topicId uint64, posters []Poster, lastPostID uint64, lastPostedAt time.Time) error

func IncrementViews

func IncrementViews(counts map[uint64]uint64) error

func PageForAdmin

func PageForAdmin(q AdminPageQuery) struct {
	Page     int
	PageSize int
	HasNext  bool
	Data     []Entity
}

func PageForModeration

func PageForModeration(q ModerationPageQuery) struct {
	Page     int
	PageSize int
	Total    int64
	HasNext  bool
	Data     []Entity
}

func ReservePostSequence

func ReservePostSequence(topicId uint64) (uint64, error)

func ReservePostSequenceWithDB added in v0.2.61

func ReservePostSequenceWithDB(db *gorm.DB, topicId uint64) (uint64, error)

func Save

func Save(entity *Entity) error

func SaveNoUpdate

func SaveNoUpdate(entity *Entity) error

func SaveOrCreateById

func SaveOrCreateById(entity *Entity) int64

func UpdatePinWeight

func UpdatePinWeight(id uint64, pinWeight int) error

func UpdateProcessStatus

func UpdateProcessStatus(id uint64, processStatus int8) error

Types

type AdminPageQuery

type AdminPageQuery struct {
	Page, PageSize int
	Search         string
	UserId         uint64
}

type Entity

type Entity struct {
	Id          uint64   `` /* 360-byte string literal not displayed */
	Title       string   `gorm:"column:title;type:varchar(512);not null;default:'';" json:"title"`
	CategoryIds []uint64 `gorm:"column:category_id;type:varchar(255);not null;default:'[]';serializer:json" json:"categoryIds"`
	// MainCategoryId is CategoryIds[0]. It is the only category that decides who
	// may read the topic. Remaining categories are public auxiliary tags; a
	// restricted category must be the topic's only category.
	MainCategoryId uint64         `gorm:"column:main_category_id;type:bigint unsigned;not null;default:0;index:idx_topics_main_category;" json:"mainCategoryId"`
	UserId         uint64         `` /* 160-byte string literal not displayed */
	Status         int8           `` /* 263-byte string literal not displayed */
	ProcessStatus  int8           `` /* 278-byte string literal not displayed */
	LikeCount      uint64         `gorm:"column:like_count;type:bigint unsigned;not null;default:0;" json:"likeCount"`
	ViewCount      uint64         `` /* 133-byte string literal not displayed */
	PostCount      uint64         `gorm:"column:post_count;type:bigint unsigned;not null;default:0;" json:"postCount"`
	ReplyCount     uint64         `` /* 131-byte string literal not displayed */
	PostSeq        uint64         `gorm:"column:post_seq;type:bigint unsigned;not null;default:0;" json:"postSeq"`
	FirstPostId    uint64         `gorm:"column:first_post_id;type:bigint unsigned;not null;default:0;" json:"firstPostId"`
	LastPostId     uint64         `gorm:"column:last_post_id;type:bigint unsigned;not null;default:0;" json:"lastPostId"`
	LastPostedAt   *time.Time     `gorm:"column:last_posted_at;index:idx_topics_last_posted,sort:desc;" json:"lastPostedAt"`
	PinWeight      int            `` /* 224-byte string literal not displayed */
	Excerpt        string         `gorm:"column:excerpt;type:varchar(255);not null;default:'';" json:"excerpt"`
	FirstImageURL  string         `gorm:"column:first_image_url;type:varchar(512);not null;default:'';" json:"firstImageUrl"`
	Posters        []Poster       `gorm:"column:posters;type:text;serializer:json" json:"posters"`
	CreatedAt      time.Time      `gorm:"column:created_at;autoCreateTime;<-:create;index:idx_topics_list_new,priority:3,sort:desc;" json:"createdAt"`
	UpdatedAt      time.Time      `` /* 211-byte string literal not displayed */
	DeletedAt      gorm.DeletedAt `json:"-"`
}

func Get

func Get(id uint64) (entity Entity)

func GetDraftsByUserId

func GetDraftsByUserId(userId uint64, limit int) ([]*Entity, error)

func GetLatestPublished

func GetLatestPublished(limit int) (entities []*Entity, err error)

func GetLatestPublishedByUserId

func GetLatestPublishedByUserId(userId uint64, limit int) ([]*Entity, error)

func GetLatestPublishedByUserIdForAudience added in v0.2.61

func GetLatestPublishedByUserIdForAudience(userId uint64, limit int, readableCategoryIDs []uint64, filterAudience bool) ([]*Entity, error)

func GetLatestPublishedForAudience added in v0.2.61

func GetLatestPublishedForAudience(limit int, readableCategoryIDs []uint64, filterAudience bool) (entities []*Entity, err error)

func GetPublishedByUserBeforeId

func GetPublishedByUserBeforeId(userId uint64, beforeId uint64, limit int) ([]*Entity, error)

func GetPublishedByUserBeforeIdForAudience added in v0.2.61

func GetPublishedByUserBeforeIdForAudience(userId uint64, beforeId uint64, limit int, readableCategoryIDs []uint64, filterAudience bool) ([]*Entity, error)

func GetSimple

func GetSimple(id any) (entity Entity)

func QueryById

func QueryById(startId uint64, limit int) (entities []*Entity)

func (*Entity) GetPosters

func (itself *Entity) GetPosters() []Poster

func (*Entity) TableName

func (itself *Entity) TableName() string

type ModerationPageQuery

type ModerationPageQuery struct {
	Page, PageSize      int
	FilterProcessStatus bool
	ProcessStatus       int8
	CategoryIDs         []uint64
}

type PageQuery

type PageQuery struct {
	Page, PageSize      int
	Search              string
	UserId              uint64
	FilterStatus        bool
	CategoryId          uint64
	FilterAudience      bool
	ReadableCategoryIds []uint64
	Sort                string
}

type Poster

type Poster struct {
	UserID uint64 `json:"user_id"`
}

type TopicPage added in v0.2.61

type TopicPage struct {
	Page     int
	PageSize int
	HasNext  bool
	Data     []Entity
}

func Page

func Page(q PageQuery) TopicPage

func PageWithDB added in v0.2.61

func PageWithDB(conn *gorm.DB, q PageQuery) TopicPage

Jump to

Keyboard shortcuts

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