Documentation ¶
Index ¶
- Constants
- Variables
- func AutoMigrate(db *gorm.DB) error
- func Connect(conf *conf.DBConfiguration, logger *zap.Logger) (*gorm.DB, error)
- func SendJSON(w http.ResponseWriter, apiMsg *APIMessage) error
- type APIMessage
- type Auth
- type DBLogger
- type Org
- type OrgApp
- type OrgUser
- type SignLog
- type SignLogs
- type User
Constants ¶
View Source
const ( ErrNil = "0" ErrInternal = "1000" ErrInvalidAccount = "2000" ErrInvalidPassword = "2001" ErrInvalidToken = "2002" ErrOccupiedAccount = "2003" ErrNilAccount = "2004" ErrInvalidOrgJoinCode = "3001" ErrOrgUnActivated = "3002" ErrInvalidOrg = "3003" )
common used error code
Variables ¶
View Source
var ErrText = map[string]string{ ErrNil: "api call succeeded", ErrInvalidAccount: "invalid account", ErrInvalidPassword: "invalid password", ErrInvalidToken: "invalid token", ErrOccupiedAccount: "account already occupied", ErrNilAccount: "account doesn't exist", ErrInvalidOrgJoinCode: "invalid org join code", ErrOrgUnActivated: "org has not been activated yet", ErrInvalidOrg: "org invalid", }
ErrText error text
Functions ¶
func SendJSON ¶
func SendJSON(w http.ResponseWriter, apiMsg *APIMessage) error
SendJSON handle rest api returns
Types ¶
type APIMessage ¶
type APIMessage struct { HTTPCode int `json:"-"` Code string `json:"code"` RequestID string `json:"-"` Message string `json:"message"` Payload interface{} `json:"payload"` InternalError error `json:"-"` InternalMessage string `json:"-"` }
APIMessage the rest api response message
func NewAPIError ¶
func NewAPIError(code string, msgFmt string, args ...interface{}) *APIMessage
NewAPIError construct result for a successful api call, but the result is invalid
func NewAPIResult ¶
func NewAPIResult(code string, obj interface{}, msgFmt string, args ...interface{}) *APIMessage
NewAPIResult construct result for a successful api call, but the result is valid
func NewHTTPError ¶
func NewHTTPError(httpCode int, code string, msgFmt string, args ...interface{}) *APIMessage
NewHTTPError construct an api error
func (*APIMessage) Error ¶
func (e *APIMessage) Error() string
func (*APIMessage) WithInternalError ¶
func (e *APIMessage) WithInternalError(err error) *APIMessage
WithInternalError adds internal error information to the error
func (*APIMessage) WithInternalMessage ¶
func (e *APIMessage) WithInternalMessage(fmtString string, args ...interface{}) *APIMessage
WithInternalMessage adds internal message information to the error
type Auth ¶
type Auth struct { UserID int64 SignOrg string `gorm:"-"` Provider string UID string Password string ID int64 CreateUser int64 UpdateUser int64 CreateTime time.Time UpdateTime time.Time DeleteTime *time.Time SignLogs }
Auth is the persistent model of auth
func (Auth) ToRefreshClaims ¶
ToRefreshClaims convert to refresh-token Claims
type DBLogger ¶
DBLogger logger for database operations
func NewDBLogger ¶
NewDBLogger create new database logger
type Org ¶
type Org struct { ID int64 UID string JoinCode string Nickname string Verified bool Activated bool RealName string CreateUser int64 UpdateUser int64 CreateTime time.Time UpdateTime time.Time DeleteTime *time.Time }
Org org represents tenant
type OrgApp ¶
type OrgApp struct { ID int64 AppUID string PackageUID string `gorm:"column:package_uid"` UserID int64 OrgID int64 `gorm:"index:ORG_ID"` CreateUser int64 UpdateUser int64 CreateTime time.Time UpdateTime time.Time DeleteTime *time.Time }
OrgApp org-app relations
type OrgUser ¶
type OrgUser struct { ID int64 OrgID int64 UserID int64 RoleCode string CreateUser int64 UpdateUser int64 CreateTime time.Time UpdateTime time.Time DeleteTime *time.Time }
OrgUser org-user relations
Click to show internal directories.
Click to hide internal directories.