controllers

package
v0.6.0-beta.20210715 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: BSD-3-Clause Imports: 38 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ControllerIdNode = iota
	ControllerIdProject
	ControllerIdSpider
	ControllerIdTask
	ControllerIdJob
	ControllerIdSchedule
	ControllerIdUser
	ControllerIdSetting
	ControllerIdToken
	ControllerIdVariable
	ControllerIdTag
	ControllerIdLogin
	ControllerIdColor
	ControllerIdPlugin
	ControllerIdDataSource
	ControllerIdDataCollection
	ControllerIdResult
	ControllerIdStats
	ControllerIdFiler
)

Variables

View Source
var ColorActions = []Action{
	{Method: http.MethodGet, Path: "", HandlerFunc: GetColorList},
}
View Source
var LoginActions = []Action{
	{Method: http.MethodPost, Path: "/login", HandlerFunc: loginCtx.login},
	{Method: http.MethodPost, Path: "/logout", HandlerFunc: loginCtx.logout},
}
View Source
var NodeController *nodeController
View Source
var ProjectController *projectController
View Source
var ResultActions = []Action{
	{
		Method:      http.MethodGet,
		Path:        "/:id",
		HandlerFunc: resultCtx.getList,
	},
}
View Source
var ScheduleController *scheduleController
View Source
var SpiderController *spiderController
View Source
var StatsActions = []Action{
	{
		Method:      http.MethodGet,
		Path:        "/overview",
		HandlerFunc: statsCtx.getOverview,
	},
	{
		Method:      http.MethodGet,
		Path:        "/daily",
		HandlerFunc: statsCtx.getDaily,
	},
	{
		Method:      http.MethodGet,
		Path:        "/tasks",
		HandlerFunc: statsCtx.getTasks,
	},
}
View Source
var TaskController *taskController
View Source
var TokenActions []Action
View Source
var TokenController *tokenController
View Source
var UserActions = []Action{
	{
		Method:      http.MethodPost,
		Path:        "/:id/change-password",
		HandlerFunc: userCtx.changePassword,
	},
}
View Source
var UserController *userController

Functions

func FilterToQuery

func FilterToQuery(f *entity.Filter) (q bson.M, err error)

FilterToQuery Translate entity.Filter to bson.M

func GetColorList

func GetColorList(c *gin.Context)

func GetDefaultPagination

func GetDefaultPagination() (p *entity.Pagination)

func GetFilter

func GetFilter(c *gin.Context) (f *entity.Filter, err error)

GetFilter Get entity.Filter from gin.Context

func GetFilterAll

func GetFilterAll(c *gin.Context) (res bool, err error)

GetFilterAll Get all from gin.Context

func GetFilterQuery

func GetFilterQuery(c *gin.Context) (q bson.M, err error)

GetFilterQuery Get bson.M from gin.Context

func GetPagination

func GetPagination(c *gin.Context) (p *entity.Pagination, err error)

func GetSorts

func GetSorts(c *gin.Context) (sorts []entity.Sort, err error)

GetSorts Get entity.Sort from gin.Context

func GetSortsOption

func GetSortsOption(c *gin.Context) (sort bson.D, err error)

GetSortsOption Get entity.Sort from gin.Context

func HandleError

func HandleError(statusCode int, c *gin.Context, err error)

func HandleErrorBadRequest

func HandleErrorBadRequest(c *gin.Context, err error)

func HandleErrorInternalServerError

func HandleErrorInternalServerError(c *gin.Context, err error)

func HandleErrorNotFound

func HandleErrorNotFound(c *gin.Context, err error)

func HandleErrorUnauthorized

func HandleErrorUnauthorized(c *gin.Context, err error)

func HandleSuccess

func HandleSuccess(c *gin.Context)

func HandleSuccessWithData

func HandleSuccessWithData(c *gin.Context, data interface{})

func HandleSuccessWithListData

func HandleSuccessWithListData(c *gin.Context, data interface{}, total int)

func InitControllers

func InitControllers() (err error)

func MustGetFilterAll

func MustGetFilterAll(c *gin.Context) (res bool)

func MustGetFilterQuery

func MustGetFilterQuery(c *gin.Context) (q bson.M)

func MustGetPagination

func MustGetPagination(c *gin.Context) (p *entity.Pagination)

func MustGetSortOption

