camModels

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	// The component name of the default components.Database
	DefaultDBName string
	// default xorm template's file relative path.
	DefaultTemplatesDir string
}

application's config struct

type BaseContext

type BaseContext struct {
	camBase.ContextInterface
	// contains filtered or unexported fields
}

上下文对象

func (*BaseContext) GetSession added in v0.2.15

func (model *BaseContext) GetSession() camBase.SessionInterface

func (*BaseContext) SetSession added in v0.2.15

func (model *BaseContext) SetSession(session camBase.SessionInterface)

type BaseController

type BaseController struct {
	camBase.ControllerInterface
	// contains filtered or unexported fields
}

所有 handler 的基类。主要处理问题是:统一接口、数据库管理

func (*BaseController) AddValue

func (controller *BaseController) AddValue(key string, value interface{})

OVERWRITE: 添加参数

func (*BaseController) AfterAction

func (controller *BaseController) AfterAction(action string, response []byte) []byte

执行动作后执行的方法 过滤返回结果

func (*BaseController) BeforeAction

func (controller *BaseController) BeforeAction(action string) bool

执行动作前执行的方法 如果返回 false 将会返回一个错误

func (*BaseController) GetAppInterface

func (controller *BaseController) GetAppInterface() camBase.ApplicationInterface

Return app instance

func (*BaseController) GetContext

func (controller *BaseController) GetContext() camBase.ContextInterface

获取上下文对象

func (*BaseController) GetValue

func (controller *BaseController) GetValue(key string) interface{}

获取参数

func (*BaseController) Init

func (controller *BaseController) Init()

初始化

func (*BaseController) Read

func (controller *BaseController) Read() []byte

return action write

func (*BaseController) SetApp

func (controller *BaseController) SetApp(app camBase.ApplicationInterface)

set app instance

func (*BaseController) SetContext

func (controller *BaseController) SetContext(context camBase.ContextInterface)

设置上下文对象

func (*BaseController) SetHttpValues

func (controller *BaseController) SetHttpValues(w http.ResponseWriter, r *http.Request)

设置http接收到的参数

func (*BaseController) SetValues

func (controller *BaseController) SetValues(values map[string]interface{})

设置接收到的参数

func (*BaseController) Write

func (controller *BaseController) Write(bytes []byte)

set response str

type BaseModel

type BaseModel struct {
}

type Cam added in v0.2.9

type Cam struct {
	Modules []*CamModule `json:"modules"`
}

type CamModule added in v0.2.9

type CamModule struct {
	Name string                `json:"name"`
	Type camBase.CamModuleType `json:"type"`
}

type Config

type Config struct {
	BaseModel
	// Application config
	AppConfig *AppConfig
	// Params required by the business logic
	Params map[string]interface{}
	// Components's config
	ComponentDict map[string]camBase.ConfigComponentInterface
}

config struct config can merge in application

func (*Config) Init

func (config *Config) Init()

init params

type Context

type Context struct {
	BaseContext
	// contains filtered or unexported fields
}

http 上下文对象

func NewContext

func NewContext(session camBase.SessionInterface) *Context

新建 http 上下文对象

func (*Context) GetSession

func (model *Context) GetSession() camBase.SessionInterface

获取session

type HttpSession

type HttpSession struct {
	camBase.SessionInterface
	// contains filtered or unexported fields
}

session

func NewHttpSession

func NewHttpSession(session *sessions.Session) *HttpSession

func (*HttpSession) Destroy

func (model *HttpSession) Destroy()

销毁session 清空 session 所有数据

func (*HttpSession) Get

func (model *HttpSession) Get(key interface{}) interface{}

获取值

func (*HttpSession) GetSessionId

func (model *HttpSession) GetSessionId() string

获取 sessionId

func (*HttpSession) Set

func (model *HttpSession) Set(key interface{}, value interface{})

设置值

type MessageModel

type MessageModel struct {
	BaseModel
	Id    int64  `json:"i"` // 协议号
	Route string `json:"r"` // 路由
	Data  string `json:"d"` // 传输的数据
}

func (*MessageModel) Validate

func (model *MessageModel) Validate() bool

验证数据是否合法

type Migration

type Migration struct {
	camBase.MigrationInterface
	// contains filtered or unexported fields
}

base migration struct

func (*Migration) Exec

func (model *Migration) Exec(sql string)

exec sql

func (*Migration) GetSqlList

func (model *Migration) GetSqlList() []string

get sql list

type ResponseModel

type ResponseModel struct {
	Code    int                    `json:"c"` // 状态码
	Message string                 `json:"m"` // 消息
	Values  map[string]interface{} `json:"v"` // 传输的值
}

type WebsocketSession

type WebsocketSession struct {
	BaseModel
	// contains filtered or unexported fields
}

websocket 使用的 session 。没有发送的功能。必须依赖 WebsocketServer 进行发送

func NewWebsocketSession

func NewWebsocketSession(conn *websocket.Conn) *WebsocketSession

新建websocket session

func (*WebsocketSession) Destroy

func (model *WebsocketSession) Destroy()

销毁session 清空 session 所有数据

func (*WebsocketSession) Get

func (model *WebsocketSession) Get(key interface{}) interface{}

获取值

func (*WebsocketSession) GetConn added in v0.2.13

func (model *WebsocketSession) GetConn() *websocket.Conn

get client connection

func (*WebsocketSession) GetSessionId

func (model *WebsocketSession) GetSessionId() string

获取 sessionId

func (*WebsocketSession) Set

func (model *WebsocketSession) Set(key interface{}, value interface{})

设置值

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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