domain

package
v0.0.0-...-e6cce5a Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnderReview uint8 = iota
	Approved
	UnApproved
)
View Source
const (
	LotteryStatusPending   string = "pending"   // 待开始
	LotteryStatusActive    string = "active"    // 进行中
	LotteryStatusCompleted string = "completed" // 已完成
)
View Source
const (
	SecondKillStatusPending   string = "pending"   // 待开始
	SecondKillStatusActive    string = "active"    // 进行中
	SecondKillStatusCompleted string = "completed" // 已完成
)
View Source
const (
	Draft     uint8 = iota // 0: 草稿状态
	Published              // 1: 发布状态
	Withdrawn              // 2: 撤回状态
	Deleted                // 3: 删除状态

)

Variables

View Source
var (
	ErrInvalidUsernameFormat = errors.New("invalid username format")
	ErrInvalidPasswordFormat = errors.New("invalid password format")
	ErrPasswordMismatch      = errors.New("password mismatch")
)
View Source
var ErrNotFound = errors.New("record not found")

Functions

This section is empty.

Types

type Api

type Api struct {
	ID          int    `json:"id"`          // 主键ID
	Name        string `json:"name"`        // API名称
	Path        string `json:"path"`        // API路径
	Method      int    `json:"method"`      // HTTP请求方法(1:GET,2:POST,3:PUT,4:DELETE)
	Description string `json:"description"` // API描述
	Version     string `json:"version"`     // API版本
	Category    int    `json:"category"`    // API分类(1:系统,2:业务)
	IsPublic    int    `json:"is_public"`   // 是否公开(0:否,1:是)
	CreateTime  int64  `json:"create_time"` // 创建时间
	UpdateTime  int64  `json:"update_time"` // 更新时间
	IsDeleted   int    `json:"is_deleted"`  // 是否删除(0:否,1:是)
}

Api API接口

type AsyncSms

type AsyncSms struct {
	Id       int64
	TplId    string
	Args     []string
	Numbers  []string
	RetryMax int
}

type Check

type Check struct {
	ID        int64  // 审核ID
	PostID    uint   // 帖子ID
	Content   string // 审核内容
	Title     string // 审核标签
	Uid       int64  // 提交审核的用户ID
	PlateID   int64  // 板块id
	Status    uint8  // 审核状态
	Remark    string // 审核备注
	CreatedAt int64  // 创建时间
	UpdatedAt int64  // 更新时间
	BizId     int64  // 审核类型(帖子或者评论)
}

type Comment

type Comment struct {
	Id            int64
	UserId        int64
	Biz           string
	BizId         int64
	PostId        int64
	Content       string
	RootComment   *Comment  // 根节点
	ParentComment *Comment  // 父节点
	Children      []Comment // 子节点
	CreatedAt     int64
	UpdatedAt     int64
	Status        uint8 // 评论的审核状态
}

type CommentSearch

type CommentSearch struct {
	Id       uint   // 评论ID
	AuthorId int64  // 评论者ID
	Status   uint8  // 评论状态
	Content  string // 评论内容
}

type History

type History struct {
	PostID  uint
	Title   string
	Content string
	Uid     int64
	Tags    string
}

type Interactive

type Interactive struct {
	BizID        uint  `json:"biz_id"`
	ReadCount    int64 `json:"read_count"`
	LikeCount    int64 `json:"like_count"`
	CollectCount int64 `json:"collect_count"`
	Liked        bool  `json:"liked"`
	Collected    bool  `json:"collected"`
}

func (*Interactive) IncrementCollectCount

func (i *Interactive) IncrementCollectCount()

func (*Interactive) IncrementLikeCount

func (i *Interactive) IncrementLikeCount()

func (*Interactive) IncrementReadCount

func (i *Interactive) IncrementReadCount()

type Job

type Job struct {
	Id         int64  // 任务的唯一标识符
	Name       string // 任务名称
	Expression string // Cron 表达式,用于定义任务的调度时间
	Executor   string // 执行任务的执行器名称
	Cfg        string // 任务配置,可以是任意字符串
	CancelFunc func() // 用于取消任务的函数
}

func (*Job) NextTime

func (j *Job) NextTime() (time.Time, error)

