model

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Department

type Department struct {
	types.BaseModel
	ParentID    uint32        `json:"parent_id" gorm:"not null;comment:父id"`
	Path        string        `json:"path" gorm:"not null;size:256;comment:层级路径"`
	Keyword     string        `json:"keyword" gorm:"not null;size:32;unique;comment:关键字"`
	Name        string        `json:"name" gorm:"not null;size:32;unique;comment:名称"`
	Description string        `json:"description" gorm:"not null;size:256;comment:描述"`
	Children    []*Department `json:"children"  gorm:"-"`
}

func (*Department) All

func (t *Department) All(ctx kratosx.Context, scopes types.Scopes) ([]*Department, error)

All 获取全部部门

func (*Department) AppendChildren

func (t *Department) AppendChildren(child any)

func (*Department) ChildrenNode

func (t *Department) ChildrenNode() []tree.Tree

func (*Department) Create

func (t *Department) Create(ctx kratosx.Context) error

Create 创建部门

func (*Department) DeleteByID

func (t *Department) DeleteByID(ctx kratosx.Context, id uint32) error

DeleteByID 通过id删除指定部门 以及部门下的部门

func (*Department) FindByID

func (t *Department) FindByID(ctx kratosx.Context, id uint32) error

FindByID 通过部门id查询

func (*Department) FindByKeyword

func (t *Department) FindByKeyword(ctx kratosx.Context, keyword string) error

FindByKeyword 通过部门keyword查询

func (*Department) ID

func (t *Department) ID() uint32

func (*Department) Parent

func (t *Department) Parent() uint32

func (*Department) Update

func (t *Department) Update(ctx kratosx.Context) error

Update 更新部门信息

type DepartmentClosure

type DepartmentClosure struct {
	ID                 uint32      `json:"id" gorm:"primaryKey;autoIncrement;comment:主键ID"`
	Parent             uint32      `json:"parent" gorm:"not null;comment:部门id"`
	Children           uint32      `json:"children" gorm:"not null;comment:部门id"`
	ParentDepartment   *Department `json:"parent_department" gorm:"constraint:onDelete:cascade;foreignKey:parent;references:id"`
	ChildrenDepartment *Department `json:"children_department" gorm:"constraint:onDelete:cascade;foreignKey:children;references:id"`
}

type Dict

type Dict struct {
	types.BaseModel
	Keyword     string `json:"keyword" gorm:"not null;size:32;unique;comment:关键字"`
	Name        string `json:"name" gorm:"not null;size:32;unique;comment:名称"`
	Type        string `json:"type" gorm:"not null;size:32;comment:类型"`
	Extra       string `json:"extra" gorm:"size:text;comment:类型"`
	Description string `json:"description" gorm:"not null;size:256;comment:描述"`
}

func (*Dict) Create

func (u *Dict) Create(ctx kratosx.Context) error

Create 创建职位信息

func (*Dict) Creates

func (u *Dict) Creates(ctx kratosx.Context, jobs []*Dict) error

Creates 批量创建职位信息

func (*Dict) DeleteByID

func (u *Dict) DeleteByID(ctx kratosx.Context, id uint32) error

DeleteByID 通过id删除职位信息

func (*Dict) FindByID

func (u *Dict) FindByID(ctx kratosx.Context, id uint32) error

FindByID 通过id查询职位信息

func (*Dict) FindByKeyword

func (u *Dict) FindByKeyword(ctx kratosx.Context, email string) error

FindByKeyword 通过keyword查询职位信息

func (*Dict) Page

func (u *Dict) Page(ctx kratosx.Context, options *types.PageOptions) ([]*Dict, uint32, error)

Page 查询分页数据

func (*Dict) Update

func (u *Dict) Update(ctx kratosx.Context) error

Update 更新职位信息

type DictValue

type DictValue struct {
	types.BaseModel
	DictID      uint32  `json:"dict_id" gorm:"not null;uniqueIndex:dv;comment:字典id"`
	Label       string  `json:"label" gorm:"not null;size:128;unique;comment:标签"`
	Value       string  `json:"value" gorm:"not null;uniqueIndex:dv;size:128;unique;comment:值"`
	Status      *bool   `json:"status" gorm:"default:true;comment:状态"`
	Weight      *uint32 `json:"weight" gorm:"default 0;comment:权重"`
	Type        string  `json:"type" gorm:"size:32;comment:字典类型"`
	Extra       string  `json:"extra" gorm:"size:256;comment:扩展信息"`
	Description string  `json:"description" gorm:"size:256;comment:描述"`
	Dict        *Dict   `json:"dict" gorm:"constraint:onDelete:cascade"`
}

func (*DictValue) AllByDictId

func (u *DictValue) AllByDictId(ctx kratosx.Context, id uint32) ([]*DictValue, error)

