model

package
v0.0.0-...-f53b5d5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const TimeFormat = "2006-01-02 15:04:05"

Variables

View Source
var (
	TokenExpired     = errors.New("Token is expired")
	TokenNotValidYet = errors.New("Token not active yet")
	TokenMalformed   = errors.New("That's not even a token")
	TokenInvalid     = errors.New("Couldn't handle this token:")
)

Functions

func Find

func Find(tx *gorm.DB) (data []map[string]interface{}, err error)

func GetUserAuthorityId

func GetUserAuthorityId(c *gin.Context) []int

func GetUserID

func GetUserID(c *gin.Context) int

func GetUserUuid

func GetUserUuid(c *gin.Context) uuid.UUID

func LoadAll

func LoadAll()

Types

type BaseClaims

type BaseClaims struct {
	UUID        uuid.UUID
	ID          int
	Username    string
	NickName    string
	AuthorityId []int
}

type Casbin

type Casbin struct{}

func (Casbin) Casbin

func (c Casbin) Casbin() *casbin.SyncedEnforcer

持久化到数据库 引入自定义规则

func (Casbin) ClearCasbin

func (c Casbin) ClearCasbin(v int, p ...string) bool

清除匹配的权限

func (Casbin) GetPolicyPathByAuthorityId

func (c Casbin) GetPolicyPathByAuthorityId(AuthorityID int) (pathMaps []CasbinInfo)

获取权限列表

func (Casbin) UpdateCasbin

func (c Casbin) UpdateCasbin(AuthorityID int, casbinInfos []CasbinInfo) error

更新 casbin 权限

func (Casbin) UpdateCasbinApi

func (c Casbin) UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod string) error

API更新随动

type CasbinInReceive

type CasbinInReceive struct {
	AuthorityId int          `json:"authorityId"` // 权限id
	CasbinInfos []CasbinInfo `json:"casbinInfos"`
}

Casbin structure for input parameters

type CasbinInfo

type CasbinInfo struct {
	Path   string `json:"path"`   // 路径
	Method string `json:"method"` // 方法
}

Casbin info structure

func DefaultCasbin

func DefaultCasbin() []CasbinInfo

type CustomClaims

type CustomClaims struct {
	BaseClaims
	BufferTime int64
	jwt.StandardClaims
}

Custom claims structure

func GetClaims

func GetClaims(c *gin.Context) (*CustomClaims, error)

func GetUserInfo

func GetUserInfo(c *gin.Context) *CustomClaims

type ExaFile

type ExaFile struct {
	MODEL
	FileName     string
	FileMd5      string
	FilePath     string
	ExaFileChunk []ExaFileChunk
	ChunkTotal   int
	IsFinish     bool
}

file struct, 文件结构体

type ExaFileChunk

type ExaFileChunk struct {
	MODEL
	ExaFileID       int
	FileChunkNumber int
	FileChunkPath   string
}

file chunk struct, 切片结构体

type Jwt

type Jwt struct {
	SigningKey []byte
}

func NewJWT

func NewJWT(signingKey string) *Jwt

func (*Jwt) CreateClaims

func (j *Jwt) CreateClaims(baseClaims BaseClaims) CustomClaims

func (*Jwt) CreateToken

func (j *Jwt) CreateToken(claims CustomClaims) (string, error)

func (*Jwt) CreateTokenByOldToken

func (j *Jwt) CreateTokenByOldToken(oldToken string, claims CustomClaims) (string, error)

func (*Jwt) GetRedisJWT

func (j *Jwt) GetRedisJWT(userName string) (redisJWT string, err error)

func (*Jwt) IsBlacklist

func (j *Jwt) IsBlacklist(jwt string) bool

判断 jwt 是否在黑名单内部

func (Jwt) JsonInBlacklist

func (j Jwt) JsonInBlacklist(jwtList SysJwtBlacklist) (err error)

拉黑 jwt

func (*Jwt) ParseToken

func (j *Jwt) ParseToken(tokenString string) (*CustomClaims, error)

解析 token

func (*Jwt) SetRedisJWT

func (j *Jwt) SetRedisJWT(jwt string, userName string) (err error)

type LocalTime

type LocalTime time.Time

func (LocalTime) Format

func (t LocalTime) Format(layout string) string

func (LocalTime) MarshalJSON

func (t LocalTime) MarshalJSON() ([]byte, error)

func (*LocalTime) Scan

func (t *LocalTime) Scan(v interface{}) error

func (*LocalTime) UnmarshalJSON

func (t *LocalTime) UnmarshalJSON(data []byte) (err error)

func (LocalTime) Value

func (t LocalTime) Value() (driver.Value, error)

type MODEL

