go-admin: github.com/GoAdminGroup/go-admin/plugins/admin/models Index | Files

package models

import "github.com/GoAdminGroup/go-admin/plugins/admin/models"

Index

Package Files

base.go menu.go operation_log.go permission.go role.go site.go user.go

Constants

const (
    SiteItemOpenState = 1
    SiteItemOffState  = 0
)

type Base Uses

type Base struct {
    TableName string

    Conn db.Connection
    Tx   *sql.Tx
}

Base is base model structure.

func (Base) SetConn Uses

func (b Base) SetConn(con db.Connection) Base

func (Base) Table Uses

func (b Base) Table(table string) *db.SQL
type MenuModel struct {
    Base

    Id        int64
    Title     string
    ParentId  int64
    Icon      string
    Uri       string
    Header    string
    CreatedAt string
    UpdatedAt string
}

MenuModel is menu model structure.

func Menu() MenuModel

Menu return a default menu model.

func MenuWithId(id string) MenuModel

MenuWithId return a default menu model of given id.

func (t MenuModel) AddRole(roleId string) (int64, error)

AddRole add a role to the menu.

func (t MenuModel) CheckRole(roleId string) bool

CheckRole check the role if has permission to get the menu.

func (t MenuModel) Delete()

Delete delete the menu model.

func (t MenuModel) DeleteRoles() error

DeleteRoles delete roles with menu.

func (t MenuModel) Find(id interface{}) MenuModel

Find return a default menu model of given id.

func (t MenuModel) MapToModel(m map[string]interface{}) MenuModel

MapToModel get the menu model from given map.

func (t MenuModel) New(title, icon, uri, header string, parentId, order int64) (MenuModel, error)

New create a new menu model.

func (t MenuModel) ResetOrder(data []byte)

ResetOrder update the order of menu models.

func (t MenuModel) SetConn(con db.Connection) MenuModel
func (t MenuModel) Update(title, icon, uri, header string, parentId int64) (int64, error)

Update update the menu model.

type OperationLogModel Uses

type OperationLogModel struct {
    Base

    Id        int64
    UserId    int64
    Path      string
    Method    string
    Ip        string
    Input     string
    CreatedAt string
    UpdatedAt string
}

OperationLogModel is operation log model structure.

func OperationLog Uses

func OperationLog() OperationLogModel

OperationLog return a default operation log model.

func (OperationLogModel) Find Uses

func (t OperationLogModel) Find(id interface{}) OperationLogModel

Find return a default operation log model of given id.

func (OperationLogModel) MapToModel Uses

func (t OperationLogModel) MapToModel(m map[string]interface{}) OperationLogModel

MapToModel get the operation log model from given map.

func (OperationLogModel) New Uses

func (t OperationLogModel) New(userId int64, path, method, ip, input string) OperationLogModel

New create a new operation log model.

func (OperationLogModel) SetConn Uses

func (t OperationLogModel) SetConn(con db.Connection) OperationLogModel

type OrderItem Uses

type OrderItem struct {
    ID       uint       `json:"id"`
    Children OrderItems `json:"children"`
}

type OrderItems Uses

type OrderItems []OrderItem

type PermissionModel Uses

type PermissionModel struct {
    Base

    Id         int64
    Name       string
    Slug       string
    HttpMethod []string
    HttpPath   []string
    CreatedAt  string
    UpdatedAt  string
}

PermissionModel is permission model structure.

func Permission Uses

func Permission() PermissionModel

Permission return a default permission model.

func PermissionWithId Uses

func PermissionWithId(id string) PermissionModel

PermissionWithId return a default permission model of given id.

func (PermissionModel) Find Uses

func (t PermissionModel) Find(id interface{}) PermissionModel

Find return the permission model of given id.

func (PermissionModel) FindByName Uses

func (t PermissionModel) FindByName(name string) PermissionModel

FindBySlug return the permission model of given slug.

func (PermissionModel) FindBySlug Uses

func (t PermissionModel) FindBySlug(slug string) PermissionModel

FindBySlug return the permission model of given slug.