AllByDictId 通过dict_id查询所有字典值信息

func (*DictValue) Create

func (u *DictValue) Create(ctx kratosx.Context) error

Create 创字典值位信息

func (*DictValue) Creates

func (u *DictValue) Creates(ctx kratosx.Context, jobs []*DictValue) error

Creates 批量创字典值位信息

func (*DictValue) DeleteByID

func (u *DictValue) DeleteByID(ctx kratosx.Context, id uint32) error

DeleteByID 通过id删除字典值信息

func (*DictValue) Page

func (u *DictValue) Page(ctx kratosx.Context, options *types.PageOptions) ([]*DictValue, uint32, error)

Page 查询分页数据

func (*DictValue) Update

func (u *DictValue) Update(ctx kratosx.Context) error

Update 更新字典值信息

type Job

type Job struct {
	types.BaseModel
	Keyword     string  `json:"keyword" gorm:"not null;size:32;unique;comment:关键字"`
	Name        string  `json:"name" gorm:"not null;size:32;unique;comment:名称"`
	Weight      *uint32 `json:"weight" gorm:"default 0;comment:权重"`
	Description string  `json:"description" gorm:"not null;size:256;comment:描述"`
}

func (*Job) Create

func (u *Job) Create(ctx kratosx.Context) error

Create 创建职位信息

func (*Job) Creates

func (u *Job) Creates(ctx kratosx.Context, jobs []*Job) error

Creates 批量创建职位信息

func (*Job) DeleteByID

func (u *Job) DeleteByID(ctx kratosx.Context, id uint32) error

DeleteByID 通过id删除职位信息

func (*Job) FindByID

func (u *Job) FindByID(ctx kratosx.Context, id uint32) error

FindByID 通过id查询职位信息

func (*Job) FindByKeyword

func (u *Job) FindByKeyword(ctx kratosx.Context, email string) error

FindByKeyword 通过keyword查询职位信息

func (*Job) Page

func (u *Job) Page(ctx kratosx.Context, options *types.PageOptions) ([]*Job, uint32, error)

Page 查询分页数据

func (*Job) Update

func (u *Job) Update(ctx kratosx.Context) error

Update 更新职位信息

type Menu struct {
	types.BaseModel
	ParentID   uint32  `json:"parent_id" gorm:"not null;comment:父id"`
	App        string  `json:"app" gorm:"not null;type:char(32) binary;comment:服务"`
	Title      string  `json:"title" gorm:"not null;size:128;comment:标题"`
	Type       string  `json:"type" gorm:"not null;type:char(32);comment:类型"`
	Keyword    *string `json:"keyword" gorm:"default null;unique;size:64;comment:关键词"`
	Icon       *string `json:"icon" gorm:"default null;type:char(32);comment:图标"`
	Api        *string `json:"api" gorm:"default null;size:128;comment:接口"`
	Method     *string `json:"method" gorm:"default null;size:12;comment:接口方法"`
	Path       *string `json:"path" gorm:"default null;unique;size:128;comment:路径"`
	Permission *string `json:"permission" gorm:"default null;size:128;comment:指令"`
	Component  *string `json:"component" gorm:"default null;size:128;comment:组件"`
	Redirect   *string `json:"redirect" gorm:"default null;size:128;comment:重定向地址"`
	Weight     *uint32 `json:"weight" gorm:"default 0;comment:权重"`
	IsHidden   *bool   `json:"is_hidden" gorm:"default false;comment:是否隐藏"`
	IsCache    *bool   `json:"is_cache" gorm:"default false;comment:是否缓存"`
	IsHome     *bool   `json:"is_home" gorm:"default false;comment:是否为首页"`
	IsAffix    *bool   `json:"is_affix" gorm:"default false;comment:是否为标签"`
	Children   []*Menu `json:"children"  gorm:"-"`
}
func (m *Menu) All(ctx kratosx.Context, scopes types.Scopes) ([]*Menu, error)

All 获取全部的菜单列表

func (m *Menu) AppendChildren(child any)

AppendChildren 添加子节点

func (m *Menu) ChildrenNode() []tree.Tree

ChildrenNode 获取子节点

func (m *Menu) Create(ctx kratosx.Context) error

Create 创建菜单

func (m *Menu) DeleteByIds(ctx kratosx.Context, ids []uint32) error

DeleteByIds 通过条件删除菜单

func (m *Menu) FindByID(ctx kratosx.Context, id uint32) error

FindByID 通过id查询指定菜单

func (m *Menu) ID() uint32

ID 获取菜单树ID

func (m *Menu) Parent() uint32

Parent 获取父ID

func (m *Menu) Tree(ctx kratosx.Context, scopes types.Scopes) (tree.Tree, error)

Tree 获取菜单树

func (m *Menu) Update(ctx kratosx.Context) error

Update 更新菜单

