enums

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareStringList

func CompareStringList(x string, lst []string, cmp StrCmp) bool

是否在字符串列表中

func CompareSubsetLength

func CompareSubsetLength(lst1, lst2 []string, strict bool) bool

比较两个列表的长度

func CompareSubsetList

func CompareSubsetList(lst1, lst2 []string, cmp StrCmp, strict bool) bool

lst1 是否 lst2 的(真)子集

func ContainPermit

func ContainPermit(admission, permit int, strict bool) bool

func EndStringList

func EndStringList(x string, lst []string) bool

是否在字符串列表中,比较方式是有任何一个开头符合

func InStringList

func InStringList(x string, lst []string) bool

是否在字符串列表中

func IsNoop

func IsNoop(permit int) bool

func IsSubsetList

func IsSubsetList(lst1, lst2 []string, strict bool) bool

lst1 是否 lst2 的(真)子集

func MatchString

func MatchString(a, b string, cmp StrCmp) bool

比较是否相符

func MatchStringList

func MatchStringList(x string, lst []string, cmp StrCmp) bool

是否在字符串列表中,主要适用于 strcmp.Contains 和 strcmp.EndsWith

func SearchStringList

func SearchStringList(x string, lst []string, cmp StrCmp) bool

是否在字符串列表中,仅适用于 strcmp.Equal 和 strcmp.StartsWith

func StartStringList

func StartStringList(x string, lst []string) bool

是否在字符串列表中,比较方式是有任何一个开头符合

Types

type Permit

type Permit int
const (
	View   Permit = 2 << iota // 查看详情
	Draft                     // 草稿状态
	Delete                    // 删除丢弃
	Add                       // 新增添加
	Edit                      // 编辑修改
	Export                    // 导出下载

	Noop  Permit = 0 // 无操作
	Batch Permit = 1 // 批量处理
)

操作列表

func DividePermit

func DividePermit(permit int) (codes []Permit, names []string)

分解出具体权限

func PermitString

func PermitString(s string) (Permit, error)

PermitString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func PermitValues

func PermitValues() []Permit

PermitValues returns all values of the enum

func (Permit) IsAPermit

func (i Permit) IsAPermit() bool

IsAPermit returns "true" if the value is listed in the enum definition. "false" otherwise

func (Permit) MarshalText

func (i Permit) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for Permit

func (Permit) String

func (i Permit) String() string

func (*Permit) UnmarshalText

func (i *Permit) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for Permit

type SqlJoin

type SqlJoin int
const (
	Join SqlJoin = iota
	InnerJoin
	OuterJoin
	CrossJoin

	LeftJoin SqlJoin = iota
	LeftInnerJoin
	LeftOuterJoin

	RightJoin SqlJoin = iota + 1
	RightInnerJoin
	RightOuterJoin
)

数据表联接

func SqlJoinString

func SqlJoinString(s string) (SqlJoin, error)

SqlJoinString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func SqlJoinValues

func SqlJoinValues() []SqlJoin

SqlJoinValues returns all values of the enum

func (SqlJoin) IsASqlJoin

func (i SqlJoin) IsASqlJoin() bool

IsASqlJoin returns "true" if the value is listed in the enum definition. "false" otherwise

func (SqlJoin) MarshalText

func (i SqlJoin) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for SqlJoin

func (SqlJoin) String

func (i SqlJoin) String() string

func (SqlJoin) Subject

func (i SqlJoin) Subject() string

func (*SqlJoin) UnmarshalText

func (i *SqlJoin) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for SqlJoin

type StrCmp

type StrCmp int
const (
	Omit            StrCmp = iota // 不比较
	Contains                      // 包含
	StartsWith                    // 打头
	EndsWith                      // 结尾
	CaseInsensitive               // 不分大小写
	IgnoreSpaces                  // 忽略空格
	Equal                         // 相等
)

字符串比较方式

func StrCmpString

func StrCmpString(s string) (StrCmp, error)

StrCmpString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func StrCmpValues

func StrCmpValues() []StrCmp

StrCmpValues returns all values of the enum

func (StrCmp) IsAStrCmp

func (i StrCmp) IsAStrCmp() bool

IsAStrCmp returns "true" if the value is listed in the enum definition. "false" otherwise

func (StrCmp) MarshalText

func (i StrCmp) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for StrCmp

func (StrCmp) String

func (i StrCmp) String() string

func (*StrCmp) UnmarshalText

func (i *StrCmp) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for StrCmp

type UserType

type UserType int
const (
	Anonymous UserType = iota // 匿名用户(未登录/未注册)
	Forbidden                 // 封禁用户(有违规被封号)
	Limited                   // 受限用户(未过审或被降级)
	Regular                   // 正常用户(正式会员)
	Super                     // 超级用户(后台管理权限)
)

用户分类

func UserTypeString

func UserTypeString(s string) (UserType, error)

UserTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func UserTypeValues

func UserTypeValues() []UserType

UserTypeValues returns all values of the enum

func (UserType) IsAUserType

func (i UserType) IsAUserType() bool

IsAUserType returns "true" if the value is listed in the enum definition. "false" otherwise

func (UserType) MarshalText

func (i UserType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for UserType

func (UserType) String

func (i UserType) String() string

func (*UserType) UnmarshalText

func (i *UserType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for UserType

Jump to

Keyboard shortcuts

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