models

package
v0.0.0-...-fa384c1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRoleName

func CheckRoleName(name string) (bool, error)

func CheckUsername

func CheckUsername(username string) (bool, error)

func CloseDB

func CloseDB()

func GetTree

func GetTree() (dto.FillMenusTree, error)

func ToDtoRoles

func ToDtoRoles(a []*Role) []*dto.Role

Types

type AuthSwag

type AuthSwag struct {
	Username string `json:"username"`
	Password string `json:"password"`
}
type Menu struct {
	Model
	Name       *string         `gorm:"column:name;"`                                                                  // 菜单名称
	Sequence   *int            `gorm:"column:sequence;"`                                                              // 排序值
	Icon       *string         `gorm:"column:icon;"`                                                                  // 菜单图标
	Router     *string         `gorm:"column:router;"`                                                                // 访问路由
	Hidden     *int            `gorm:"column:hidden;"`                                                                // 隐藏菜单(0:不隐藏 1:隐藏)
	ParentID   *int            `gorm:"column:parent_id;"`                                                             // 父级内码
	ParentPath *string         `gorm:"column:parent_path;"`                                                           // 父级路径
	Resources  []*MenuResource `gorm:"association_save_reference:false;foreignkey:MenuID;association_foreignkey:ID;"` // 资源列表
	Actions    []*MenuAction   `gorm:"association_save_reference:false;foreignkey:MenuID;association_foreignkey:ID;"` // 动作列表
}

func BelongToFillMenu

func BelongToFillMenu(a *dto.FillMenu) *Menu

转实体FillMenu

func BelongToMenu

func BelongToMenu(a *dto.Menu) *Menu

转实体Menu

func (a *Menu) Create() error
func (a *Menu) Delete(id int) error
func (a *Menu) Find(id int) (*Menu, error)
func (a Menu) Query(params *dto.MenuQueryParams) (Menus, int, error)
func (a Menu) TableName() string
func (a *Menu) ToDtoMenu() *dto.Menu
func (a *Menu) Update() error
func (a *Menu) UpdateMenuGetRoles(id int) []int
type MenuAction struct {
	Model
	MenuID int    `gorm:"column:menu_id;int;size:36;index;"` // 菜单ID
	Code   string `gorm:"column:code;size:50;index;"`        // 动作编号
	Name   string `gorm:"column:name;size:50;"`              // 动作名称
}

MenuAction 菜单动作关联实体

func BelongToAction

func BelongToAction(a *dto.MenuAction, menuID int) *MenuAction

转实体Action

func (a MenuAction) TableName() string

TableName 表名

func (a MenuAction) ToPogoMenuActive() *dto.MenuAction
type MenuActions []*MenuAction

MenuActions 菜单动作关联实体列表

func (a MenuActions) GetByMenuID(menuID int) []*dto.MenuAction

GetByMenuID 根据菜单ID获取菜单动作列表

type MenuResource struct {
	Model
	MenuID int    `gorm:"column:menu_id;size:36;index;"` // 菜单ID
	Code   string `gorm:"column:code;size:50;index;"`    // 资源编号
	Name   string `gorm:"column:name;size:50;"`          // 资源名称
	Method string `gorm:"column:method;size:50;"`        // 请求方式
	Path   string `gorm:"column:path;size:255;"`         // 请求路径
}

MenuResource 菜单资源关联实体

func BelongToResource

func BelongToResource(a *dto.MenuResource, menuID int) *MenuResource

转实体Resource

func (a MenuResource) TableName() string

TableName 表名

func (a *MenuResource) ToPogoMenuResource() *dto.MenuResource
type MenuResources []*MenuResource

MenuResources 菜单资源关联实体列表

func (a MenuResources) GetByMenuID(menuID int) []*dto.MenuResource

GetByMenuID 根据菜单ID获取菜单资源列表

type Menus []*Menu

Menus 菜单实体列表

func (a Menus) DoFillMenus(includeActions bool, includeResources bool) (dto.FillMenusTree, error)

填充菜单对象数据

type Model

type Model struct {
	ID        int                `gorm:"primary_key" json:"id"`
	CreatedAt gormkit.LocalTime  `json:"created_at"`
	UpdatedAt gormkit.LocalTime  `json:"updated_at"`
	DeletedAt *gormkit.LocalTime `json:"deleted_at"`
}

func (Model) TableName

func (Model) TableName(name string) string

type Role

type Role struct {
	Model
	Name      *string     `gorm:"column:name;"`
	Memo      *string     `gorm:"column:memo"`
	RoleMenus []*RoleMenu `gorm:"association_save_reference:false;"`
}

func GetRolesAll

func GetRolesAll() ([]*Role, error)

func (*Role) Create

func (a *Role) Create(dtoRoleMenus []*dto.RoleMenu) error

func (*Role) Delete

func (a *Role) Delete(id int) error

func (*Role) Find

func (a *Role) Find(id int) (*Role, error)

func (*Role) Query

func (a *Role) Query(params *dto.RoleQueryParams) ([]*Role, int, error)

func (Role) TableName

func (a Role) TableName() string

func (*Role) ToDtoRole

func (a *Role) ToDtoRole() *dto.Role

func (*Role) Update

func (a *Role) Update(dtoRoleMenus []*dto.RoleMenu) error

type RoleMenu

type RoleMenu struct {
	Model
	RoleID   int     `gorm:"column:role_id;"`  // 角色内码
	MenuID   int     `gorm:"column:menu_id;"`  // 菜单内码
	Action   *string `gorm:"column:action;"`   // 动作权限(多个以英文逗号分隔)
	Resource *string `gorm:"column:resource;"` // 资源权限(多个以英文逗号分隔)
}

RoleMenu 角色菜单关联实体

type User

type User struct {
	Model
	Username *string `gorm:"column:username"`
	Password *string `gorm:"column:password"`
	Nickname *string `gorm:"column:nickname"`
	Disabled *int    `gorm:"column:disabled"`
	Phone    *string `gorm:"column:phone"`
	Email    *string `gorm:"column:email"`
	Roles    []*Role `gorm:"many2many:user_role;"`
}

func CheckUser

func CheckUser(username, password string) (*User, error)

func GetUsersAll

func GetUsersAll() ([]*User, error)

func (*User) Create

func (a *User) Create(roleIds []int) error

func (*User) Delete

func (a *User) Delete(id int) error

func (*User) Find

func (a *User) Find(id int) (*User, error)

func (*User) Query

func (a *User) Query(params *dto.UserQueryParams) ([]*User, int, error)

func (User) TableName

func (a User) TableName() string

func (*User) ToDtoUser

func (a *User) ToDtoUser() *dto.User

func (*User) Update

func (a *User) Update(roleIds []int) error

type UserRole

type UserRole struct {
	Model
	UserID int `gorm:"column:user_id"`
	RoleID int `gorm:"column:role_id"`
}

func (UserRole) TableName

func (a UserRole) TableName() string

Jump to

Keyboard shortcuts

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