func (m *Menu) UseHome(ctx kratosx.Context, srvKey string, menuId uint32) error

UseHome 将此菜单用于首页菜单

type Role

type Role struct {
	types.BaseModel
	ParentID      uint32  `json:"parent_id" gorm:"not null;comment:父id"`
	Name          string  `json:"name" gorm:"not null;type:char(64);comment:名称"`
	Keyword       string  `json:"keyword" gorm:"not null;type:char(32);comment:关键字"`
	Path          string  `json:"path" gorm:"not null;size:256;comment:层级路径"`
	Status        *bool   `json:"status" gorm:"not null;default:false;comment:状态"`
	Description   *string `json:"description" gorm:"not null;size:128;comment:描述"`
	DepartmentIds *string `json:"department_ids" gorm:"size:256;comment:自定义管理部门"`
	DataScope     string  `json:"data_scope"  gorm:"not null;type:char(32);comment:权限类型"`
	Children      []*Role `json:"children" gorm:"-"`
}

func (*Role) All

func (r *Role) All(ctx kratosx.Context, scopes types.Scopes) ([]*Role, error)

All 查询全部角色信息

func (*Role) AppendChildren

func (r *Role) AppendChildren(child any)

AppendChildren 添加子树

func (*Role) ChildrenNode

func (r *Role) ChildrenNode() []tree.Tree

ChildrenNode 获取子树列表

func (*Role) Create

func (r *Role) Create(ctx kratosx.Context) error

Create 创建角色信息

func (*Role) DeleteByID

func (r *Role) DeleteByID(ctx kratosx.Context, id uint32) error

DeleteByID 通过ID删除角色信息

func (*Role) FindByID

func (r *Role) FindByID(ctx kratosx.Context, id uint32) error

FindByID 通过ID查询角色信息

func (*Role) FindManagerIds

func (r *Role) FindManagerIds(ctx kratosx.Context) ([]uint32, error)

FindManagerIds 查询用户管理的id列表

func (*Role) ID

func (r *Role) ID() uint32

ID 获取ID

func (*Role) Parent

func (r *Role) Parent() uint32

Parent 获取父ID

func (*Role) ParentStatus

func (r *Role) ParentStatus(ctx kratosx.Context) bool

ParentStatus 获取指定角色的父角色状态

func (*Role) Update

func (r *Role) Update(ctx kratosx.Context) error

Update 更新角色信息

type RoleClosure

type RoleClosure struct {
	ID           uint32 `json:"id" gorm:"primaryKey;autoIncrement;comment:主键ID"`
	Parent       uint32 `json:"parent" gorm:"not null;comment:用户id"`
	Children     uint32 `json:"children" gorm:"not null;comment:用户id"`
	ParentRole   *Role  `json:"parent_role" gorm:"constraint:onDelete:cascade;foreignKey:parent;references:id"`
	ChildrenRole *Role  `json:"children_role" gorm:"constraint:onDelete:cascade;foreignKey:children;references:id"`
}

type RoleMenu

type RoleMenu struct {
	types.CreateModel
	RoleID uint32 `json:"role_id" gorm:"not null;comment:角色id"`
	MenuID uint32 `json:"menu_id" gorm:"not null;comment:菜单id"`
	Role   Role   `json:"role" gorm:"constraint:onDelete:cascade"`
	Menu   Menu   `json:"menu" gorm:"constraint:onDelete:cascade"`
}

func (*RoleMenu) DeleteByRoleID

func (rm *RoleMenu) DeleteByRoleID(ctx kratosx.Context, roleId uint32) error

DeleteByRoleID 通过角色id删除 角色所属菜单

func (*RoleMenu) MenuRoles

func (rm *RoleMenu) MenuRoles(ctx kratosx.Context, menuId uint32) ([]*RoleMenu, error)

MenuRoles 通过菜单ID获取角色菜单列表

func (*RoleMenu) RoleMenus

func (rm *RoleMenu) RoleMenus(ctx kratosx.Context, roleId uint32) ([]*RoleMenu, error)

RoleMenus 通过角色ID获取角色菜单

func (*RoleMenu) Update

func (rm *RoleMenu) Update(ctx kratosx.Context, roleId uint32, menuIds []uint32) error

Update 批量更新角色所属菜单

type User