type MODEL struct {
	ID        int            `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `json:"ct"`
	UpdatedAt time.Time      `json:"ut"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

type MODEX_EXTEND

type MODEX_EXTEND struct {
	Cb int `json:"-"` // 创建者
	Ub int `json:"-"` // 更新者
	Db int `json:"-"` // 删除者
}

type Meta

type Meta struct {
	ActiveName  string `json:"activeName" gorm:"comment:高亮菜单"`
	KeepAlive   bool   `json:"keepAlive" gorm:"comment:是否缓存"`           // 是否缓存
	DefaultMenu bool   `json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"` // 是否是基础路由(开发中)
	Title       string `json:"title" gorm:"comment:菜单名"`                // 菜单名
	Icon        string `json:"icon" gorm:"comment:菜单图标"`                // 菜单图标
	CloseTab    bool   `json:"closeTab" gorm:"comment:自动关闭tab"`         // 自动关闭tab
	SSRPath     string `json:"SSRPath" gorm:"ssr_path"`
}

type SysApi

type SysApi struct {
	MODEL
	Path        string `json:"path" gorm:"comment:api路径"`             // api路径
	Description string `json:"description" gorm:"comment:api中文描述"`    // api中文描述
	ApiGroup    string `json:"apiGroup" gorm:"comment:api组"`          // api组
	Method      string `json:"method" gorm:"default:POST;comment:方法"` // 方法:创建POST(默认)|查看GET|更新PUT|删除DELETE
	Sys         bool   `json:"sys" gorm:"-"`
}

func (SysApi) All

func (s SysApi) All() ([]SysApi, error)

func (*SysApi) Create

func (s *SysApi) Create() error

func (SysApi) Delete

func (s SysApi) Delete(ids []int) error

func (SysApi) GetAPIInfoList

func (s SysApi) GetAPIInfoList(api SysApi, info request.PageInfo, order string, desc bool) (list interface{}, total int64, err error)

func (SysApi) GetById

func (s SysApi) GetById(id int) (SysApi, error)

func (SysApi) IsExist

func (s SysApi) IsExist(path, method string) bool

func (SysApi) TableName

func (SysApi) TableName() string

func (*SysApi) Update

func (s *SysApi) Update() error

type SysAuthority

type SysAuthority struct {
	CreatedAt       time.Time       // 创建时间
	UpdatedAt       time.Time       // 更新时间
	DeletedAt       *time.Time      `sql:"index"`
	AuthorityId     int             `json:"authorityId" gorm:"not null;unique;primary_key;comment:角色ID;size:90"` // 角色ID
	AuthorityName   string          `json:"authorityName" gorm:"comment:角色名"`                                    // 角色名
	ParentId        *uint           `json:"parentId" gorm:"comment:父角色ID"`                                       // 父角色ID
	DataAuthorityId []*SysAuthority `json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id;"`
	Children        []SysAuthority  `json:"children" gorm:"-"`
	SysMenus        []SysMenu       `json:"menus" gorm:"many2many:sys_authority_menus;"`
	Users           []SysUser       `json:"-" gorm:"many2many:sys_user_authority;"`
	DefaultRouter   string          `json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"` // 默认菜单(默认dashboard)
}

func (SysAuthority) CopyAuthority

func (s SysAuthority) CopyAuthority(copyInfo SysAuthorityCopyResponse) (SysAuthority, error)

func (SysAuthority) CreateAuthority

func (s SysAuthority) CreateAuthority(auth SysAuthority) (SysAuthority, error)

func (SysAuthority) DeleteAuthority

func (s SysAuthority) DeleteAuthority(auth *SysAuthority) (err error)

func (SysAuthority) GetAuthorityInfoList

func (s SysAuthority) GetAuthorityInfoList(info request.PageInfo) (list interface{}, total int64, err error)

func (SysAuthority) SetDataAuthority

func (s SysAuthority) SetDataAuthority(auth SysAuthority) error

func (SysAuthority) SetMenuAuthority

func (s SysAuthority) SetMenuAuthority(auth *SysAuthority) error

func (SysAuthority) TableName

func (SysAuthority) TableName() string

func (SysAuthority) UpdateAuthority

func (s SysAuthority) UpdateAuthority(auth SysAuthority) (authority SysAuthority, err error)

type SysAuthorityCopyResponse

type SysAuthorityCopyResponse struct {
	Authority      SysAuthority `json:"authority"`
	OldAuthorityId int          `json:"oldAuthorityId"` // 旧角色ID
}

type SysAuthorityMenu

type SysAuthorityMenu struct {
	MenuId      int `json:"menuId" gorm:"comment:菜单ID;column:sys_menu_id"`
	AuthorityId int `json:"-" gorm:"comment:角色ID;column:sys_authority_authority_id"`
}

func (SysAuthorityMenu) GetMenuIdsByAuthorityIds

func (s SysAuthorityMenu) GetMenuIdsByAuthorityIds(ids []int) (menuIds []int)

func (SysAuthorityMenu) SaveAuthority

func (s SysAuthorityMenu) SaveAuthority(authorityId int, menus []SysMenu) error

func (SysAuthorityMenu) TableName

func (s SysAuthorityMenu) TableName() string

type SysFileUploadAndDownload

type SysFileUploadAndDownload struct {
	MODEL
	Name string `json:"name" gorm:"comment:文件名"` // 文件名
	Url  string `json:"url" gorm:"comment:文件地址"` // 文件地址
	Tag  string `json:"tag" gorm:"comment:文件标签"` // 文件标签
	Key  string `json:"key" gorm:"comment:编号"`   // 编号
}

func (SysFileUploadAndDownload) CreateFileChunk

func (s SysFileUploadAndDownload) CreateFileChunk(id int, fileChunkPath string, fileChunkNumber int) error

func (SysFileUploadAndDownload) DeleteFile

func (s SysFileUploadAndDownload) DeleteFile(file SysFileUploadAndDownload) (err error)

func (SysFileUploadAndDownload) DeleteFileChunk

func (s SysFileUploadAndDownload) DeleteFileChunk(fileMd5 string, filePath string) error

func (SysFileUploadAndDownload) EditFileName

func (s SysFileUploadAndDownload) EditFileName(file SysFileUploadAndDownload) (err error)

func (SysFileUploadAndDownload) FindFile

func (SysFileUploadAndDownload) FindOrCreateFile

func (s SysFileUploadAndDownload) FindOrCreateFile(fileMd5 string, fileName string, chunkTotal int) (file ExaFile, err error)

func (SysFileUploadAndDownload) GetFileRecordInfoList

func (s SysFileUploadAndDownload) GetFileRecordInfoList(info request.PageInfo) (list interface{}, total int64, err error)

func (SysFileUploadAndDownload) Upload

type SysJwtBlacklist

type SysJwtBlacklist struct {
	MODEL
	Jwt string `gorm:"type:text;comment:jwt"`
}

func (SysJwtBlacklist) IsBlack

func (s SysJwtBlacklist) IsBlack(jwt string) bool

type SysMenu

type SysMenu struct {
	MODEL
	AuthorityId   int                                        `json:"authorityId" gorm:"-"`
	MenuLevel     uint                                       `json:"-"`
	ParentId      int                                        `json:"parentId" gorm:"comment:父菜单ID"`     // 父菜单ID
	Path          string                                     `json:"path" gorm:"comment:路由path"`        // 路由path
	Name          string                                     `json:"name" gorm:"comment:路由name"`        // 路由name
	Hidden        bool                                       `json:"hidden" gorm:"comment:是否在列表隐藏"`     // 是否在列表隐藏
	Component     string                                     `json:"component" gorm:"comment:对应前端文件路径"` // 对应前端文件路径
	Sort          int                                        `json:"sort" gorm:"comment:排序标记"`          // 排序标记
	Children      []SysMenu                                  `json:"children" gorm:"-"`
	SysAuthoritys []SysAuthority                             `json:"authoritys" gorm:"many2many:sys_authority_menus;"`
	Meta          `json:"meta" gorm:"embedded;comment:附加属性"` // 附加属性
}

func (SysMenu) AddBaseMenu

func (s SysMenu) AddBaseMenu(menu SysMenu) error

func (SysMenu) DeleteBaseMenu

func (s SysMenu) DeleteBaseMenu(id int) (err error)

func (SysMenu) GetAllMenu

func (s SysMenu) GetAllMenu(tree, loadSystem bool) ([]SysMenu, error)

func (SysMenu) GetAllTreeMenuByAuthorityId

func (s SysMenu) GetAllTreeMenuByAuthorityId(authorityIds []int, tree bool) ([]SysMenu, error)

func (SysMenu) GetBaseMenuById

func (s SysMenu) GetBaseMenuById(id int) (menu SysMenu, err error)

func (SysMenu) GetMenuByUserId

func (s SysMenu) GetMenuByUserId(userId int, tree bool) ([]SysMenu, error)

func (SysMenu) TableName

func (SysMenu) TableName() string

func (SysMenu) UpdateBaseMenu

func (s SysMenu) UpdateBaseMenu(menu SysMenu) (err error)

type SysOperationRecord

type SysOperationRecord struct {
	MODEL
	Ip           string        `json:"ip" form:"ip" gorm:"column:ip;comment:请求ip"`                                   // 请求ip
	Method       string        `json:"method" form:"method" gorm:"column:method;comment:请求方法"`                       // 请求方法
	Path         string        `json:"path" form:"path" gorm:"column:path;comment:请求路径"`                             // 请求路径
	Status       int           `json:"status" form:"status" gorm:"column:status;comment:请求状态"`                       // 请求状态
	Latency      time.Duration `json:"latency" form:"latency" gorm:"column:latency;comment:延迟" swaggertype:"string"` // 延迟
	Agent        string        `json:"agent" form:"agent" gorm:"column:agent;comment:代理"`                            // 代理
	ErrorMessage string        `json:"error_message" form:"error_message" gorm:"column:error_message;comment:错误信息"`  // 错误信息
	Body         string        `json:"body" form:"body" gorm:"type:text;column:body;comment:请求Body"`                 // 请求Body
	Resp         string        `json:"resp" form:"resp" gorm:"type:text;column:resp;comment:响应Body"`                 // 响应Body
	UserID       int           `json:"user_id" form:"user_id" gorm:"column:user_id;comment:用户id"`                    // 用户id
	User         SysUser       `json:"user"`
}

如果含有time.Time 请自行import time包

func (SysOperationRecord) Create

func (s SysOperationRecord) Create() (err error)

func (SysOperationRecord) DeleteSysOperationRecordByIds

func (s SysOperationRecord) DeleteSysOperationRecordByIds(ids []int) (err error)

func (*SysOperationRecord) GetSysOperationRecord

func (s *SysOperationRecord) GetSysOperationRecord(id int) (sysOperationRecord SysOperationRecord, err error)

func (SysOperationRecord) GetSysOperationRecordInfoList

func (s SysOperationRecord) GetSysOperationRecordInfoList(info struct {
	SysOperationRecord
	request.PageInfo
}) (list interface{}, total int64, err error)

type SysUser

type SysUser struct {
	MODEL
	UUID        uuid.UUID      `json:"uuid" gorm:"index;comment:用户UUID"`                // 用户UUID
	Username    string         `json:"userName" gorm:"index;comment:用户登录名"`             // 用户登录名
	Password    string         `json:"-"  gorm:"comment:用户登录密码"`                        // 用户登录密码
	NickName    string         `json:"nickName" gorm:"default:系统用户;comment:用户昵称"`       // 用户昵称
	SideMode    string         `json:"sideMode" gorm:"default:dark;comment:用户侧边主题"`     // 用户侧边主题
	HeaderImg   string         `json:"headerImg" gorm:"comment:用户头像"`                   // 用户头像
	BaseColor   string         `json:"baseColor" gorm:"default:#fff;comment:基础颜色"`      // 基础颜色
	ActiveColor string         `json:"activeColor" gorm:"default:#1890ff;comment:活跃颜色"` // 活跃颜色
	AuthorityId int            `json:"authorityId" gorm:"default:888;comment:用户角色ID"`   // 用户角色ID
	Authority   SysAuthority   `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"`
	Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"`
	Phone       string         `json:"phone"  gorm:"comment:用户手机号"`                     // 用户手机号
	Email       string         `json:"email"  gorm:"comment:用户邮箱"`                      // 用户邮箱
	Enable      int            `json:"enable" gorm:"default:1;comment:用户是否被冻结 1正常 2冻结"` //用户是否被冻结 1正常 2冻结
}

func (SysUser) ChangePassword

func (s SysUser) ChangePassword(newPassword string) (userInter *SysUser, err error)

func (SysUser) DeleteUser

func (s SysUser) DeleteUser(id int) (err error)

func (SysUser) GetUserInfo

func (s SysUser) GetUserInfo(uuid uuid.UUID) (user SysUser, err error)

func (SysUser) GetUserInfoList

func (s SysUser) GetUserInfoList(info request.PageInfo) (list interface{}, total int64, err error)

func (SysUser) Login

func (s SysUser) Login(username, password string) (user *SysUser, err error)

func (SysUser) Register

func (s SysUser) Register() (userInter SysUser, err error)

func (SysUser) ResetPassword

func (s SysUser) ResetPassword() (err error)

func (SysUser) SetSelfInfo

func (s SysUser) SetSelfInfo(req SysUser) error

func (SysUser) SetUserAuthorities

func (s SysUser) SetUserAuthorities(authorityIds []int) (err error)

func (SysUser) SetUserAuthority

func (s SysUser) SetUserAuthority() (err error)

func (SysUser) SetUserInfo

func (s SysUser) SetUserInfo(req SysUser) error

func (SysUser) TableName

func (SysUser) TableName() string

type SysUserAuthority

type SysUserAuthority struct {
	SysUserId               int `gorm:"column:sys_user_id"`
	SysAuthorityAuthorityId int `gorm:"column:sys_authority_authority_id"`
}

func (SysUserAuthority) GetAuthorityAuthorityIdByUserId

func (s SysUserAuthority) GetAuthorityAuthorityIdByUserId(uid int) (aid []int)

func (SysUserAuthority) TableName

func (s SysUserAuthority) TableName() string

Jump to

Keyboard shortcuts

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