model

package
v0.0.0-...-ff8c6a7 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OK

func OK[T any](c *gin.Context, data T)

OK 成功

func OKWithMsg

func OKWithMsg[T any](c *gin.Context, data T, msg string)

func Throw

func Throw(c *gin.Context, errCode errhandle.ErrCode)

Throw 已知的定义错误

func ThrowBindError

func ThrowBindError(c *gin.Context, obj any, err error)

ThrowBindError 数据绑定错误

func ThrowError

func ThrowError(c *gin.Context, err error)

ThrowError 服务器内部错误

Types

type Article

type Article struct {
	ID           int64     `json:"id,omitempty"`
	Title        string    `json:"title,omitempty"`
	Content      string    `gorm:"type:text" json:"content,omitempty"`
	LookCount    uint      `json:"look_count,omitempty"`    //浏览量
	CommentCount uint      `json:"comment_count,omitempty"` //评论数
	LikeCount    uint      `json:"like_count,omitempty"`    //点赞数
	User         User      `gorm:"foreignKey:UserID" json:"-,omitempty"`
	UserID       int64     `json:"user_id,omitempty"`
	Comments     []Comment `gorm:"foreignKey:ArticleID" json:"comments,omitempty"`
	Tags         []Tag     `gorm:"many2many:article_tags" json:"tags,omitempty"`
	CategoryID   int64     `json:"category_id,omitempty"`
	Image        Image     `gorm:"foreignKey:ImageID" json:"image,omitempty"` //文章的封面
	ImageID      int64     `json:"image_id,omitempty"`
	CreatedAt    time.Time `gorm:"column:createdAt" json:"created_at,omitempty"`
	UpdatedAt    time.Time `gorm:"column:updatedAt" json:"Updated_at,omitempty"`
}

type Category

type Category struct {
	ID        int64     `json:"id,omitempty"`
	Name      string    `gorm:"unique" json:"name,omitempty"`
	Articles  []Article `gorm:"foreignKey:CategoryID" json:"articles,omitempty"`
	CreatedAt time.Time `gorm:"column:createdAt" json:"created_at,omitempty"`
	UpdatedAt time.Time `gorm:"column:updatedAt" json:"Updated_at,omitempty"`
}

type Comment

type Comment struct {
	ID        int64     `json:"id,omitempty"`
	Content   string    `gorm:"type:text" json:"content,omitempty"`
	ArticleID uint      `json:"article_id,omitempty"`
	UserID    int64     `json:"user_id,omitempty"`
	User      User      `json:"user,omitempty"`
	CreatedAt time.Time `gorm:"column:createdAt" json:"created_at,omitempty"`
	UpdatedAt time.Time `gorm:"column:updatedAt" json:"Updated_at,omitempty"`
}

type CommonResponse

type CommonResponse[T any] struct {
	Data   T                 `json:"data,omitempty"`
	Status errhandle.ErrCode `json:"status"`
	Reason string            `json:"reason,omitempty"`
	Msg    string            `json:"msg,omitempty"`
}

type DelIdListRequest

type DelIdListRequest struct {
	IdList []int64 `json:"id_list" binding:"required" msg:"请输入要删除的内容id列表"`
}

type GetUserResponse