type User struct {
	types.BaseModel
	DepartmentID uint32      `json:"department_id" gorm:"not null;comment:部门id"`
	RoleID       uint32      `json:"role_id" gorm:"not null;comment:角色id"`
	Name         string      `json:"name" gorm:"not null;size:32;comment:名称"`
	Nickname     string      `json:"nickname" gorm:"not null;size:64;comment:昵称"`
	Gender       string      `json:"gender" gorm:"not null;size:12;comment:性别"`
	Phone        string      `json:"phone" gorm:"not null;size:11;comment:手机号码"`
	Password     string      `json:"password" gorm:"not null;size:256;comment:密码"`
	Avatar       string      `json:"avatar" gorm:"size:128;comment:头像"`
	Email        string      `json:"email" gorm:"not null;size:64;comment:邮箱"`
	Status       *bool       `json:"status" gorm:"default:false;comment:状态"`
	Disabled     *string     `json:"disabled" gorm:"size:64;comment:禁用原因"`
	LastLogin    int64       `json:"last_login" gorm:"comment:禁用原因"`
	Token        string      `json:"token" gorm:"size:512;comment:禁用原因"`
	Role         *Role       `json:"role"`
	Department   *Department `json:"department"`
}

func (*User) Create

func (u *User) Create(ctx kratosx.Context) error

Create 创建用户信息

func (*User) DeleteByID

func (u *User) DeleteByID(ctx kratosx.Context, id uint32) error

DeleteByID 通过id删除用户信息

func (*User) FindByEmail

func (u *User) FindByEmail(ctx kratosx.Context, email string) error

FindByEmail 通过email查询用户信息

func (*User) FindByID

func (u *User) FindByID(ctx kratosx.Context, id uint32) error

FindByID 通过id查询用户信息

func (*User) FindByPhone

func (u *User) FindByPhone(ctx kratosx.Context, phFind string) error

FindByPhone 通过phFind查询用户信息

func (*User) HasRoleManagerScope

func (u *User) HasRoleManagerScope(ctx kratosx.Context, rid uint32) bool

HasRoleManagerScope 判断用户是否具有指定用户的管理权限

func (*User) HasUserManagerScope

func (u *User) HasUserManagerScope(ctx kratosx.Context, mid, id uint32) bool

HasUserManagerScope 判断用户是否具有指定用户的管理权限

func (*User) ManagerDepartment

func (u *User) ManagerDepartment(ctx kratosx.Context, uid uint32) ([]*Department, error)

ManagerDepartment 通过用户id获取用户所管理的部门列表

func (*User) ManagerDepartmentIds

func (u *User) ManagerDepartmentIds(ctx kratosx.Context, uid uint32) ([]uint32, error)

ManagerDepartmentIds 通过用户id获取用户所管理的部门id列表

func (*User) Page

func (u *User) Page(ctx kratosx.Context, options *types.PageOptions) ([]*User, uint32, error)

Page 查询分页数据

func (*User) Update

func (u *User) Update(ctx kratosx.Context) error

Update 更新用户信息

func (*User) UpdateLastLogin

func (u *User) UpdateLastLogin(ctx kratosx.Context, t uint32) error

type UserJob

type UserJob struct {
	types.CreateModel
	JobID  uint32 `json:"job_id" gorm:"not null;comment:角色id"`
	UserID uint32 `json:"user_id" gorm:"not null;comment:菜单id"`
	Job    *Job   `json:"job" gorm:"constraint:OnDelete:cascade"`
}

func (*UserJob) Add

func (ur *UserJob) Add(ctx kratosx.Context) error

func (*UserJob) DeleteByID

func (ur *UserJob) DeleteByID(ctx kratosx.Context, id uint32) error

DeleteByID 通过id删除

func (*UserJob) FindByUserAndJob

func (ur *UserJob) FindByUserAndJob(ctx kratosx.Context, userId, jobId uint32) error

func (*UserJob) Update

func (ur *UserJob) Update(ctx kratosx.Context, userId uint32, jobIds []uint32) error

Update 批量更新角色所属菜单

func (*UserJob) UserJobs

func (ur *UserJob) UserJobs(ctx kratosx.Context, userId uint32) ([]*UserJob, error)

UserJobs 通过角色ID获取角色菜单

type UserRole

type UserRole struct {
	types.CreateModel
	RoleID uint32 `json:"role_id" gorm:"not null;comment:角色id"`
	UserID uint32 `json:"user_id" gorm:"not null;comment:菜单id"`
	Role   *Role  `json:"role" gorm:"constraint:OnDelete:cascade"`
}

func (*UserRole) Add

func (ur *UserRole) Add(ctx kratosx.Context) error

func (*UserRole) DeleteByID

func (ur *UserRole) DeleteByID(ctx kratosx.Context, id uint32) error

DeleteByID 通过id删除

func (*UserRole) FindByUserAndRole

func (ur *UserRole) FindByUserAndRole(ctx kratosx.Context, userId, roleId uint32) error

func (*UserRole) Update

func (ur *UserRole) Update(ctx kratosx.Context, userId uint32, roleIds []uint32) error

Update 批量更新角色所属菜单

func (*UserRole) UserRoles

func (ur *UserRole) UserRoles(ctx kratosx.Context, userId uint32) ([]*UserRole, error)

UserRoles 通过角色ID获取角色菜单

Jump to

Keyboard shortcuts

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