NextTime 计算任务的下次执行时间

type LotteryDraw

type LotteryDraw struct {
	ID           int           // 抽奖活动的唯一标识符
	Name         string        // 抽奖活动名称
	Description  string        // 抽奖活动描述
	StartTime    int64         // UNIX 时间戳,表示活动开始时间
	EndTime      int64         // UNIX 时间戳,表示活动结束时间
	Status       string        // 抽奖活动状态
	Participants []Participant // 参与者列表
}

LotteryDraw 表示一个抽奖活动

type Menu struct {
	ID         int     `json:"id"`          // 菜单ID
	Name       string  `json:"name"`        // 菜单显示名称
	ParentID   int     `json:"parent_id"`   // 上级菜单ID,0表示顶级菜单
	Path       string  `json:"path"`        // 前端路由访问路径
	Component  string  `json:"component"`   // 前端组件文件路径
	Icon       string  `json:"icon"`        // 菜单显示图标
	SortOrder  int     `json:"sort_order"`  // 菜单显示顺序,数值越小越靠前
	RouteName  string  `json:"route_name"`  // 前端路由名称,需唯一
	Hidden     int     `json:"hidden"`      // 菜单是否隐藏(0:显示 1:隐藏)
	CreateTime int64   `json:"create_time"` // 记录创建时间戳
	UpdateTime int64   `json:"update_time"` // 记录最后更新时间戳
	IsDeleted  int     `json:"is_deleted"`  // 逻辑删除标记(0:未删除 1:已删除)
	Children   []*Menu `json:"children"`    // 子菜单列表
}

Menu 菜单

type Pagination

type Pagination struct {
	Page int    // 当前页码
	Size *int64 // 每页数据
	Uid  int64
	// 以下字段通常在服务端内部使用,不需要客户端传递
	Offset *int64 // 数据偏移量
	Total  *int64 // 总数据量
}

type Participant

type Participant struct {
	ID             string // 参与记录的唯一标识符
	LotteryID      *int   // 关联的活动ID(可以是抽奖或秒杀活动)
	SecondKillID   *int
	ActivityType   string
	UserID         int64 // 参与者的用户ID
	ParticipatedAt int64 // UNIX 时间戳,表示参与时间
}

Participant 表示参与者的记录,适用于抽奖和秒杀活动

type Plate

type Plate struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Uid         int64  `json:"uid"`
	CreatedAt   int64  `json:"created_at"`
	UpdatedAt   int64  `json:"updated_at"`
	DeletedAt   int64  `json:"deleted_at"`
	Deleted     bool   `json:"deleted"`
}

type Post

type Post struct {
	ID           uint         `json:"id"`
	Title        string       `json:"title"`
	Content      string       `json:"content"`
	CreatedAt    time.Time    `json:"created_at"`
	UpdatedAt    time.Time    `json:"updated_at"`
	DeletedAt    sql.NullTime `json:"deleted_at"`
	ReadCount    int64        `json:"read_count"`
	LikeCount    int64        `json:"like_count"`
	CollectCount int64        `json:"collect_count"`
	Uid          int64        `json:"uid"`
	Status       uint8        `json:"status"`
	PlateID      int64        `json:"plate_id"`
	Slug         string       `json:"slug"`
	CategoryID   int64        `json:"category_id"`
	Tags         string       `json:"tags"`
	CommentCount int64        `json:"comment_count"`
	IsSubmit     bool         `json:"is_submit"`
	Total        int64        `json:"total"`
}

func (*Post) Abstract

func (p *Post) Abstract() string

type PostSearch

type PostSearch struct {
	Id       uint
	Title    string
	AuthorId int64
	Status   uint8
	Content  string
	Tags     string
}

type Profile

type Profile struct {
	ID       int64   `json:"id"`       // 资料ID,主键
	UserID   int64   `json:"userId"`   // 用户ID,外键,关联到用户
	RealName string  `json:"realName"` // 真实姓名
	Avatar   string  `json:"avatar"`   // 头像URL
	Email    string  `json:"email"`    // 邮箱
	About    string  `json:"about"`    // 个人简介
	Birthday string  `json:"birthday"` // 生日
	Phone    *string `json:"phone"`    // 手机号码,指针类型,允许为空
}

