models

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

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

Go to latest
Published: Jun 27, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSystemAdmin

func CreateSystemAdmin(roleId uint)

* *创建系统管理员 *@param role_id uint *@return *models.AdminUserTranform api格式化后的数据格式

func CreateSystemAdminPermission

func CreateSystemAdminPermission(perms []*validates.PermissionRequest) []uint

*

  • 创建系统权限
  • @return

func CreateSystemData

func CreateSystemData(perms []*validates.PermissionRequest)

* *初始化系统 账号 权限 角色

func DelAllData

func DelAllData()

func DropTables

func DropTables()

func GetAll

func GetAll(string, orderBy string, offset, limit int) *gorm.DB

*

  • 获取列表
  • @method MGetAll
  • @param {[type]} string string [description]
  • @param {[type]} orderBy string [description]
  • @param {[type]} relation string [description]
  • @param {[type]} offset int [description]
  • @param {[type]} limit int [description]

func GetPermissionsForUser

func GetPermissionsForUser(uid uint) [][]string

func GetRolesForUser

func GetRolesForUser(uid uint) []string

func IsNotFound

func IsNotFound(err error)

func Update

func Update(v, d interface{}) error

func UserAdminLogout

func UserAdminLogout(userId uint) bool

* * 用户退出登陆 * @method UserAdminLogout * @param {[type]} ids string [description]

Types

type OauthToken

type OauthToken struct {
	gorm.Model

	Token     string `gorm:"not null default '' comment('Token') VARCHAR(191)"`
	UserId    uint   `gorm:"not null default '' comment('UserId') VARCHAR(191)"`
	Secret    string `gorm:"not null default '' comment('Secret') VARCHAR(191)"`
	ExpressIn int64  `gorm:"not null default 0 comment('是否是标准库') BIGINT(20)"`
	Revoked   bool
}

func (*OauthToken) GetOauthTokenByToken

func (ot *OauthToken) GetOauthTokenByToken(token string)

*

  • 通过 token 获取 access_token 记录
  • @method GetOauthTokenByToken
  • @param {[type]} token string [description]

func (*OauthToken) OauthTokenCreate

func (ot *OauthToken) OauthTokenCreate() *Token

*

  • oauth_token
  • @method OauthTokenCreate

func (*OauthToken) UpdateOauthTokenByUserId

func (ot *OauthToken) UpdateOauthTokenByUserId(userId uint)

*

  • 通过 user_id 更新 oauth_token 记录
  • @method UpdateOauthTokenByUserId *@param {[type]} user *OauthToken [description]

type Permission

type Permission struct {
	gorm.Model
	Name        string `gorm:"not null VARCHAR(191)"`
	DisplayName string `gorm:"VARCHAR(191)"`
	Description string `gorm:"VARCHAR(191)"`
	Act         string `gorm:"VARCHAR(191)"`
}

func GetAllPermissions

func GetAllPermissions(name, orderBy string, offset, limit int) (permissions []*Permission)

*

  • 获取所有的权限
  • @method GetAllPermissions
  • @param {[type]} name string [description]
  • @param {[type]} orderBy string [description]
  • @param {[type]} offset int [description]
  • @param {[type]} limit int [description]

func NewPermission

func NewPermission(id uint, name, act string) *Permission

func NewPermissionByStruct

func NewPermissionByStruct(jp *validates.PermissionRequest) *Permission

func (*Permission) CreatePermission

func (p *Permission) CreatePermission()

*

  • 创建
  • @method CreatePermission
  • @param {[type]} kw string [description]
  • @param {[type]} cp int [description]
  • @param {[type]} mp int [description]

func (*Permission) DeletePermissionById

func (p *Permission) DeletePermissionById()

*

  • 通过 id 删除权限
  • @method DeletePermissionById

func (*Permission) GetPermissionById

func (p *Permission) GetPermissionById()

*

  • 通过 id 获取 permission 记录
  • @method GetPermissionById
  • @param {[type]} permission *Permission [description]

func (*Permission) GetPermissionByNameAct

func (p *Permission) GetPermissionByNameAct()

*

  • 通过 name 获取 permission 记录
  • @method GetPermissionByName
  • @param {[type]} permission *Permission [description]

func (*Permission) UpdatePermission

func (p *Permission) UpdatePermission(pj *validates.PermissionRequest)