func (PermissionModel) IsEmpty Uses

func (t PermissionModel) IsEmpty() bool

IsEmpty check the user model is empty or not.

func (PermissionModel) IsSlugExist Uses

func (t PermissionModel) IsSlugExist(slug string, id string) bool

IsSlugExist check the row exist with given slug and id.

func (PermissionModel) MapToModel Uses

func (t PermissionModel) MapToModel(m map[string]interface{}) PermissionModel

MapToModel get the permission model from given map.

func (PermissionModel) SetConn Uses

func (t PermissionModel) SetConn(con db.Connection) PermissionModel

type RoleModel Uses

type RoleModel struct {
    Base

    Id        int64
    Name      string
    Slug      string
    CreatedAt string
    UpdatedAt string
}

RoleModel is role model structure.

func Role Uses

func Role() RoleModel

Role return a default role model.

func RoleWithId Uses

func RoleWithId(id string) RoleModel

RoleWithId return a default role model of given id.

func (RoleModel) AddPermission Uses

func (t RoleModel) AddPermission(permissionId string) (int64, error)

AddPermission add the permissions to the role.

func (RoleModel) CheckPermission Uses

func (t RoleModel) CheckPermission(permissionId string) bool

CheckPermission check the permission of role.

func (RoleModel) DeletePermissions Uses

func (t RoleModel) DeletePermissions() error

DeletePermissions delete all the permissions of role.

func (RoleModel) Find Uses

func (t RoleModel) Find(id interface{}) RoleModel

Find return a default role model of given id.

func (RoleModel) IsSlugExist Uses

func (t RoleModel) IsSlugExist(slug string, id string) bool

IsSlugExist check the row exist with given slug and id.

func (RoleModel) MapToModel Uses

func (t RoleModel) MapToModel(m map[string]interface{}) RoleModel

MapToModel get the role model from given map.

func (RoleModel) New Uses

func (t RoleModel) New(name, slug string) (RoleModel, error)

New create a role model.

func (RoleModel) SetConn Uses

func (t RoleModel) SetConn(con db.Connection) RoleModel

func (RoleModel) Update Uses

func (t RoleModel) Update(name, slug string) (int64, error)

Update update the role model.

func (RoleModel) WithTx Uses

func (t RoleModel) WithTx(tx *sql.Tx) RoleModel

type SiteModel Uses

type SiteModel struct {
    Base

    Id    int64
    Key   string
    Value string
    Desc  string
    State int64

    CreatedAt string
    UpdatedAt string
}

SiteModel is role model structure.

func Site Uses

func Site() SiteModel

Site return a default role model.

func (SiteModel) AllToMap Uses

func (t SiteModel) AllToMap() map[string]string

func (SiteModel) AllToMapInterface Uses

func (t SiteModel) AllToMapInterface() map[string]interface{}

func (SiteModel) Init Uses

func (t SiteModel) Init(cfg map[string]string)

func (SiteModel) SetConn Uses

func (t SiteModel) SetConn(con db.Connection) SiteModel

func (SiteModel) Update Uses

func (t SiteModel) Update(v form.Values) error

func (SiteModel) WithTx Uses

func (t SiteModel) WithTx(tx *sql.Tx) SiteModel

type UserModel Uses

type UserModel struct {
    Base `json:"-"`

    Id            int64             `json:"id"`
    Name          string            `json:"name"`
    UserName      string            `json:"user_name"`
    Password      string            `json:"password"`
    Avatar        string            `json:"avatar"`
    RememberToken string            `json:"remember_token"`
    Permissions   []PermissionModel `json:"permissions"`
    MenuIds       []int64           `json:"menu_ids"`
    Roles         []RoleModel       `json:"role"`
    Level         string            `json:"level"`
    LevelName     string            `json:"level_name"`

    CreatedAt string `json:"created_at"`
    UpdatedAt string `json:"updated_at"`
}

UserModel is user model structure.

func User Uses

func User() UserModel

User return a default user model.

func UserWithId Uses

