apis

package
v0.0.0-...-a33bf99 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2015 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ListLimitMin     = 5
	ListLimitDefault = 30
	ListLimitMax     = 100
)
View Source
const (
	StatusCodeOK            = http.StatusOK
	StatusCodeInternalError = 579

	ErrCodeInvalidRequestBody    = 990101
	ErrCodeInvalidArgs           = 990102
	ErrCodeInvalidJsonObjectType = 990105
)

Variables

View Source
var (
	ErrInternalError = jsonutils.NewAPIError(StatusCodeInternalError, 990103, "internal error")
	ErrInvalidId     = jsonutils.NewAPIError(http.StatusBadRequest, 990104, "invalid id")

	ErrUnauthorized = jsonutils.NewAPIError(http.StatusForbidden, 990201, "unauthorized request")
	ErrUnlogged     = jsonutils.NewAPIError(http.StatusForbidden, 990202, "unlogged")
	ErrAgentOnly    = jsonutils.NewAPIError(http.StatusForbidden, 990203, "for agent only")

	ErrBrandAlreadyInitialized = jsonutils.NewAPIError(http.StatusForbidden, 110101, "brand already initialized")
	ErrBrandNotFound           = jsonutils.NewAPIError(http.StatusBadRequest, 110102, "brand not found")

	ErrAgentNotFound         = jsonutils.NewAPIError(http.StatusBadRequest, 110201, "agent not found")
	ErrAgentPasswordNotMatch = jsonutils.NewAPIError(http.StatusForbidden, 110202, "passwod not match")

	ErrTicketDuplicate = jsonutils.NewAPIError(http.StatusBadRequest, 110301, "ticket with duplicate channel")
	ErrTicketNotFound  = jsonutils.NewAPIError(http.StatusNotFound, 110302, "ticket not found")

	ErrCommentNotFound     = jsonutils.NewAPIError(http.StatusNotFound, 110401, "comment not found")
	ErrCommentUnchangeable = jsonutils.NewAPIError(http.StatusForbidden, 110402, "comment unchangeable")

	ErrUserNotFound = jsonutils.NewAPIError(http.StatusNotFound, 110501, "user not found")

	ErrFocusNotFound       = jsonutils.NewAPIError(http.StatusNotFound, 110601, "focus not found")
	ErrFocusAlreadyHandled = jsonutils.NewAPIError(http.StatusBadRequest, 110602, "focus already handled")

	ErrResourceNotFound = jsonutils.NewAPIError(http.StatusNotFound, 110701, "resource not found")

	ErrFileInternalInvalidToken   = jsonutils.NewAPIError(http.StatusForbidden, 110801, "invalid file token")
	ErrFileInternalInvalidRequest = jsonutils.NewAPIError(http.StatusBadRequest, 110802, "invalid request uploading file")
	ErrFileInternalFileNotFound   = jsonutils.NewAPIError(http.StatusBadRequest, 110803, "uploading file not found")
)
View Source
var (
	ErrExpectingOSFile = fmt.Errorf("expected an *os.File")
)

Functions

func AuthorizedAsAgent

func AuthorizedAsAgent(user *models.User) bool

func AuthorizedAsSpecifiedUser

func AuthorizedAsSpecifiedUser(user *models.User, id bson.ObjectId) bool

func AuthorizedLogged

func AuthorizedLogged(user *models.User) bool

func ChangeSetM

func ChangeSetM(setM map[string]interface{}) helpers.M

func CheckAuthorizedAsAgent

func CheckAuthorizedAsAgent(c *echo.Context) *models.User

func CheckAuthorizedLogged

func CheckAuthorizedLogged(c *echo.Context) *models.User

func CheckValidation

func CheckValidation(v *validation.Validation)

func CurrentUser

func CurrentUser(h echo.HandlerFunc) echo.HandlerFunc

func ErrorInvaidArgsWithMsg

func ErrorInvaidArgsWithMsg(msg string) error

func ErrorInvalidArgType

func ErrorInvalidArgType(name, typeName string) error

func ErrorInvalidRequestBodyWithError

func ErrorInvalidRequestBodyWithError(err error) error

func GetCurrentBrand

func GetCurrentBrand() *models.Brand

