Documentation ¶
Index ¶
- type Auth
- type AuthAccountCreateReq
- type AuthAccountLoginReq
- type AuthAccountLoginRes
- type AuthAccountLoginSuccess
- type AuthListRes
- type AuthRes
- type Base
- type BulkDelete
- type BulkUpdate
- type Group
- type GroupListRes
- type GroupRes
- type HTTPBulkSuccess
- type HTTPDeleteSuccess
- type HTTPError
- type HTTPSuccess
- type Menu
- type MenuListRes
- type MenuRes
- type PaginReq
- type PaginRes
- type ReqInfo
- type Role
- type RoleListRes
- type RoleRes
- type UploadMultiSuccess
- type UploadRes
- type UploadSuccess
- type User
- type UserCurrent
- type UserGroup
- type UserGroupListRes
- type UserGroupRes
- type UserJWT
- type UserListRes
- type UserRes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct { Base UserID uuid.UUID `json:"userId" gorm:"column:user_id;not null"` // 用户ID User *User `json:"user" gorm:"foreignkey:UserID"` // 用户 AuthType string `json:"authType" gorm:"column:auth_type;type:VARCHAR(16);not null"` // 鉴权类型 AuthName string `json:"authName" gorm:"column:auth_name;type:VARCHAR(128);not null"` // 鉴权名称 AuthCode *string `json:"authCode" gorm:"column:auth_code" binding:"omitempty"` // 鉴权识别码 VerifyTime *time.Time `json:"verifyTime" gorm:"column:verify_time;type:DATETIME" binding:"omitempty"` // 认证时间 ExpireTime *time.Time `json:"expireTime" gorm:"column:expire_time;type:DATETIME" binding:"omitempty"` // 过期时间 IsEnabled bool `json:"isEnabled" gorm:"column:is_enabled;default:true" binding:"omitempty"` // 是否启用 }
Auth 定义模型
type AuthAccountCreateReq ¶
type AuthAccountCreateReq struct { Username string `form:"username" binding:"required"` // 帐号 Password string `form:"password" binding:"required"` // 密码 }
AuthAccountCreateReq 创建帐号
type AuthAccountLoginReq ¶
type AuthAccountLoginReq struct { Username string `json:"username" form:"username" binding:"required" example:"gabe"` // 用户名 Password string `json:"password" form:"password" binding:"required" example:"123456"` // 密码 }
AuthAccountLoginReq 帐号登录表单
type AuthAccountLoginRes ¶
type AuthAccountLoginRes struct { TokenType string `json:"tokenType" binding:"required"` // token类型 AccessToken string `json:"accessToken" binding:"required"` // token ExpiresIn int64 `json:"expiresIn" binding:"required"` // 过期时间(毫秒) }
AuthAccountLoginRes 登录成功返回数据
type AuthAccountLoginSuccess ¶
type AuthAccountLoginSuccess struct { HTTPSuccess Data AuthAccountLoginRes `json:"data" binding:"required"` }
AuthAccountLoginSuccess 登录成功
type AuthListRes ¶
type AuthListRes struct { HTTPSuccess Pagin PaginRes `json:"pagin" binding:"required"` Data []Auth `json:"data" binding:"required"` }
AuthListRes 返回列表
type AuthRes ¶
type AuthRes struct { HTTPSuccess Data Auth `json:"data" binding:"required"` }
AuthRes 返回单个
type Base ¶
type Base struct { ID uuid.UUID `json:"id" gorm:"column:id;primary_key;not null"` // ID CreatedAt time.Time `json:"createdAt" gorm:"column:created_at;not null"` // 创建时间 UpdatedAt time.Time `json:"updatedAt" gorm:"column:update_at;not null"` // 更新时间 DeletedAt *time.Time `json:"-" sql:"index" gorm:"column:deleted_at" binding:"omitempty"` // 软删除时间 }
Base 给所有模型共用
func (*Base) BeforeCreate ¶
BeforeCreate 在创建前给ID赋值一个UUID
type BulkDelete ¶
BulkDelete 批量删除
type BulkUpdate ¶
type BulkUpdate struct { IDs []uuid.UUID `form:"ids" json:"ids" binding:"required"` Obj map[string]interface{} `form:"obj" json:"obj" binding:"required"` }
BulkUpdate 批量更新
type Group ¶
type Group struct { Base Name string `json:"name" gorm:"column:name;type:VARCHAR(32);not null" binding:"min=3,max=20"` // 组名称 LeaderID uuid.UUID `json:"leaderId" gorm:"column:leader_id;not null"` // 队长ID Leader *User `json:"leader" gorm:"foreignkey:LeaderID"` // 队长 Members []*UserGroup `json:"members" gorm:"foreignkey:GroupID"` // 成员 }
Group 定义模型
type GroupListRes ¶
type GroupListRes struct { HTTPSuccess Pagin PaginRes `json:"pagin" binding:"required"` Data []Group `json:"data" binding:"required"` }
GroupListRes 返回列表
type GroupRes ¶
type GroupRes struct { HTTPSuccess Data Group `json:"data" binding:"required"` }
GroupRes 返回单个
type HTTPBulkSuccess ¶
type HTTPBulkSuccess struct { Code int `json:"code" binding:"required"` // 状态码 Message string `json:"message" binding:"required"` // 提示 Data []uuid.UUID `json:"data"` // 返回数据 }
HTTPBulkSuccess 成功
type HTTPDeleteSuccess ¶
type HTTPDeleteSuccess struct { Code int `json:"code" binding:"required"` // 状态码 Message string `json:"message" binding:"required"` // 提示 Data uuid.UUID `json:"data"` // 返回数据 }
HTTPDeleteSuccess 成功
type HTTPError ¶
type HTTPError struct { Code int `json:"code" binding:"required"` // 状态码 Message string `json:"message" binding:"required"` // 提示 Errors []string `json:"errors"` // 详细错误信息 }
HTTPError 错误
type HTTPSuccess ¶
type HTTPSuccess struct { Code int `json:"code" binding:"required"` // 状态码 Message string `json:"message" binding:"required"` // 提示 Data interface{} `json:"data"` // 返回数据 }
HTTPSuccess 成功
type Menu ¶
type Menu struct { Base ParentID uuid.UUID `json:"parentId" gorm:"column:parent_id" binding:"omitempty"` // 父ID Parent *Menu `json:"parent" gorm:"foreignkey:ParentID"` // 父菜单 Children []*Menu `json:"children" gorm:"foreignkey:ParentID"` // 子菜单 Name string `json:"name" gorm:"column:name;not null"` // 菜单名称 Path string `json:"path" gorm:"column:path;not null"` // 菜单路径 Icon *string `json:"icon" gorm:"column:icon" binding:"omitempty"` // 菜单图标 Sort *int `json:"sort" gorm:"column:sort" binding:"omitempty"` // 排序 Roles []*Role `json:"roles" gorm:"many2many:rolemenu;"` // 角色 }
Menu 定义模型
func (Menu) GetUniqueIndex ¶
GetUniqueIndex 实现 IFUniqueItem 接口
type MenuListRes ¶
type MenuListRes struct { HTTPSuccess Pagin PaginRes `json:"pagin" binding:"required"` Data []Menu `json:"data" binding:"required"` }
MenuListRes 返回列表
type MenuRes ¶
type MenuRes struct { HTTPSuccess Data Menu `json:"data" binding:"required"` }
MenuRes 返回单个
type PaginReq ¶
type PaginReq struct { Page uint `form:"page,default=1"` // 页码 Size uint `form:"size,default=10"` // 每页数量 Sort string `form:"sort,default=created_at desc"` // 排序 }
PaginReq 分页查询参数
type PaginRes ¶
type PaginRes struct { Page uint `json:"page" binding:"required"` // 页码 Size uint `json:"size" binding:"required"` // 每页数量 Total uint `json:"total" binding:"required"` // 总数 }
PaginRes 分页查询结果
type Role ¶
type Role struct { Base Name string `json:"name" gorm:"column:name;type:VARCHAR(32);unique;not null" binding:"min=3,max=20"` // 角色名称 Users []*User `json:"users" gorm:"many2many:userrole;"` // 用户 Menus []*Menu `json:"menus" gorm:"many2many:rolemenu;"` // 菜单 }
Role 定义模型
type RoleListRes ¶
type RoleListRes struct { HTTPSuccess Pagin PaginRes `json:"pagin" binding:"required"` Data []Role `json:"data" binding:"required"` }
RoleListRes 角色列表
type RoleRes ¶
type RoleRes struct { HTTPSuccess Data Role `json:"data" binding:"required"` }
RoleRes 返回单个
type UploadMultiSuccess ¶
type UploadMultiSuccess struct { HTTPSuccess Data []UploadRes `json:"data" binding:"required"` }
UploadMultiSuccess 上传多文件
type UploadRes ¶
type UploadRes struct { Origin string `json:"origin" binding:"required"` // 原始文件名 Type string `json:"type" binding:"required"` // 文件类型 URL string `json:"url" binding:"required"` // 文件全路径 Thumb string `json:"thumb" binding:"required"` // 图片缩略图 Isnew bool `json:"isnew" binding:"required"` // 是否新文件 }
UploadRes 上传文件
type UploadSuccess ¶
type UploadSuccess struct { HTTPSuccess Data UploadRes `json:"data" binding:"required"` }
UploadSuccess 上传单文件
type User ¶
type User struct { Base Name *string `json:"name" gorm:"column:name;type:VARCHAR(32)" binding:"min=3,max=20"` // 姓名 Nickname string `json:"nickname" gorm:"column:nickname;not null"` // 昵称 Gender *int `json:"gender" gorm:"column:gender;type:TINYINT;default:0" binding:"omitempty,eq=0|eq=1|eq=2"` // 性别 Avatar *string `json:"avatar" gorm:"column:avatar" binding:"omitempty"` // 昵称 Mobile *string `json:"mobile" gorm:"column:mobile;type:VARCHAR(16)" binding:"omitempty"` // 手机 Email *string `json:"email" gorm:"column:email;unique" binding:"omitempty,email"` // 邮箱 Homepage *string `json:"homepage" gorm:"column:homepage" binding:"omitempty,url"` // 个人主页 Birthday *time.Time `json:"birthday" gorm:"column:birthday;type:DATE" binding:"omitempty"` // 生日 Height *float32 `json:"height" gorm:"column:height;type:FLOAT" binding:"omitempty,min=0.01,max=300"` // 身高(cm) BloodType *string `json:"bloodType" gorm:"column:blood_type;type:VARCHAR(8)" binding:"omitempty,eq=A|eq=B|eq=AB|eq=O|eq=NULL"` // 血型(ABO) Notice *string `json:"notice" gorm:"column:notice;type:TEXT" binding:"omitempty"` // 备注 Intro *string `json:"intro" gorm:"column:intro;type:TEXT" binding:"omitempty"` // 简介 Address *string `json:"address" gorm:"column:address;type:JSON" binding:"omitempty"` // 地址 Lives *string `json:"lives" gorm:"column:lives;type:JSON" binding:"omitempty"` // 生活轨迹 Tags *string `json:"tags" gorm:"column:tags;type:JSON" binding:"omitempty"` // 标签 LuckyNumbers *string `json:"luckyNumbers" gorm:"column:lucky_numbers;type:JSON" binding:"omitempty"` // 幸运数字 Score *int `json:"score" gorm:"column:score;default:0" binding:"omitempty"` // 积分 UserNo int `json:"userNo" gorm:"column:user_no;AUTO_INCREMENT"` // 编号 Auths []*Auth `json:"auths" gorm:"foreignkey:UserID"` // 帐号 Groups []*UserGroup `json:"groups" gorm:"foreignkey:UserID"` // 用户组 Roles []*Role `json:"roles" gorm:"many2many:userrole;"` // 角色 Friends []*User `json:"friends" gorm:"many2many:userfriend;association_jointable_foreignkey:user_id;jointable_foreignkey:friend_id;"` // 友 }
User 用户模型
type UserCurrent ¶
type UserCurrent struct { IssuedAt int64 `json:"iss" binding:"required"` AuthID string `json:"aid" binding:"required"` UserID string `json:"uid" binding:"required"` Roles []string `json:"roles" binding:"required"` }
UserCurrent JWT用户数据
type UserGroup ¶
type UserGroup struct { Base UserID uuid.UUID `json:"userId" gorm:"column:user_id;not null"` // 用户ID User *User `json:"user" gorm:"foreignkey:UserID"` // 用户 GroupID uuid.UUID `json:"groupId" gorm:"column:group_id;not null"` // 组ID Group *Group `json:"group" gorm:"foreignkey:GroupID"` // 组 Level *int `json:"level" gorm:"column:level;type:TINYINT;default:0" binding:"omitempty"` // 级别 JoinTime *time.Time `json:"joinTime" gorm:"column:join_time;type:DATETIME" binding:"omitempty"` // 加入时间 }
UserGroup 定义模型
type UserGroupListRes ¶
type UserGroupListRes struct { HTTPSuccess Pagin PaginRes `json:"pagin" binding:"required"` Data []UserGroup `json:"data" binding:"required"` }
UserGroupListRes 返回列表
type UserGroupRes ¶
type UserGroupRes struct { HTTPSuccess Data UserGroup `json:"data" binding:"required"` }
UserGroupRes 返回单个
type UserJWT ¶
type UserJWT struct { AuthID string `json:"aid" binding:"required"` UserID string `json:"uid" binding:"required"` }
UserJWT JWT用户数据
type UserListRes ¶
type UserListRes struct { HTTPSuccess Pagin PaginRes `json:"pagin" binding:"required"` Data []User `json:"data" binding:"required"` }
UserListRes 返回列表
type UserRes ¶
type UserRes struct { HTTPSuccess Data User `json:"data" binding:"required"` }
UserRes 返回单个