type GetUserResponse struct {
	ID       int64  `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
	Email    string `json:"email,omitempty"`
	NickName string `gorm:"column:nickName" json:"nickName,omitempty"`
	Sex      string `json:"sex,omitempty"`
	Avatar   string `json:"avatar,omitempty"`
	IP       string `json:"ip,omitempty"`
	Role     string `json:"role,omitempty"`
}

type Image

type Image struct {
	ID             int64                `json:"id,omitempty"`
	URL            string               `json:"url,omitempty"`
	Hash           string               `json:"hash,omitempty"` //判断图片是否重复
	Name           string               `json:"name,omitempty"`
	ImageStoreType ctype.ImageStoreType `gorm:"default:1" json:"image_store_type,omitempty"`
	CreatedAt      time.Time            `gorm:"column:createdAt" json:"created_at,omitempty"`
	UpdatedAt      time.Time            `gorm:"column:updatedAt" json:"Updated_at,omitempty"`
}

func (*Image) BeforeDelete

func (b *Image) BeforeDelete(tx *gorm.DB) (err error)

BeforeDelete 删除操作的钩子函数

type ImageResponse

type ImageResponse struct {
	FilePath     string `json:"file_path,omitempty"`
	IsSucceed    bool   `json:"is_succeed,omitempty"`
	UploadStatus string `json:"upload_status,omitempty"`
}

type ImageUpdateRequest

type ImageUpdateRequest struct {
	ID   uint   `json:"id" binding:"required" msg:"请选择图片id"` //必传
	Name string `json:"name" binding:"required" msg:"请输入图片名称"`
}

type LoginWithEmailRequest

type LoginWithEmailRequest struct {
	Email            string  `json:"email" binding:"required" msg:"邮箱非法"`
	VerificationCode *string `json:"verificationCode,omitempty"`
}
type MenuItem struct {
	ID        int64      `gorm:"primaryKey" json:"id,omitempty"`
	Title     string     `json:"title,omitempty"`                               // 菜单项标题
	URL       string     `json:"url,omitempty"`                                 // 菜单项链接
	ParentID  *int64     `json:"parent_id,omitempty"`                           // 父菜单项ID,用于构建多级菜单
	Children  []MenuItem `gorm:"foreignKey:ParentID" json:"children,omitempty"` // 子菜单项列表
	Sort      int        `json:"sort,omitempty"`                                //菜单的排序
	CreatedAt time.Time  `gorm:"column:createdAt" json:"created_at,omitempty"`
	UpdatedAt time.Time  `gorm:"column:updatedAt" json:"Updated_at,omitempty"`
}

MenuItem represents an item in the menu

type MenuRequest struct {
	Title    string `json:"title,omitempty" binding:"required" msg:"菜单标题"`
	URL      string `json:"url,omitempty" binding:"required" msg:"菜单url"`
	ParentID *int   `json:"parent_id,omitempty"`
	Sort     int    `json:"sort,omitempty" binding:"required" msg:"菜单的排序"`
}

菜单

type MenuUptateRequest struct {
	Title    string `json:"title,omitempty" binding:"required" msg:"菜单标题"`
	URL      string `json:"url,omitempty" binding:"required" msg:"菜单url"`
	ParentID *int   `json:"parent_id,omitempty"`
	Sort     int    `json:"sort,omitempty" binding:"required" msg:"菜单的排序"`
}

type ModifyPasswordRequest

type ModifyPasswordRequest struct {
	UserIDOnlyRequest
	OldPwd string `json:"old_pwd,omitempty"`
	NewPwb string `json:"new_pwb,omitempty"`
}

type ModifyUserRequest

type ModifyUserRequest struct {
	UserIDOnlyRequest
	Name     string `json:"name,omitempty"`
	NickName string `json:"nick_name,omitempty"`
	Sex      string `json:"sex,omitempty"`
	Avatar   string `json:"avatar,omitempty"`
	Email    string `json:"email,omitempty"`
}

type PageRequest

type PageRequest struct {
	Page  int    `form:"page" json:"page,omitempty"`   //页码
	Key   string `form:"key" json:"key,omitempty"`     //关键字
	Limit int    `form:"limit" json:"limit,omitempty"` //每页大小
	Sort  string `form:"sort" json:"sort,omitempty"`   //排序(升序/降序)
}

PageRequest 分页请求

type QueryRequest

type QueryRequest struct {
	UserID   int    `json:"id,omitempty"`
	Name     string `json:"name,omitempty"`
	Email    string `json:"email,omitempty"`
	NickName string `json:"nick_name,omitempty"`
}

用户

type RegisterUserRequest

type RegisterUserRequest struct {
	Name             string  `json:"name,omitempty"`
	Password         string  `json:"password,omitempty"`
	Email            string  `json:"email,omitempty"`
	NickName         string  `json:"nick_name,omitempty"`
	Sex              string  `json:"sex,omitempty"`
	Avatar           string  `json:"avatar,omitempty"`
	VerificationCode *string `json:"verificationCode"`
}

type ResetPasswordRequest

type ResetPasswordRequest struct {
	Email            string  `json:"email" binding:"required,email" msg:"请输入邮箱"`
	VerificationCode *string `json:"verificationCode,omitempty"`
	NewPassword      string  `json:"newPassword,omitempty"`
}

ResetPasswordRequest 绑定重置密码的请求数据

type Tag

type Tag struct {
	ID        int64     `json:"id,omitempty"`
	Name      string    `gorm:"unique" json:"name,omitempty"`
	Articles  []Article `gorm:"many2many:article_tags" json:"articles,omitempty"`
	CreatedAt time.Time `gorm:"column:createdAt" json:"created_at,omitempty"`
	UpdatedAt time.Time `gorm:"column:updatedAt" json:"Updated_at,omitempty"`
}

type TagRequest

type TagRequest struct {
	Name string `json:"Name,omitempty" binding:"required" msg:"请输入标签名"`
}

标签

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	Scope        string `json:"scope,omitempty"`
	ExpiredAt    int64  `json:"expiredAt,omitempty"`
}

type User

type User struct {
	ID       int64  `gorm:"column:id" json:"id,omitempty"`
	Name     string `gorm:"column:name" json:"name,omitempty"`
	Password string `gorm:"column:password" json:"password,omitempty"`
	Email    string `gorm:"column:email" json:"email,omitempty"`
	NickName string `gorm:"column:nickName" json:"nick_name,omitempty"`
	IP       string `gorm:"column:ip" json:"ip,omitempty"`

	Role            string    `gorm:"column:role" json:"role,omitempty"` //权限(管理员,普通用户)
	Sex             string    `gorm:"column:sex" json:"sex,omitempty"`
	Avatar          string    `gorm:"type:varchar(256);comment:头像" json:"avatar,omitempty"` //头像地址
	Articles        []Article `gorm:"foreignKey:UserID" json:"articles,omitempty"`
	CollectArticles []Article `gorm:"many2many:user_collect_articles" json:"collect_articles,omitempty"`
	CreatedAt       time.Time `gorm:"column:createdAt" json:"created_at,omitempty"`
	UpdatedAt       time.Time `gorm:"column:updatedAt" json:"Updated_at,omitempty"`
}

type UserIDOnlyRequest

type UserIDOnlyRequest struct {
	UserID int64 `json:"id"`
}

type UserInfo

type UserInfo struct {
	UserID int64  `json:"userid"`
	UUID   string `json:"uuid"`
	Name   string `json:"name"`
	Role   string `json:"role"`
}

type UserLoginRequest

type UserLoginRequest struct {
	Name     string `json:"name,omitempty" binding:"required" msg:"用户名"`
	Password string `json:"password,omitempty" binding:"required" msg:"密码"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