Documentation ¶
Index ¶
Constants ¶
View Source
const DB = "db"
Variables ¶
View Source
var ( // ErrNotSupported 未实现/不支持 ErrNotSupported = errors.New("not supported") // ErrLoginClaim 登录失败 ErrLoginClaim = errors.New("not valid subject") ErrUnauthorized = errors.New("unauthorized") // ErrParamFormat 参数校验失败 ErrParamFormat = errors.New("not valid param") // ErrInvalidUser 用户校验失败 ErrInvalidUser = errors.New("invalid user") //ErrRecordNotNew 不是新记录 ErrRecordNotNew = errors.New("record not new") // ErrRecordNotFound returns a "record not found error". ErrRecordNotFound = errors.New("record not found") // ErrInvalidSQL occurs when you attempt a query with invalid SQL ErrInvalidSQL = errors.New("invalid SQL") // ErrInvalidTransaction occurs when you are trying to `Commit` or `Rollback` ErrInvalidTransaction = errors.New("no valid transaction") // ErrCantStartTransaction can't start transaction when you are trying to start one with `Begin` ErrCantStartTransaction = errors.New("can't start transaction") // ErrUnaddressable unaddressable value ErrUnaddressable = errors.New("using unaddressable value") // ErrUnKnown Error UnKnown ErrUnKnown = errors.New("UnKnown Error") )
Functions ¶
func NewRichError ¶
Types ¶
type DataSource ¶
type DataSource struct { Dialect string `yaml:"dialect"` //数据库类型 Server string `yaml:"server"` ////数据库地址 Port int `yaml:"port"` //数据库端口 Database string `yaml:"database"` //数据库名称 Username string `yaml:"username"` //数据库用户名 Password string `yaml:"password"` //数据库密码 }
DataSource 数据源
type Entity ¶
type Entity struct { CreatedAt times.PrettyTime `json:"CreatedAt" gorm:"COLUMN:created_at"` //创建时间 CreatedBy *int64 `json:"CreatedBy" gorm:"COLUMN:created_by"` //创建者 UpdatedAt times.PrettyTime `json:"UpdatedAt" gorm:"COLUMN:updated_at"` //修改时间 UpdatedBy *int64 `json:"UpdatedBy" gorm:"COLUMN:updated_by"` //修改者 DeletedAt gorm.DeletedAt `json:"DeletedAt,omitempty" gorm:"COLUMN:deleted_at"` //删除时间 DeletedBy *int64 `json:"DeletedBy,omitempty" gorm:"COLUMN:deleted_by"` //删除者 Remark *string `json:"Remark,omitempty" gorm:"COLUMN:remark"` //备注 }
Entity 实体类基本模型
type Errors ¶
type Errors []error
Errors contains all happened errors
type License ¶
type License struct { Signature string `yaml:"signature"` Payload `yaml:",inline" mapstructure:",squash"` //mapstructure 用于viper嵌入结构体 }
License 授权信息
type Model ¶
type Model struct { CreatedAt times.PrettyTime `json:"CreatedAt" gorm:"COLUMN:created_at"` //创建时间 CreatedBy *string `json:"CreatedBy" gorm:"COLUMN:created_by"` //创建者 UpdatedAt times.PrettyTime `json:"UpdatedAt" gorm:"COLUMN:updated_at"` //修改时间 UpdatedBy *string `json:"UpdatedBy" gorm:"COLUMN:updated_by"` //修改者 DeletedAt gorm.DeletedAt `json:"DeletedAt,omitempty" gorm:"COLUMN:deleted_at"` //删除时间 DeletedBy *string `json:"DeletedBy,omitempty" gorm:"COLUMN:deleted_by"` //删除者 Remark *string `json:"Remark,omitempty" gorm:"COLUMN:remark"` //备注 }
Model 实体类基本模型
type Payload ¶
type Payload struct { Uid string `json:"uid" yaml:"uid"` //产品码 Product string `json:"product" yaml:"product"` //产品 Version string `json:"version" yaml:"version"` //版本 Company string `json:"company" yaml:"company"` //公司 Expire string `json:"expire" yaml:"expire"` //过期时间 Random string `json:"random" yaml:"random"` //随机数 }
Payload 载荷
type RestResult ¶
type RestResult struct { Code uint `json:"code"` Message string `json:"message"` Data any `json:"data"` }
func AdaptData ¶
func AdaptData(data any, err error) RestResult
func Error ¶
func Error(err error, data any) RestResult
func Fail ¶
func Fail(message string, data any) RestResult
func Success ¶
func Success(data any) RestResult
type SensitiveString ¶
type SensitiveString struct {
Sensitive string
}
SensitiveString 敏感信息 ******** ⬛🈲㊙🚫🔒㊙
func (SensitiveString) MarshalJSON ¶
func (t SensitiveString) MarshalJSON() ([]byte, error)
MarshalJSON 写入json时会调用 隐藏敏感数据
func (*SensitiveString) Scan ¶
func (t *SensitiveString) Scan(v any) error
Scan 读取数据库时会调用 valueof 注意是指针类型 method
func (SensitiveString) String ¶
func (t SensitiveString) String() string
func (*SensitiveString) UnmarshalJSON ¶
func (t *SensitiveString) UnmarshalJSON(data []byte) error
UnmarshalJSON 读取json时会调用 序列化为string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.