database

package
v0.0.0-...-bff2e6b Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Db *gorm.DB
	CE *casbin.Enforcer
)

Functions

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 HashPassword

func HashPassword(pwd string) string

func New

func New(db *gorm.DB, ce *casbin.Enforcer)

New new DB backend for I18n

func TUserAdminLogout

func TUserAdminLogout(userId uint) bool

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

func Update

func Update(v, d interface{}) error

Types

type Backend

type Backend struct {
	DB *gorm.DB
}

Backend DB backend

type TOauthToken

type TOauthToken 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 (*TOauthToken) GetTOauthTokenByToken

func (ot *TOauthToken) GetTOauthTokenByToken(token string)

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

func (*TOauthToken) TOauthTokenCreate

func (ot *TOauthToken) TOauthTokenCreate() *Token

* * oauth_token * @method OauthTokenCreate

func (*TOauthToken) UpdateTOauthTokenByTUserId

func (ot *TOauthToken) UpdateTOauthTokenByTUserId(userId uint)

* * 通过 user_id 更新 oauth_token 记录 * @method UpdatetOauthTokenByUserId *@param {[type]} user *tOauthToken [description]

type TPermission

type TPermission 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 GetAllTPermissions

func GetAllTPermissions(name, orderBy string, offset, limit int) (permissions []*TPermission)

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

func NewTPermission

func NewTPermission(id uint, name, act string) *TPermission

func (*TPermission) CreateTPermission

func (p *TPermission) CreateTPermission() error

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

func (*TPermission) DeleteTPermissionById

func (p *TPermission) DeleteTPermissionById()

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

func (*TPermission) GetTPermissionById

func (p *TPermission) GetTPermissionById()

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

func (*TPermission) GetTPermissionByNameAct

func (p *TPermission) GetTPermissionByNameAct()

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

func (*TPermission) UpdateTPermission

func (p *TPermission) UpdateTPermission(pj *validates.TPermissionRequest)

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

type TRole

type TRole struct {
	gorm.Model

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

func GetAllTRoles

func GetAllTRoles(name, orderBy string, offset, limit int) (roles []*TRole)

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

func NewTRole

func NewTRole(id uint, name string) *TRole

func NewTRoleByStruct

func NewTRoleByStruct(rr *validates.TRoleRequest) *TRole

func (*TRole) CreateTRole

func (r *TRole) CreateTRole(permIds []uint) error

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

func (*TRole) DeleteTRoleById

func (r *TRole) DeleteTRoleById()

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

func (*TRole) GetTRoleById

func (r *TRole) GetTRoleById()

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

func (*TRole) GetTRoleByName

func (r *TRole) GetTRoleByName()

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

func (*TRole) TRoleTPermisions

func (r *TRole) TRoleTPermisions() []*TPermission

角色权限

func (*TRole) UpdateTRole

func (r *TRole) UpdateTRole(rj *validates.TRoleRequest, permIds []uint)

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

type TUser

type TUser struct {
	gorm.Model

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

func GetAllTUsers

func GetAllTUsers(name, orderBy string, offset, limit int) []*TUser

* * 获取所有的账号 * @method GetAllTUser * @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 NewTUser

func NewTUser(id uint, username string) *TUser

func NewTUserByStruct

func NewTUserByStruct(ru *validates.CreateUpdateTUserRequest) *TUser

func (*TUser) CheckLogin

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

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

func (*TUser) CreateTUser

func (u *TUser) CreateTUser(roleIds []uint) error

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

func (*TUser) DeleteTUser

func (u *TUser) DeleteTUser()

* * 通过 id 删除用户 * @method DeleteTUserById

func (*TUser) GetTUserById

func (u *TUser) GetTUserById()

func (*TUser) GetTUserByUsername

func (u *TUser) GetTUserByUsername()

func (*TUser) UpdateTUser

func (u *TUser) UpdateTUser(uj *validates.CreateUpdateTUserRequest)

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

type Tenant

type Tenant struct {
	gorm.Model

	Name     string
	FullName string                       // 全称
	Avatar   qortenant.AvatarImageStorage //'头像',
	Province string
	City     string
	County   string
	Addr     string
	Phone    string
	Lng      float64 // 经度
	Lat      float64 // 纬度
	TUsers   []*TUser
}

type Token

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

Jump to

Keyboard shortcuts

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