func UserWithId(id string) UserModel

UserWithId return a default user model of given id.

func (UserModel) AddPermission Uses

func (t UserModel) AddPermission(permissionId string) (int64, error)

AddPermission add a permission of the user model.

func (UserModel) AddRole Uses

func (t UserModel) AddRole(roleId string) (int64, error)

AddRole add a role of the user model.

func (UserModel) CheckPermission Uses

func (t UserModel) CheckPermission(permission string) bool

CheckPermission check the permission of the user.

func (UserModel) CheckPermissionById Uses

func (t UserModel) CheckPermissionById(permissionId string) bool

CheckPermission check the permission of the user.

func (UserModel) CheckPermissionByUrlMethod Uses

func (t UserModel) CheckPermissionByUrlMethod(path, method string, formParams url.Values) bool

func (UserModel) CheckRole Uses

func (t UserModel) CheckRole(slug string) bool

CheckRole check the role of the user.

func (UserModel) CheckRoleId Uses

func (t UserModel) CheckRoleId(roleId string) bool

CheckRole check the role of the user model.

func (UserModel) DeletePermissions Uses

func (t UserModel) DeletePermissions() error

DeletePermissions delete all the permissions of the user model.

func (UserModel) DeleteRoles Uses

func (t UserModel) DeleteRoles() error

DeleteRoles delete all the roles of the user model.

func (UserModel) Find Uses

func (t UserModel) Find(id interface{}) UserModel

Find return a default user model of given id.

func (UserModel) FindByUserName Uses

func (t UserModel) FindByUserName(username interface{}) UserModel

FindByUserName return a default user model of given name.

func (UserModel) GetAllRoleId Uses

func (t UserModel) GetAllRoleId() []interface{}

func (UserModel) GetCheckPermissionByUrlMethod Uses

func (t UserModel) GetCheckPermissionByUrlMethod(path, method string) string

func (UserModel) HasMenu Uses

func (t UserModel) HasMenu() bool

HasMenu check the user has visitable menu or not.

func (UserModel) HideUserCenterEntrance Uses

func (t UserModel) HideUserCenterEntrance() bool

func (UserModel) IsEmpty Uses

func (t UserModel) IsEmpty() bool

IsEmpty check the user model is empty or not.

func (UserModel) IsSuperAdmin Uses

func (t UserModel) IsSuperAdmin() bool

IsSuperAdmin check the user model is super admin or not.

func (UserModel) IsVisitor Uses

func (t UserModel) IsVisitor() bool

func (UserModel) MapToModel Uses

func (t UserModel) MapToModel(m map[string]interface{}) UserModel

MapToModel get the user model from given map.

func (UserModel) New Uses

func (t UserModel) New(username, password, name, avatar string) (UserModel, error)

New create a user model.

func (UserModel) ReleaseConn Uses

func (t UserModel) ReleaseConn() UserModel

UpdateAvatar update the avatar of user.

func (UserModel) SetConn Uses

func (t UserModel) SetConn(con db.Connection) UserModel

func (UserModel) Update Uses

func (t UserModel) Update(username, password, name, avatar string) (int64, error)

Update update the user model.

func (UserModel) UpdateAvatar Uses

func (t UserModel) UpdateAvatar(avatar string)

UpdateAvatar update the avatar of user.

func (UserModel) UpdatePwd Uses

func (t UserModel) UpdatePwd(password string) UserModel

UpdatePwd update the password of the user model.

func (UserModel) WithMenus Uses

func (t UserModel) WithMenus() UserModel

WithMenus query the menu info of the user.

func (UserModel) WithPermissions Uses

func (t UserModel) WithPermissions() UserModel

WithPermissions query the permission info of the user.

func (UserModel) WithRoles Uses

func (t UserModel) WithRoles() UserModel

WithRoles query the role info of the user.

func (UserModel) WithTx Uses

func (t UserModel) WithTx(tx *sql.Tx) UserModel

Package models imports 14 packages (graph) and is imported by 25 packages. Updated 2020-05-13. Refresh now. Tools for package owners.