init repo

This commit is contained in:
VaalaCat
2024-08-28 00:02:28 +08:00
committed by vaalacat
commit 13148b95e3
97 changed files with 10214 additions and 0 deletions

17
defs/entity.go Normal file
View File

@@ -0,0 +1,17 @@
package defs
type User struct {
UserID string `json:"user_id"`
Name string `json:"name"`
Username string `json:"username"`
Email string `json:"email"`
IsPrivateEmail bool `json:"is_private_email"`
EmailVerified bool `json:"email_verified"`
// Tenants []Tenant
}
// type Tenant struct {
// ID string `json:"id"`
// Name string `json:"name"`
// Description string `json:"description"`
// }

23
defs/request.go Normal file
View File

@@ -0,0 +1,23 @@
package defs
type CommonRequest struct {
Extra interface{} `json:"extra,omitempty"`
}
type CommonPaginationRequest struct {
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Extra interface{} `json:"extra,omitempty"`
}
type CommonQueryRequest struct {
Query string `json:"query,omitempty"`
Extra interface{} `json:"extra,omitempty"`
}
type CommonQueryPaginationRequest struct {
Query string `json:"query,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Extra interface{} `json:"extra,omitempty"`
}

37
defs/response.go Normal file
View File

@@ -0,0 +1,37 @@
package defs
const (
RespCode_SUCCESS = RespCode(0)
RespCode_ERROR = RespCode(1)
RespCode_UNAUTHORIZED = RespCode(2)
RespCode_INVALID = RespCode(3)
)
const (
RespMessage_SUCCESS = RespMsg("success")
RespMessage_ERROR = RespMsg("error")
RespMessage_UNAUTHORIZED = RespMsg("unauthorized")
RespMessage_INVALID = RespMsg("invalid")
)
type RespCode int
type RespMsg string
type Status struct {
Code RespCode `json:"code"`
Message RespMsg `json:"message"`
}
type CommonResponse struct {
Status *Status `json:"status"`
}
type GetUserInfoResponse struct {
Status *Status `json:"status"`
User *User `json:"user"`
}
type GetUserAuthTokenResponse struct {
Status *Status `json:"status"`
Token string `json:"token"`
}

11
defs/user_info.go Normal file
View File

@@ -0,0 +1,11 @@
package defs
type UserGettable interface {
GetUserID() string
GetName() string
GetUsername() string
GetEmail() string
GetIsPrivateEmail() bool
GetEmailVerified() bool
ToUser() User
}