func MustGetSortOption(c *gin.Context) (sort bson.D)

func SortsToOption

func SortsToOption(sorts []entity.Sort) (sort bson.D, err error)

SortsToOption Translate entity.Sort to bson.D

Types

type Action

type Action struct {
	Method      string
	Path        string
	HandlerFunc gin.HandlerFunc
}

type ActionController

type ActionController interface {
	Actions() (actions []Action)
}
var ColorController ActionController
var FilerController ActionController
var LoginController ActionController
var ResultController ActionController
var StatsController ActionController

type ActionControllerDelegate

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

func NewActionControllerDelegate

func NewActionControllerDelegate(id ControllerId, actions []Action) (d *ActionControllerDelegate)

func (*ActionControllerDelegate) Actions

func (ctr *ActionControllerDelegate) Actions() (actions []Action)

type BasicController

type BasicController interface {
	Get(c *gin.Context)
	Post(c *gin.Context)
	Put(c *gin.Context)
	Delete(c *gin.Context)
}

type BasicControllerDelegate

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

func (*BasicControllerDelegate) Delete

func (d *BasicControllerDelegate) Delete(c *gin.Context)

func (*BasicControllerDelegate) Get

func (d *BasicControllerDelegate) Get(c *gin.Context)

func (*BasicControllerDelegate) Post

func (d *BasicControllerDelegate) Post(c *gin.Context)

func (*BasicControllerDelegate) Put

func (d *BasicControllerDelegate) Put(c *gin.Context)

type BinderInterface

type BinderInterface interface {
	Bind(c *gin.Context) (res interfaces.Model, err error)
	BindList(c *gin.Context) (res []interfaces.Model, err error)
	BindBatchRequestPayload(c *gin.Context) (payload entity.BatchRequestPayload, err error)
	BindBatchRequestPayloadWithStringData(c *gin.Context) (payload entity.BatchRequestPayloadWithStringData, res interfaces.Model, err error)
}

type ControllerId

type ControllerId int

type JsonBinder

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

func NewJsonBinder

func NewJsonBinder(id ControllerId) (b *JsonBinder)

func (*JsonBinder) Bind

func (b *JsonBinder) Bind(c *gin.Context) (res interfaces.Model, err error)

func (*JsonBinder) BindBatchRequestPayload

func (b *JsonBinder) BindBatchRequestPayload(c *gin.Context) (payload entity.BatchRequestPayload, err error)

func (*JsonBinder) BindBatchRequestPayloadWithStringData

func (b *JsonBinder) BindBatchRequestPayloadWithStringData(c *gin.Context) (payload entity.BatchRequestPayloadWithStringData, res interfaces.Model, err error)

func (*JsonBinder) BindList

func (b *JsonBinder) BindList(c *gin.Context) (res interface{}, err error)

type ListActionController

type ListActionController interface {
	ListController
	ActionController
}

type ListActionControllerDelegate

type ListActionControllerDelegate struct {
	ListController
	ActionController
}

func NewListPostActionControllerDelegate

func NewListPostActionControllerDelegate(id ControllerId, svc interfaces.ModelBaseService, actions []Action) (d *ListActionControllerDelegate)

type ListController

type ListController interface {
	BasicController
	GetList(c *gin.Context)
	PutList(c *gin.Context)
	PostList(c *gin.Context)
	DeleteList(c *gin.Context)
}
var DataCollectionController ListController
var PluginController ListController
var TagController ListController

type ListControllerDelegate

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

func (*ListControllerDelegate) Delete

func (d *ListControllerDelegate) Delete(c *gin.Context)

func (*ListControllerDelegate) DeleteList

func (d *ListControllerDelegate) DeleteList(c *gin.Context)

func (*ListControllerDelegate) Get

func (d *ListControllerDelegate) Get(c *gin.Context)

func (*ListControllerDelegate) GetList

func (d *ListControllerDelegate) GetList(c *gin.Context)

func (*ListControllerDelegate) Post

func (d *ListControllerDelegate) Post(c *gin.Context)

func (*ListControllerDelegate) PostList

func (d *ListControllerDelegate) PostList(c *gin.Context)

func (*ListControllerDelegate) Put

func (d *ListControllerDelegate) Put(c *gin.Context)

func (*ListControllerDelegate) PutList

func (d *ListControllerDelegate) PutList(c *gin.Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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