*

  • 更新
  • @method UpdatePermission
  • @param {[type]} kw string [description]
  • @param {[type]} cp int [description]
  • @param {[type]} mp int [description]

type Role

type Role struct {
	gorm.Model

	Name        string `gorm:"unique;not null VARCHAR(191)"`
	DisplayName string `gorm:"VARCHAR(191)"`
	Description string `gorm:"VARCHAR(191)"`
}

func CreateSystemAdminRole

func CreateSystemAdminRole(permIds []uint) *Role

* *创建系统管理员 *@return *models.AdminRoleTranform api格式化后的数据格式

func GetAllRoles

func GetAllRoles(name, orderBy string, offset, limit int) (roles []*Role)

*

  • 获取所有的角色
  • @method GetAllRole
  • @param {[type]} name string [description]
  • @param {[type]} orderBy string [description]
  • @param {[type]} offset int [description]
  • @param {[type]} limit int [description]

func NewRole

func NewRole(id uint, name string) *Role

func NewRoleByStruct

func NewRoleByStruct(rr *validates.RoleRequest) *Role

func (*Role) CreateRole

func (r *Role) CreateRole(permIds []uint)

*

  • 创建
  • @method CreateRole
  • @param {[type]} kw string [description]
  • @param {[type]} cp int [description]
  • @param {[type]} mp int [description]

func (*Role) DeleteRoleById

func (r *Role) DeleteRoleById()

*

  • 通过 id 删除角色
  • @method DeleteRoleById

func (*Role) GetRoleById

func (r *Role) GetRoleById()

*

  • 通过 id 获取 role 记录
  • @method GetRoleById
  • @param {[type]} role *Role [description]

func (*Role) GetRoleByName

func (r *Role) GetRoleByName()

*

  • 通过 name 获取 role 记录
  • @method GetRoleByName
  • @param {[type]} role *Role [description]

func (*Role) RolePermisions

func (r *Role) RolePermisions() []*Permission

角色权限

func (*Role) UpdateRole

func (r *Role) UpdateRole(rj *validates.RoleRequest, permIds []uint)

*

  • 更新
  • @method UpdateRole
  • @param {[type]} kw string [description]
  • @param {[type]} cp int [description]
  • @param {[type]} mp int [description]

type Stream

type Stream struct {
	gorm.Model
	Status     bool
	URL        string `gorm:"type:varchar(256);unique"`
	CustomPath string `gorm:"type:varchar(256)"`
}

type Token

type Token struct {
	Token string `json:"access_token"`
}

type User

type User struct {
	gorm.Model

	Name     string `gorm:"not null VARCHAR(191)"`
	Username string `gorm:"unique;VARCHAR(191)"`
	Password string `gorm:"not null VARCHAR(191)"`
}

func GetAllUsers

func GetAllUsers(name, orderBy string, offset, limit int) []*User

*

  • 获取所有的账号
  • @method GetAllUser
  • @param {[type]} name string [description]
  • @param {[type]} username string [description]
  • @param {[type]} orderBy string [description]
  • @param {[type]} offset int [description]
  • @param {[type]} limit int [description]

func NewUser

func NewUser(id uint, username string) *User

func NewUserByStruct

func NewUserByStruct(ru *validates.CreateUpdateUserRequest) *User

func (*User) CheckLogin

func (u *User) CheckLogin(password string) (*Token, bool, string)

*

  • 判断用户是否登录
  • @method CheckLogin
  • @param {[type]} id int [description]
  • @param {[type]} password string [description]

func (*User) CreateUser

func (u *User) CreateUser(aul *validates.CreateUpdateUserRequest)

*

  • 创建
  • @method CreateUser
  • @param {[type]} kw string [description]
  • @param {[type]} cp int [description]
  • @param {[type]} mp int [description]

func (*User) DeleteUser

func (u *User) DeleteUser()

*

  • 通过 id 删除用户
  • @method DeleteUserById

func (*User) GetUserById

func (u *User) GetUserById()

func (*User) GetUserByUsername

func (u *User) GetUserByUsername()

func (*User) UpdateUser

func (u *User) UpdateUser(uj *validates.CreateUpdateUserRequest)

*

  • 更新
  • @method UpdateUser
  • @param {[type]} kw string [description]
  • @param {[type]} cp int [description]
  • @param {[type]} mp int [description]

Jump to

Keyboard shortcuts

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