contrib

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROLE_NAME_SUPER   = "superuser" // 超级管理员
	ROLE_NAME_LIMITED = "limited"   // 受限用户
	URL_PREFIX_IMAGE  = "/images"   // 静态图片网址
)

Variables

View Source
var (
	WeekEndType = calendar.W_MON_FRI // 双休

)

Functions

func AddAccess

func AddAccess(role, res string, perm uint16, args ...string) (acc *db.Access, err error)

添加权限

func AddMenuToParent

func AddMenuToParent(menu, parent *db.Menu) (err error)

添加子菜单

func CountRows

func CountRows(tableName string, excludeDeleted bool) int

func GetNextWorkday

func GetNextWorkday(t time.Time) (time.Time, bool)

*

  • 找出下一个工作日(不含今天)

func GetUserInfo

func GetUserInfo(user *db.User) map[string]interface{}

func GetUserRoles

func GetUserRoles(user *db.User) (roles []string, err error)

func IsHoliday

func IsHoliday(date string) bool

*

  • 判断是否节假日,日期使用yyyy-mm-dd格式

func NewMenu

func NewMenu(path, title, icon string) *db.Menu

func QueryPermissions

func QueryPermissions(roles ...string) *xorm.Session

func SetCalendarY2019

func SetCalendarY2019(cal *calendar.Calendar) *calendar.Calendar

*

  • 2019年节日调休年历

func SetCalendarY2020

func SetCalendarY2020(cal *calendar.Calendar) *calendar.Calendar

*

  • 2020年节日调休年历

func TruncTable

func TruncTable(tableName string) error

清空表

Types

type CronTimerCluster

type CronTimerCluster struct {
	cron.CronTimer     `json:",inline" xorm:"extends"`
	*base.ClusterMixin `json:"-" xorm:"-"`
}

func NewCronTimerCluster

func NewCronTimerCluster() *CronTimerCluster

func (CronTimerCluster) ResetTable

func (m CronTimerCluster) ResetTable(curr string, trunc bool) error

func (CronTimerCluster) TableName

func (m CronTimerCluster) TableName() string

type GroupSummary

type GroupSummary struct {
	Title  string `json:"title" xorm:"notnull default '' comment('名称') VARCHAR(50)"`
	Remark string `json:"remark" xorm:"comment('说明备注') TEXT"`
}

func (GroupSummary) TableName

func (GroupSummary) TableName() string

type Permission

type Permission struct {
	db.Access `json:",inline" xorm:"extends"`
}

func (Permission) CheckPerm

func (p Permission) CheckPerm(act uint16, url string) bool

type UserAuth

type UserAuth struct {
	*db.User
	auth.IUserAuth
}

func (UserAuth) GetAnonymousOpenUrls

func (a UserAuth) GetAnonymousOpenUrls() []string

获取可公开访问的网址

func (UserAuth) GetLimitedBlackListUrls

func (a UserAuth) GetLimitedBlackListUrls() []string

获取受限用户黑名单中的的网址,与白名单二选一

func (UserAuth) GetLimitedWhiteListUrls

func (a UserAuth) GetLimitedWhiteListUrls() []string

获取受限用户白名单中的的网址,不再检查正常用户权限,与黑名单二选一

func (UserAuth) GetRegularPermissions

func (a UserAuth) GetRegularPermissions(roles []string) (perms []auth.IPermission)

获取正常用户权限可访问的网址

func (UserAuth) GetSuperPermissions

func (a UserAuth) GetSuperPermissions(roles []string) (perms []auth.IPermission)

获取超级用户权限可访问的网址,不再检查正常用户权限

func (UserAuth) GetUserRoles

func (a UserAuth) GetUserRoles() (roles []string, err error)

用户拥有的角色

func (UserAuth) GetUserType

func (a UserAuth) GetUserType() (utype usertype.UserType, err error)

用户分类,无法区分内部用户和普通用户

func (UserAuth) IsStaticResourceUrl

func (a UserAuth) IsStaticResourceUrl(url string) bool

是否静态资源网址

type UserWithGroup

type UserWithGroup struct {
	db.User   `json:",inline" xorm:"extends"`
	PrinGroup *GroupSummary `json:",inline" xorm:"extends"`
	ViceGroup *GroupSummary `json:",inline" xorm:"extends"`
}

Jump to

Keyboard shortcuts

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