models

package
v0.0.1-Beta01 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package models - NekoBlog backend server database models This file is for comment related models. Copyright (c) [2024], Author(s): - WhitePaper233<[email protected]>

Package models - NekoBlog backend server models migration. This file is for database migration function. Copyright (c) [2024], Author(s): - WhitePaper233<[email protected]>

Package models - NekoBlog backend server database models This file is for post related models. Copyright (c) [2024], Author(s): - WhitePaper233<[email protected]>

Package models - NekoBlog backend server database models This file is for user related models. Copyright (c) [2024], Author(s): - WhitePaper233<[email protected]>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB) error

Migrate 数据库迁移

参数:

  • db *gorm.DB 数据库连接

返回值:

  • error 错误

Types

type CachedPostImage

type CachedPostImage struct {
	gorm.Model        // 基本模型
	FileName   string `gorm:"column:file_name"`   // 文件名
	ExpireTime int64  `gorm:"column:expire_time"` // 过期时间
}

type CommentInfo

type CommentInfo struct {
	gorm.Model               // 基本模型
	PostID     uint64        `gorm:"column:post_id"`                // 博文ID
	UID        uint64        `gorm:"column:uid"`                    // 用户ID
	Username   string        `gorm:"column:username"`               // 用户名
	Content    string        `gorm:"column:content"`                // 内容
	Like       pq.Int64Array `gorm:"column:like;type:bigint[]"`     // 点赞数 记录UID
	Dislike    pq.Int64Array `gorm:"column:dislike;type:bigint[]"`  // 踩数 记录UID
	IsPublic   bool          `gorm:"column:is_public;default:true"` // 是否公开

}

CommentInfo 评论信息模型

type DeletedAvatar

type DeletedAvatar struct {
	gorm.Model        // 基本模型
	FileName   string `gorm:"column:file_name"` // 文件名
}

DeletedAvatar 头像删除等待列表

type DeletedCachedImage

type DeletedCachedImage struct {
	gorm.Model        // 基本模型
	FileName   string `gorm:"column:file_name"` // 文件名
}

type PostInfo

type PostInfo struct {
	gorm.Model                  // 基本模型
	ParentPostID *uint64        `gorm:"column:parent_post_id"`          // 转发自文章ID
	UID          uint64         `gorm:"column:uid"`                     // 用户ID
	IpAddrress   *string        `gorm:"column:ip_address"`              // IP地址
	Title        string         `gorm:"column:title"`                   // 标题
	Content      string         `gorm:"column:content"`                 // 内容
	Images       pq.StringArray `gorm:"column:images;type:text[]"`      // 图片
	Like         pq.Int64Array  `gorm:"column:like;type:bigint[]"`      // 点赞数 记录UID
	Favourite    pq.Int64Array  `gorm:"column:favourite;type:bigint[]"` // 收藏数 记录UID
	Farward      pq.Int64Array  `gorm:"column:farward;type:bigint[]"`   // 转发数 记录UID
	IsPublic     bool           `gorm:"column:is_public;default:true"`  // 是否公开

}

PostInfo 博文信息模型

type UserAuthInfo

type UserAuthInfo struct {
	gorm.Model          // 基本模型
	UID          uint64 `gorm:"unique;column:uid"`      // 用户ID
	UserName     string `gorm:"unique;column:username"` // 用户名
	Salt         string `gorm:"column:salt"`            // 盐
	PasswordHash string `gorm:"column:psw_hash"`        // 密码哈希值
}

UserAuthInfo 用户认证信息模型

type UserAvaliableToken

type UserAvaliableToken struct {
	gorm.Model           // 基本模型
	UID        uint64    `gorm:"column:uid"`          // 用户ID
	Username   string    `gorm:"column:username"`     // 用户名
	Token      string    `gorm:"unique;column:token"` // Token
	ExpireTime time.Time `gorm:"column:expire_time"`  // 过期时间
}

UserAvaliableToken 用户可用Token模型

type UserDislikeRecord

type UserDislikeRecord struct {
	gorm.Model
	UID            uint64        `gorm:"column:uid"`                           // 用户ID
	DislikeComment pq.Int64Array `gorm:"column:dislike_comment;type:bigint[]"` // 点踩过的评论
	DislikeReply   pq.Int64Array `gorm:"column:dislike_reply;type:bigint[]"`   // 点踩过的回复
}

UserDislikeRecord 用户点踩记录

type UserFavouriteRecord

type UserFavouriteRecord struct {
	gorm.Model
	UID       uint64        `gorm:"column:uid"`                     // 用户ID
	Favourite pq.Int64Array `gorm:"column:favourite;type:bigint[]"` // 收藏过的博文
}

UserFavouriteRecord 用户收藏记录

type UserInfo

type UserInfo struct {
	gorm.Model            // 基本模型
	UserName   string     `gorm:"unique;column:username"`             // 用户名
	NickName   *string    `gorm:"column:nickname"`                    // 昵称
	Avatar     string     `gorm:"default:vanilla.webp;column:avatar"` // 头像
	Birth      *time.Time `gorm:"column:birth"`                       // 生日
	Gender     *string    `gorm:"column:gender"`                      // 性别
	Authority  uint64     `gorm:"default:0;column:authority"`         // 权限等级
	Level      uint64     `gorm:"default:1;column:level"`             // 等级
}

UserInfo 用户信息模型

type UserLikedRecord

type UserLikedRecord struct {
	gorm.Model
	UID          uint64        `gorm:"column:uid"`                         // 用户ID
	LikedPost    pq.Int64Array `gorm:"column:liked_post;type:bigint[]"`    // 点赞过的博文
	LikedComment pq.Int64Array `gorm:"column:liked_comment;type:bigint[]"` // 点赞过的评论
	LikedReply   pq.Int64Array `gorm:"column:liked_reply;type:bigint[]"`   // 点赞过的回复
}

UserLikedRecord 用户点赞记录

type UserLoginLog

type UserLoginLog struct {
	gorm.Model            // 基本模型
	UID         uint64    `gorm:"column:uid"`                         // 用户ID
	LoginTime   time.Time `gorm:"column:login_time"`                  // 登录时间
	LoginIP     string    `gorm:"column:login_ip"`                    // 登录IP
	IsSucceed   bool      `gorm:"column:is_succeed"`                  // 登录是否成功
	IfChecked   bool      `gorm:"default:false;column:if_checked"`    // 是否已经以被发送到客户端
	Reason      string    `gorm:"column:reason"`                      // 原因
	Device      string    `gorm:"default:unknown;column:device"`      // 登录时登陆的设备 如:Windows iOS Android
	Application string    `gorm:"default:unknown;column:application"` // 登录时使用的应用 如 Chrome 236.12
	BearerToken string    `gorm:"column:bearer_token"`                // 此次登录获取到的令牌
}

UserLoginLog 用户登录日志模型

Jump to

Keyboard shortcuts

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