models

package
v0.0.0-...-3e386e2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PAGESIZE = 20 // 每页默认数量
	PAGE     = 1  // 当前页码
)

Variables

This section is empty.

Functions

func CheckAdmin

func CheckAdmin(id uint64, username string) bool

jwt auth 验证账号是否正确

func Create

func Create(model interface{}) error

创建

func Delete

func Delete(id uint64, model interface{}) error

删除

func Find

func Find(id uint64, model interface{}) error

查找一条信息

func PermissionMenuTableComment

func PermissionMenuTableComment() (o, c string)

迁移文件配置

func PlatformAdminTableComment

func PlatformAdminTableComment() (o, c string)

平台管理员表迁移文件配置

func PlatformRoleMenuTableComment

func PlatformRoleMenuTableComment() (o, c string)

迁移文件配置

func PlatformRoleTableComment

func PlatformRoleTableComment() (o, c string)

迁移文件配置

func Update

func Update(id uint64, model interface{}) error

更新

Types

type IdField

type IdField struct {
	Id uint64 `gorm:"primaryKey" json:"id" title:"ID"`
}

type Pagination

type Pagination struct {
	TotalRecord int64 `json:"total_record"`
	CurrentPage int   `json:"current_page"`
	PageSize    int   `json:"page_size"`
	TotalPages  int   `json:"total_pages"`
	HasNext     bool  `json:"has_next"`
}

分页信息

type PermissionMenu

type PermissionMenu struct {
	Id           uint64   `gorm:"primaryKey" json:"id" title:"ID"`
	AuthProvider string   `gorm:"size:50;comment:系统权限认证模块" json:"auth_provider"`
	Path         string   `gorm:"comment:前端路由地址" json:"path"`
	Name         string   `gorm:"comment:菜单名称" json:"name"`
	Rules        []string `gorm:"type:json;comment:权限api" json:"rules"`
}

func (PermissionMenu) TableName

func (PermissionMenu) TableName() string

表名

type PlatformAdmin

type PlatformAdmin struct {
	Id        uint64    `gorm:"primaryKey" json:"id" title:"ID" show:"detail,lists"`
	RoleId    int8      `gorm:"index;comment:用户角色ID" json:"role_id" show:"detail,lists"`
	Username  string    `gorm:"size:20;unique;comment:用户名" json:"username" validate:"required" title:"用户名" show:"detail,lists"`
	Password  string    `gorm:"varchar:150;comment:用户密码" json:"password" validate:"required"`
	Status    int       `gorm:"type:tinyint;comment:是否启用" json:"status" title:"是否启用" show:"detail,lists"`
	IsRoot    int       `gorm:"type:tinyint;comment:是否是超级管理员" json:"is_root" title:"是否是超级管理员" show:"detail,lists"`
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at" json:"created_at"`
	UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" json:"updated_at"`
}

func FindAdmin

func FindAdmin(username string) (*PlatformAdmin, error)

func (PlatformAdmin) TableName

func (PlatformAdmin) TableName() string

表名

type PlatformRole

type PlatformRole struct {
	Id        uint64    `gorm:"primaryKey" json:"id" title:"ID"`
	Name      string    `gorm:"size:50;comment:角色名称" json:"username" validate:"required" title:"角色名称"`
	Status    int       `gorm:"type:tinyint;default:1;comment:是否启用" json:"status"`
	Listorder int       `gorm:"type:tinyint;default:0;comment:是否启用" json:"listorder"`
	Menus     []string  `gorm:"type:json;comment:前端选中权限菜单" json:"menus"`
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at" json:"created_at"`
	UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" json:"updated_at"`
}

func (PlatformRole) TableName

func (PlatformRole) TableName() string

表名

type PlatformRoleMenu

type PlatformRoleMenu struct {
	RoleId    int64  `gorm:"index;comment:角色ID" json:"role_id"`
	RoutePath string `gorm:"index;comment:权限菜单路由" json:"route_path"`
}

func (PlatformRoleMenu) TableName

func (PlatformRoleMenu) TableName() string

表名

type Query

type Query struct {
	Ctx         *gin.Context // gin context
	DB          *gorm.DB     // DB 实例
	SelectField []string     // 指定查询字段
	FilterField interface{}  // 可搜索字段
	Pagination  Pagination   // 分页
	// contains filtered or unexported fields
}

查询实例

func (*Query) Fetch

func (q *Query) Fetch(model interface{}) (err error)

type TimeField

type TimeField struct {
	CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at" json:"created_at"`
	UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" json:"updated_at"`
}

Jump to

Keyboard shortcuts

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