Documentation ¶
Index ¶
- Variables
- func AllSysRoles() []string
- func CurrentUser(t OAuth, u User) *currentUser
- func SetDateFormat(layout string)
- func SetTimeFormat(layout string)
- func SetTimeZone(zone int64)
- type AppError
- func CustomError(statusCode int, root error, msg string, key string) *AppError
- func ErrCannotCreateEntity(entity string, err error) *AppError
- func ErrCannotDeleteEntity(entity string, err error) *AppError
- func ErrCannotGetEntity(entity string, err error) *AppError
- func ErrCannotListEntity(entity string, err error) *AppError
- func ErrCannotUpdateEntity(entity string, err error) *AppError
- func ErrDB(err error) *AppError
- func ErrEntityDeleted(entity string, err error) *AppError
- func ErrEntityExisted(entity string, err error) *AppError
- func ErrEntityNotFound(entity string, err error) *AppError
- func ErrInternal(err error) *AppError
- func ErrInvalidRequest(err error) *AppError
- func ErrNoPermission(err error) *AppError
- func NewCustomError(statusCode int, root error, msg string, key string) *AppError
- func NewErrorResponse(statusCode int, root error, msg, log, key string) *AppError
- func NewFullErrorResponse(statusCode int, root error, msg, log, key string) *AppError
- func NewUnauthorized(root error, msg, key string) *AppError
- type AudioInfo
- type Image
- type Images
- type JSON
- type JSONDate
- type JSONTime
- func (t *JSONTime) GetBSON() (interface{}, error)
- func (t JSONTime) MarshalJSON() ([]byte, error)
- func (t *JSONTime) Scan(value interface{}) error
- func (t *JSONTime) SetBSON(raw bson.Raw) error
- func (t *JSONTime) String() string
- func (t *JSONTime) UnmarshalJSON(data []byte) error
- func (t *JSONTime) Value() (driver.Value, error)
- type Media
- type Medias
- type MgoModel
- type OAuth
- type OrderBy
- type Paging
- type Requester
- type Response
- type SQLModel
- type SQLModelCreate
- type SystemRole
- type UID
- func (uid *UID) GetBSON() (interface{}, error)
- func (uid UID) GetLocalID() uint32
- func (uid UID) GetObjectType() int
- func (uid UID) GetShardID() uint32
- func (uid UID) MarshalJSON() ([]byte, error)
- func (uid *UID) Scan(value interface{}) error
- func (uid *UID) SetBSON(raw bson.Raw) error
- func (uid UID) String() string
- func (uid *UID) UnmarshalJSON(data []byte) error
- func (uid *UID) Value() (driver.Value, error)
- type User
- type Video
- type VideoInfo
- type Videos
Constants ¶
This section is empty.
Variables ¶
View Source
var ( SimpleSuccessResponse = func(data interface{}) Response { return newResponse(http.StatusOK, data, nil, nil) } ResponseWithPaging = func(data, param interface{}, other interface{}) Response { if v, ok := other.(Paging); ok { if v.NextCursor != "" { if !v.CursorIsUID { v.NextCursor = base58.Encode([]byte(v.NextCursor)) } } return newResponse(http.StatusOK, data, param, v) } return newResponse(http.StatusOK, data, param, other) } )
Response helpers
View Source
var ErrRecordNotFound = errors.New("record not found")
Functions ¶
func AllSysRoles ¶
func AllSysRoles() []string
func CurrentUser ¶
func SetTimeFormat ¶
func SetTimeFormat(layout string)
Set time format layout. Default: 2006-01-02T15:04:05.999999-07:00
func SetTimeZone ¶
func SetTimeZone(zone int64)
Types ¶
type AppError ¶
type AppError struct { StatusCode int `json:"status_code"` RootErr error `json:"-"` Message string `json:"message"` Log string `json:"log"` Key string `json:"error_key"` }
func ErrCannotCreateEntity ¶ added in v1.0.3
func ErrCannotDeleteEntity ¶ added in v1.0.3
func ErrCannotGetEntity ¶ added in v1.0.3
func ErrCannotListEntity ¶ added in v1.0.3
func ErrCannotUpdateEntity ¶ added in v1.0.3
func ErrEntityDeleted ¶ added in v1.0.3
func ErrEntityExisted ¶ added in v1.0.3
func ErrEntityNotFound ¶ added in v1.0.3
func ErrInternal ¶ added in v1.0.3
func ErrInvalidRequest ¶
func ErrNoPermission ¶
func NewCustomError ¶ added in v1.0.3
func NewErrorResponse ¶ added in v1.0.3
func NewFullErrorResponse ¶ added in v1.0.3
func NewUnauthorized ¶ added in v1.0.3
type AudioInfo ¶
type AudioInfo struct { Codec string `json:"codec" bson:"codec,omitempty"` BitRate string `json:"bit_rate" bson:"bit_rate,omitempty"` Frequency int `json:"frequency" bson:"frequency,omitempty"` Channels int `json:"channels" bson:"channels,omitempty"` ChannelLayout string `json:"channel_layout" bson:"channel_layout,omitempty"` }
type Image ¶
type Image struct { ID uint32 `json:"img_id,omitempty" bson:"img_id,omitempty"` FakeID *UID `json:"id,omitempty" bson:"-"` Url string `json:"url" bson:"url"` FileName string `json:"file_name,omitempty" bson:"file_name,omitempty"` OriginWidth int `json:"org_width" bson:"org_width"` OriginHeight int `json:"org_height" bson:"org_height"` OriginUrl string `json:"org_url" bson:"org_url"` CloudName string `json:"cloud_name,omitempty" bson:"cloud_name"` CloudId string `json:"cloud_id,omitempty" bson:"cloud_id"` DominantColor string `json:"dominant_color" bson:"dominant_color"` RequestId string `json:"request_id,omitempty" bson:"-"` FileSize uint32 `json:"file_size,omitempty" bson:"-"` }
func (*Image) HideSomeInfo ¶
type Images ¶
type Images []Image
type JSON ¶
type JSON []byte
func (*JSON) MarshalJSON ¶
func (*JSON) UnmarshalJSON ¶
type JSONDate ¶
func (JSONDate) MarshalJSON ¶
Implement method MarshalJSON to output date with in formatted
func (*JSONDate) UnmarshalJSON ¶
type JSONTime ¶
func (JSONTime) MarshalJSON ¶
Implement method MarshalJSON to output time with in formatted
func (*JSONTime) UnmarshalJSON ¶
type Media ¶
type Media struct { ID uint32 `json:"img_id,omitempty" bson:"img_id,omitempty"` FakeID *UID `json:"id,omitempty" bson:"-"` Type string `json:"type" bson:"type,omitempty"` Url string `json:"url" bson:"url,omitempty"` OriginWidth int `json:"org_width" bson:"org_width,omitempty"` OriginHeight int `json:"org_height" bson:"org_height,omitempty"` OriginUrl string `json:"org_url,omitempty" bson:"org_url,omitempty"` FileName string `json:"file_name,omitempty" bson:"file_name,omitempty"` CloudName string `json:"cloud_name,omitempty" bson:"cloud_name,omitempty"` CloudId string `json:"cloud_id,omitempty" bson:"cloud_id,omitempty"` DominantColor string `json:"dominant_color,omitempty" bson:"dominant_color,omitempty"` RequestId string `json:"request_id,omitempty" bson:"-"` FileSize uint32 `json:"file_size,omitempty" bson:"-"` Format string `json:"format,omitempty" bson:"format,omitempty"` Thumbnail *Image `json:"thumbnail,omitempty" bson:"thumbnail,omitempty"` Audio *AudioInfo `json:"audio,omitempty" bson:"audio,omitempty"` Video *VideoInfo `json:"video,omitempty" bson:"video,omitempty"` FrameRate float64 `json:"frame_rate,omitempty" bson:"frame_rate,omitempty"` BitRate int `json:"bit_rate,omitempty" bson:"bit_rate,omitempty"` Duration float64 `json:"duration,omitempty" bson:"duration,omitempty"` }
type MgoModel ¶
type MgoModel struct { PK bson.ObjectId `json:"id" bson:"_id,omitempty"` Status int `json:"status" bson:"status,omitempty"` CreatedAt *JSONTime `json:"created_at" bson:"created_at,omitempty"` UpdatedAt *JSONTime `json:"updated_at" bson:"updated_at,omitempty"` DeletedAt *JSONTime `json:"deleted_at" bson:"deleted_at,omitempty"` }
func (*MgoModel) PrepareForInsert ¶
type Paging ¶
type Paging struct { Cursor *UID `json:"-" form:"-"` NextCursor string `json:"next_cursor" form:"-"` CursorStr string `json:"cursor" form:"cursor"` Limit int `json:"limit" form:"limit"` Total int `json:"total" form:"-"` Page int `json:"page" form:"page"` HasNext bool `json:"has_next" form:"-"` OrderBy string `json:"-" form:"-"` OB []OrderBy `json:"-" form:"-"` CursorIsUID bool `json:"-" form:"-"` }
type Response ¶
type Response struct { Code int `json:"code"` Data interface{} `json:"data"` Param interface{} `json:"param,omitempty"` Paging interface{} `json:"paging,omitempty"` }
type SQLModel ¶
type SQLModel struct { // Real id in db, we would't show it ID uint32 `json:"-" gorm:"id,PRIMARY_KEY"` // Fake id, we will public it FakeID UID `json:"id" gorm:"-"` Status *int `json:"status,omitempty" gorm:"column:status;default:1;"` CreatedAt *JSONTime `json:"created_at,omitempty;" gorm:"column:created_at;"` UpdatedAt *JSONTime `json:"updated_at,omitempty;" gorm:"column:updated_at;"` }
For reading
func NewSQLModelWithStatus ¶
type SQLModelCreate ¶
type SQLModelCreate struct { // Real id in db, we would't show it ID uint32 `json:"-" gorm:"id,PRIMARY_KEY"` // Fake id, we will public it FakeID UID `json:"id" gorm:"-"` Status int `json:"status,omitempty" gorm:"column:status;default:1;"` CreatedAt *JSONTime `json:"created_at,omitempty;" gorm:"column:created_at;"` UpdatedAt *JSONTime `json:"updated_at,omitempty;" gorm:"column:updated_at;"` }
For creating
func NewSQLModelCreateWithStatus ¶
func NewSQLModelCreateWithStatus(status int) SQLModelCreate
func (*SQLModelCreate) GenUID ¶
func (sm *SQLModelCreate) GenUID(objType int, shardID uint32)
type SystemRole ¶
type SystemRole int
const ( SysRoleRoot SystemRole = iota SysRoleAdmin SysRoleModerator SysRoleUser SysRoleGuest )
func ParseSystemRole ¶
func ParseSystemRole(role string) SystemRole
func (SystemRole) String ¶
func (sr SystemRole) String() string
type UID ¶
type UID struct {
// contains filtered or unexported fields
}
func DecomposeUID ¶
func FromBase58 ¶
func (UID) GetLocalID ¶
func (UID) GetObjectType ¶
func (UID) GetShardID ¶
func (UID) MarshalJSON ¶
func (*UID) UnmarshalJSON ¶
type Video ¶
type Video struct { ID uint32 `json:"img_id,omitempty" bson:"img_id,omitempty"` FakeID *UID `json:"id,omitempty" bson:"-"` Url string `json:"url" bson:"url"` OriginWidth int `json:"org_width" bson:"org_width"` OriginHeight int `json:"org_height" bson:"org_height"` OriginUrl string `json:"org_url" bson:"org_url"` CloudName string `json:"cloud_name,omitempty" bson:"cloud_name"` CloudId string `json:"cloud_id,omitempty" bson:"cloud_id"` DominantColor string `json:"dominant_color" bson:"dominant_color"` RequestId string `json:"request_id,omitempty" bson:"-"` FileSize uint32 `json:"file_size,omitempty" bson:"-"` Format string `json:"format,omitempty"` Audio AudioInfo `json:"audio"` Video VideoInfo `json:"video"` FrameRate float64 `json:"frame_rate"` BitRate int `json:"bit_rate"` Duration float64 `json:"duration"` }
func (*Video) HideSomeInfo ¶
Click to show internal directories.
Click to hide internal directories.