objects

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: LGPL-2.1 Imports: 5 Imported by: 1

README

yuanmai-objects-go

yuanmai platform golang types

Documentation

Index

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

func GetUser

func GetUser[USER User](ctx context.Context) (USER, bool)

func WithUser

func WithUser[USER User](ctx context.Context, user USER) context.Context

Types

type Date

type Date time.Time

func (Date) MarshalJSON

func (this Date) MarshalJSON() ([]byte, error)

func (*Date) Scan

func (t *Date) Scan(value interface{}) error

func (*Date) UnmarshalJSON

func (td *Date) UnmarshalJSON(b []byte) error

func (Date) Value

func (t Date) Value() (driver.Value, error)

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 District struct {
	Name     string     `json:"name"`
	Level    string     `json:"level"`
	AdCode   string     `json:"adCode"`
	CityCode string     `json:"cityCode"`
	Geo      []string   `json:"geo"`
	Children []District `json:"children"`
}

func (*District) Find

func (d *District) Find(cityCode string) []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 Location

type Location struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Province  string  `json:"province"`
	City      string  `json:"city"`
	County    string  `json:"county"`
	District  string  `json:"district"`
}
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
)

func (OAuthType) String

func (t OAuthType) String() string

String returns the string representation of the OAuth type.

type OAuthUser

type OAuthUser struct {
	Id[uint]   `mapstructure:",squash"`
	UserId     int32     `json:"userId"`
	Type       OAuthType `json:"oAuthType"`
	OAuthId    string    `json:"OAuthId"`
	Unionid    string    `json:"unionid"`
	Credential string    `json:"credential"`
}

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"`
}

func (*Operator) Name

func (o *Operator) Name() string

Name returns the name of the operator.

func (*Operator) String

func (o *Operator) String() string

String returns the string representation of the operator.

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 Permisson

type Permisson struct {
	Id[uint]
	Type        int32  `json:"type"`
	Name        string `json:"name"`
	Code        string `json:"code"`
	Target      string `json:"target"`
	Description string `json:"description"`
	Path        string `json:"path"`
}

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 R[T any] struct {
	Code    int    `json:"code"`
	Error   bool   `json:"error"`
	Key     string `json:"key,omitempty"`
	Message string `json:"message,omitempty"`
	Data    T      `json:"data,omitempty"`
}

func R_

func R_[T any](data T) *R[T]

R_ 自定义成功

func R__

func R__[T any](code int, message string) *R[T]

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 Role

type Role struct {
	Id[uint]
	ParentId int32                  `json:"parentId"`
	Region   int32                  `json:"region"`
	Name     string                 `json:"name"`
	Code     string                 `json:"code"`
	PermIds  []int32                `json:"permIds"`
	Perms    []Permisson            `json:"perms"`
	Ext      map[string]interface{} `json:"ext"`
}

type TimeDateCN

type TimeDateCN time.Time

func (TimeDateCN) MarshalJSON

func (this TimeDateCN) MarshalJSON() ([]byte, error)

type TimeDateMinute

type TimeDateMinute time.Time

func (TimeDateMinute) MarshalJSON

func (this TimeDateMinute) MarshalJSON() ([]byte, error)

type TimeDateTime

type TimeDateTime time.Time

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

func (TimeDateTime) Value

func (t TimeDateTime) Value() (driver.Value, 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 (ct *TimeX) MarshalJSON() ([]byte, error)

func (*TimeX) UnmarshalJSON

func (ct *TimeX) UnmarshalJSON(b []byte) error

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"`
}

type UserInfo

type UserInfo struct {
	*User     `mapstructure:",squash"` // 匿名字段
	RoleCodes []string                 `json:"roleCodes"`
	OAuths    *[]OAuthUser             `json:"oauths"`
}

func Anonymous

func Anonymous() *UserInfo

Anonymous returns the ANONYMOUS user info.

func (*UserInfo) IsAnonymous

func (u *UserInfo) IsAnonymous() bool

IsAnonymous returns true if the user info is anonymous.

func (*UserInfo) Of

func (u *UserInfo) Of() *Operator

Of returns the operator for the user info.

Jump to

Keyboard shortcuts

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