Documentation
¶
Index ¶
- Constants
- Variables
- func GetUser[USER User](ctx context.Context) (USER, bool)
- func WithUser[USER User](ctx context.Context, user USER) context.Context
- type Date
- type Department
- type District
- type Id
- type Location
- type Menu
- type OAuthType
- type OAuthUser
- type Operator
- type Organization
- type Permisson
- type PrivilegeInfo
- type R
- type Region
- type Role
- type TimeDateCN
- type TimeDateMinute
- type TimeDateTime
- type TimeFormat
- type TimeX
- type User
- type UserInfo
Constants ¶
View Source
const ( DATE_FORMAT_DATE = "2006-01-02" DATE_FORMAT_DATETIME = "2006-01-02 15:04:05" DATE_FORMAT_DATEMINUTE = "2006-01-02 15:04" DATE_FORMAT_DATE_CN = "2006年01月02日" DATE_FORMAT_MINIFY_DATE = "20060102" DATE_FORMAT_MINIFY_MONTH = "200601" DATE_MINIFY_FORMAT_DATETIME = "20060102150405" )
Variables ¶
View Source
var ANONYMOUS = UserInfo{}
View Source
var OPER_SYS = Operator{
ID: 0,
UserName: "sys",
Type: 99,
RealName: "系统",
Email: "downloadxu@163.com",
Mobile: "15333819906",
NickName: "sys",
}
SYS is a special operator that represents the system.
Functions ¶
Types ¶
type Department ¶
type Department struct { Id[uint] ParentId int32 `json:"parentId"` Parent *Department `json:"parent"` Name string `json:"name"` Code string `json:"code"` Icon string `json:"icon"` PathIds []string `json:"pathIds"` Paths []string `json:"paths"` Level int32 `json:"level"` Manager bool `json:"manager"` Childs []Department `json:"children"` }
type District ¶
type Id ¶
type Id[ID comparable] struct { ID ID `json:"id" gorm:"column:id;primaryKey;autoIncrement;not null" mapstructure:"id"` Creater string `json:"creater,omitempty" gorm:"column:creater" ` Updater string `json:"updater,omitempty" gorm:"column:updater"` Deleted bool `json:"deleted" gorm:"column:deleted;default:false"` CreatedAt TimeDateTime `json:"createdAt,omitempty" gorm:"column:created_at" mapstructure:"createdAt"` UpdatedAt TimeDateTime `json:"updatedAt,omitempty" gorm:"column:updated_at" mapstructure:"updatedAt"` }
type Menu ¶
type Menu struct { Id[uint] `mapstructure:",squash"` ParentId int32 `json:"parentId"` Region string `json:"region"` Name string `json:"name"` Code string `json:"code"` Target string `json:"target"` Path string `json:"path"` Icon string `json:"icon"` Enable bool `json:"enable"` Depth int32 `json:"depth"` Reamrk string `json:"reamrk"` Ext map[string]interface{} `json:"ext"` Sort int32 `json:"sort"` Childs []Menu `json:"childs"` }
type OAuthType ¶
type OAuthType int32
OAuthType represents the type of OAuth provider.
const ( // UNKNOWN represents an unknown OAuth provider. UNKNOWN OAuthType = 0 // WEIXIN represents the WeChat public account OAuth provider. WEIXIN OAuthType = 1 // WEIXIN_MINIAPP represents the WeChat mini program OAuth provider. WEIXIN_MINIAPP OAuthType = 2 // QQ represents the QQ OAuth provider. QQ OAuthType = 3 // ALIPAY represents the Alipay OAuth provider. ALIPAY OAuthType = 4 // TAOBAO represents the Taobao OAuth provider. TAOBAO OAuthType = 5 // WEIBO represents the Weibo OAuth provider. WEIBO OAuthType = 6 // JPUSH represents the JPush OAuth provider. JPUSH OAuthType = 7 // APPLE represents the Apple OAuth provider. APPLE OAuthType = 8 // ALLINPAY represents the Allinpay OAuth provider. ALLINPAY OAuthType = 9 // ALLINPAY_SUB represents the Allinpay sub account OAuth provider. ALLINPAY_SUB OAuthType = 901 // WEIXIN_MOBILE represents the WeChat mobile OAuth provider. WEIXIN_MOBILE OAuthType = 11 // WEIXIN_H5 represents the WeChat H5 OAuth provider. WEIXIN_H5 OAuthType = 12 // YUNXIN represents the NetEase Yunxin OAuth provider. YUNXIN OAuthType = 13 )
type Operator ¶
type Operator struct { ID uint `json:"id"` OrgId int32 `json:"orgId"` RoleId int32 `json:"roleId"` Type int32 `json:"type"` UserName string `json:"userName"` RealName string `json:"realName"` NickName string `json:"nickName"` Mobile string `json:"mobile"` Email string `json:"email"` Avatar string `json:"avatar"` }
type Organization ¶
type Organization struct { Id[uint] ParentId int32 `json:"parentId"` Name string `json:"name"` Code string `json:"code"` Icon string `json:"icon"` PathIds []string `json:"pathIds"` Paths []string `json:"paths"` Path string `json:"path"` PathId string `json:"pathId"` Level int32 `json:"level"` Areas []Region `json:"areas"` Childs []Organization `json:"children"` ChildIds []int32 `json:"childIds"` }
type PrivilegeInfo ¶
type PrivilegeInfo struct { Id[uint] UserName string `json:"userName"` Mobile string `json:"mobile"` Email string `json:"email"` NickName string `json:"nickName"` RealName string `json:"realName"` Avatar string `json:"avatar"` Type int32 `json:"type"` Gender int32 `json:"gender"` Source int32 `json:"source"` RoleIds []int32 `json:"roleIds"` PermIds []int32 `json:"permIds"` Roles []string `json:"roles"` Permissions []string `json:"permissions"` OrgId int32 `json:"orgId"` }
func (*PrivilegeInfo) Fill ¶
func (p *PrivilegeInfo) Fill(user *User, roles []string, permissions []string) *PrivilegeInfo
Fill fills the privilege info with the given user information, roles, and permissions.
type R ¶
type Region ¶
type Region struct { ProvinceId string `json:"provinceId"` Province string `json:"province"` CityId string `json:"cityId"` City string `json:"city"` County string `json:"county"` CountyId string `json:"countyId"` District string `json:"district"` Town string `json:"town"` TownId string `json:"townId"` Village string `json:"village"` Geo []string `json:"geo"` Address string `json:"address"` }
type TimeDateCN ¶
func (TimeDateCN) MarshalJSON ¶
func (this TimeDateCN) MarshalJSON() ([]byte, error)
type TimeDateMinute ¶
func (TimeDateMinute) MarshalJSON ¶
func (this TimeDateMinute) MarshalJSON() ([]byte, error)
type TimeDateTime ¶
func (TimeDateTime) MarshalJSON ¶
func (this TimeDateTime) MarshalJSON() ([]byte, error)
func (*TimeDateTime) Scan ¶
func (t *TimeDateTime) Scan(value interface{}) error
func (*TimeDateTime) UnmarshalJSON ¶
func (td *TimeDateTime) UnmarshalJSON(b []byte) error
type TimeFormat ¶
type TimeFormat struct {
Layout string
}
func (*TimeFormat) MarshalTime ¶
func (tf *TimeFormat) MarshalTime(t time.Time) ([]byte, error)
func (*TimeFormat) UnmarshalTime ¶
func (tf *TimeFormat) UnmarshalTime(b []byte) (time.Time, error)
type TimeX ¶
type TimeX struct { Time time.Time Format *TimeFormat }
func (*TimeX) MarshalJSON ¶
func (*TimeX) UnmarshalJSON ¶
type User ¶
type User struct { Id[uint] `mapstructure:",squash"` Type int32 `json:"type"` OrgId int32 `json:"orgId"` RoleId int32 `json:"roleId"` RealName string `json:"realName"` Avatar string `json:"avatar"` UserName string `json:"userName"` NickName string `json:"nickName"` Mobile string `json:"mobile"` Email string `json:"email"` Password string `json:"password"` Salt string `json:"salt"` Status int32 `json:"status"` FirstLogin bool `json:"firstLogin" gorm:"default:false"` Merge bool `json:"merge" gorm:"default:false"` Use2FA bool `json:"use2FA" gorm:"default:false"` Secret2FA bool `json:"-"` Verified bool `json:"verified"` Gender int32 `json:"gender"` Source int32 `json:"source"` Lanaguage string `json:"lanaguage"` Anonymous bool `json:"anonymous"` }
Click to show internal directories.
Click to hide internal directories.