type RankingParameter

type RankingParameter struct {
	ID     uint
	Alpha  float64 `json:"alpha"`  // 点赞权重
	Beta   float64 `json:"beta"`   // 收藏权重
	Gamma  float64 `json:"gamma"`  // 阅读权重
	Lambda float64 `json:"lambda"` // 时间权重
}

type ReadEvent

type ReadEvent struct {
	Timestamp int64  `json:"timestamp"`
	Level     string `json:"level"`
	Message   string `json:"message"`
}

type RecentActivity

type RecentActivity struct {
	ID          int64
	UserID      int64
	Description string
	Time        string
}

type Relation

type Relation struct {
	FolloweeId int64
	FollowerId int64
}

type RelationStats

type RelationStats struct {
	FollowerCount int64
	FolloweeCount int64
}

type Role

type Role struct {
	ID          int     `json:"id"`          // 主键ID
	Name        string  `json:"name"`        // 角色名称
	Description string  `json:"description"` // 角色描述
	RoleType    int     `json:"role_type"`   // 角色类型(1:系统角色,2:自定义角色)
	IsDefault   int     `json:"is_default"`  // 是否为默认角色(0:否,1:是)
	CreateTime  int64   `json:"create_time"` // 创建时间
	UpdateTime  int64   `json:"update_time"` // 更新时间
	IsDeleted   int     `json:"is_deleted"`  // 是否删除(0:否,1:是)
	Menus       []*Menu `json:"menus"`       // 菜单列表
	Apis        []*Api  `json:"apis"`        // API列表
}

Role 角色

type SecondKillEvent

type SecondKillEvent struct {
	ID           int           // 秒杀活动的唯一标识符
	Name         string        // 秒杀活动名称
	Description  string        // 秒杀活动描述
	StartTime    int64         // UNIX 时间戳,表示活动开始时间
	EndTime      int64         // UNIX 时间戳,表示活动结束时间
	Status       string        // 秒杀活动状态
	Participants []Participant // 参与者列表
}

SecondKillEvent 表示一个秒杀活动

type User

type User struct {
	ID          int64   `json:"id"`          // 用户ID,主键
	Username    string  `json:"username"`    // 用户名,唯一
	Password    string  `json:"password"`    // 密码
	CreateTime  int64   `json:"createTime"`  // 创建时间,Unix时间戳
	UpdatedTime int64   `json:"updatedTime"` // 更新时间,Unix时间戳
	Deleted     bool    `json:"deleted"`     // 删除标志,表示该用户是否被删除
	Profile     Profile `json:"profile"`     // 用户的详细资料
	Roles       []int   `json:"roles"`
}

func (*User) HashPassword

func (u *User) HashPassword() error

HashPassword 对密码进行哈希处理

func (*User) MarkAsDeleted

func (u *User) MarkAsDeleted()

MarkAsDeleted 标记用户为已删除

func (*User) UpdateProfile

func (u *User) UpdateProfile(newProfile Profile)

UpdateProfile 更新用户资料

func (*User) ValidatePassword

func (u *User) ValidatePassword() error

ValidatePassword 验证密码格式

func (*User) ValidateUsername

func (u *User) ValidateUsername() error

ValidateUsername 验证用户名格式

func (*User) VerifyPassword

func (u *User) VerifyPassword(password string) error

VerifyPassword 验证密码是否匹配

type UserSearch

type UserSearch struct {
	Id       int64
	Nickname string
	Birthday time.Time
	Email    string
	Phone    string
	About    string
}

type UserWithProfile

type UserWithProfile struct {
	ID           int64    `json:"id"`
	Username     string   `json:"username"`
	PasswordHash string   `json:"passwordHash"`
	Deleted      bool     `json:"deleted"`
	Phone        *string  `json:"phone"`
	Email        string   `json:"email"`
	ProfileID    int64    `json:"profileId"`
	UserID       int64    `json:"userId"`
	RealName     string   `json:"realName"`
	Avatar       string   `json:"avatar"`
	About        string   `json:"about"`
	Birthday     string   `json:"birthday"`
	Roles        []string `json:"roles"`
}

Directories

Path Synopsis
es
sms

Jump to

Keyboard shortcuts

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