func GetCurrentUser

func GetCurrentUser(c *echo.Context) *models.User

func GetCurrentUserFromContext

func GetCurrentUserFromContext(c *echo.Context) (*models.User, error)

func GetJsonArgsFromContext

func GetJsonArgsFromContext(c *echo.Context, args interface{})

func GetLogger

func GetLogger(c *echo.Context) *xlogger.XLogger

func GetMapArgsFromContext

func GetMapArgsFromContext(c *echo.Context) map[string]interface{}

func NowUnix

func NowUnix() int64

func OutputJson

func OutputJson(data interface{}, c *echo.Context) error

func RegisterBaseModule

func RegisterBaseModule(cfg *config.Config, mux *echo.Group)

func RegisterBrandModule

func RegisterBrandModule(cfg *config.Config, mux *echo.Group)

func RegisterFileModule

func RegisterFileModule(cfg *config.Config, mux *echo.Group) error

func RegisterFocusModule

func RegisterFocusModule(cfg *config.Config, mux *echo.Group)

func RegisterProfileModule

func RegisterProfileModule(cfg *config.Config, mux *echo.Group)

func RegisterTicketsModule

func RegisterTicketsModule(cfg *config.Config, mux *echo.Group)

func RegisterUserModule

func RegisterUserModule(cfg *config.Config, mux *echo.Group)

Types

type BaseModule

type BaseModule struct {
	// contains filtered or unexported fields
}

type BrandInitArgs

type BrandInitArgs struct {
	BrandName string `json:"brandName"`
	Name      string `json:"name"`
	Email     string `json:"email"`
	Password  string `json:"password"`
}

type BrandModule

type BrandModule struct {
	// contains filtered or unexported fields
}

type BrandUpdateArgs

type BrandUpdateArgs struct {
	Base models.BrandBaseInfo `json:"base"`
}

brand

type CommentAddArgs

type CommentAddArgs struct {
	Type        string         `json:"type"`
	Content     string         `json:"content"`
	Attachments []*models.File `json:"attachments"`
}

comment

type FileStorager

type FileStorager interface {
	Store(*multipart.FileHeader) (*models.File, error)
}

type FocusAddArgs

type FocusAddArgs struct {
	Priority     models.TypePriority `json:"priority"`
	Message      string              `json:"message"`
	ResourceType string              `json:"resourceType"`
	ResourceId   bson.ObjectId       `json:"resourceId"`
	Duration     int64               `json:"duration"`
}

focus

type FocusModule

type FocusModule struct {
	// contains filtered or unexported fields
}

type InternalFileModule

type InternalFileModule struct {
	// contains filtered or unexported fields
}

type InternalLocalStorager

type InternalLocalStorager struct {
	// contains filtered or unexported fields
}

func (*InternalLocalStorager) Store

func (this *InternalLocalStorager) Store(header *multipart.FileHeader) (*models.File, error)

type ListArgs

type ListArgs struct {
	Limit  int           `json:"limit"`
	Sort   string        `json:"sort"`
	LastId bson.ObjectId `json:"lastId"`
}

func GetListArgsFromRequest

func GetListArgsFromRequest(r *http.Request) *ListArgs

type ListResult

type ListResult struct {
	Count int         `json:"count"`
	Items interface{} `json:"items"`
}

func ListResultNew

func ListResultNew(count int, items interface{}) *ListResult

type ProfileModule

type ProfileModule struct {
	// contains filtered or unexported fields
}

type ProfileUpdateArgs

type ProfileUpdateArgs struct {
	Base models.UserBaseInfo `json:"base"`
}

profile

type SigninArgs

type SigninArgs struct {
	Password string `json:"password"`
}

base

type TicketAddArgs

type TicketAddArgs struct {
	Email       string            `json:"email"`
	Channel     string            `json:"channel`
	Subject     string            `json:"subject"`
	Content     string            `json:"content"`
	Status      string            `json:"status"`
	IsPublic    bool              `json:"isPublic,omitempty"`
	Attachments []*models.File    `json:"attachments"`
	Extend      map[string]string `json:"extend"`
}

ticket

type TicketModule

type TicketModule struct {
	// contains filtered or unexported fields
}

type UserModule

type UserModule struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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