controllers

package
v0.0.0-...-2e9e358 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthController

type AuthController struct {
	Controller

	UserContext interface{}
	Token       string
	UserAuthObj AuthImplInterface
}

func (*AuthController) CheckUserIsClientManagerOrSelf

func (this *AuthController) CheckUserIsClientManagerOrSelf(targetUserId interface{}) bool

func (*AuthController) CheckUserPrivilege

func (this *AuthController) CheckUserPrivilege(requiredPrivilege interface{}) bool

登录状态验证

func (*AuthController) CheckUserPrivilegeRedirect

func (this *AuthController) CheckUserPrivilegeRedirect(requiredPrivilege interface{}, redirectUrl string) (ret bool)

func (*AuthController) GetUserAuthImpl

func (this *AuthController) GetUserAuthImpl() AuthImplInterface

func (*AuthController) LoadUserContext

func (this *AuthController) LoadUserContext() interface{}

读取登录状态

func (*AuthController) LoadUserToken

func (this *AuthController) LoadUserToken() string

type AuthControllerInterface

type AuthControllerInterface interface {
	GetUserAuthImpl() AuthImplInterface
	LoadUserToken() string
	LoadUserContext() interface{}
	CheckUserPrivilege(requiredPrivilege interface{}) bool
	CheckUserIsClientManagerOrSelf(targetUserId interface{}) bool
}

type AuthImplInterface

type AuthImplInterface interface {
	TokenKey() string
	LoadUserToken(c ControllerInterface) string
	LoadTokenObj(token string) interface{}
	SaveTokenObj(token string, obj interface{})
	CheckUserPrivilege(userContext interface{}, requiredPrivilege interface{}) bool
	IsClientManagerOrSelf(userContext interface{}, targetUserId interface{}) bool
}
var DefaultAuthImpl AuthImplInterface

type Controller

type Controller struct {
	W http.ResponseWriter
	R *http.Request

	UrlParameters map[string]string
}

func (*Controller) AjaxDbList

func (this *Controller) AjaxDbList(pageable *pkBeans.Pageable, list interface{}, listSize int, total int64, oldCodeFormat ...bool)

func (*Controller) AjaxDbRecord

func (this *Controller) AjaxDbRecord(ob interface{}, oldCodeFormat ...bool)

func (*Controller) AjaxError

func (this *Controller) AjaxError(message string, codes ...int)

func (*Controller) AjaxMsg

func (this *Controller) AjaxMsg(code int, data interface{}, message ...string)

func (*Controller) AjaxUnAuthorized

func (this *Controller) AjaxUnAuthorized(message string, codes ...int)

func (*Controller) Cookie

func (this *Controller) Cookie(key string) *http.Cookie

Cookie returns request cookie item string by a given key. if non-existed, return empty string.

func (*Controller) CookieValue

func (this *Controller) CookieValue(key string) string

func (*Controller) GetClientIpAddr

func (this *Controller) GetClientIpAddr() string

func (*Controller) GetInt

func (this *Controller) GetInt(key string, defValues ...int) int

func (*Controller) GetInt64

func (this *Controller) GetInt64(key string, defValues ...int64) int64

func (*Controller) GetPageableFromRequest

func (this *Controller) GetPageableFromRequest() *pkBeans.Pageable

func (*Controller) GetRequest

func (this *Controller) GetRequest() *http.Request

func (*Controller) GetResponseWriter

func (this *Controller) GetResponseWriter() http.ResponseWriter

func (*Controller) GetString

func (this *Controller) GetString(key string, defValues ...string) string

func (*Controller) Header

func (this *Controller) Header(key string) string

Header returns request header item string by a given string. if non-existed, return empty string.

func (*Controller) JsonResult

func (this *Controller) JsonResult(out interface{})

func (*Controller) OnLeave

func (this *Controller) OnLeave()

func (*Controller) OnPrepare

func (this *Controller) OnPrepare()

func (*Controller) Query

func (this *Controller) Query(key string) string

\param key string, ":k": search in url path paramters, else search in url paramters

func (*Controller) Redirect

func (this *Controller) Redirect(url string)

func (*Controller) RenderViewSimple

func (this *Controller) RenderViewSimple(viewPath string, args ...interface{})

func (*Controller) RequestBodyToJsonObject

func (this *Controller) RequestBodyToJsonObject(ob interface{}) error

func (*Controller) SetCookieValue

func (this *Controller) SetCookieValue(key string, val string, maxAgeSecondss ...int)

func (*Controller) SetRequest

func (this *Controller) SetRequest(r *http.Request)

func (*Controller) SetResponseWriter

func (this *Controller) SetResponseWriter(w http.ResponseWriter)

func (*Controller) SetUrlParameters

func (this *Controller) SetUrlParameters(p map[string]string)

type ControllerInterface

type ControllerInterface interface {
	OnPrepare()
	OnLeave()

	RenderViewSimple(viewPath string, args ...interface{})

	SetUrlParameters(p map[string]string)
	SetResponseWriter(w http.ResponseWriter)
	GetResponseWriter() http.ResponseWriter
	SetRequest(r *http.Request)
	GetRequest() *http.Request
	RequestBodyToJsonObject(ob interface{}) error
	GetClientIpAddr() string

	AjaxError(message string, codes ...int)

	Header(key string) string
	SetCookieValue(key string, val string, maxAgeSecondss ...int)
	CookieValue(key string) string
	GetInt(key string, defValues ...int) int
	GetInt64(key string, defValues ...int64) int64
	GetString(key string, defValues ...string) string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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