app

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthSkipUri    = "AuthSkipUri"
	AuthSkipPrefix = "AuthSkipPrefix"
)

Variables

View Source
var EmptyPageResult = &PageResult{
	TotalCount: 0,
	Pos:        0,
	Data:       common.EmptyList,
}

空分页对象

Functions

func GetDatabase

func GetDatabase(config *conf.DBConfig) *sqlx.DB

获取数据库连接,执行一次

func GetGrpcConn

func GetGrpcConn(config *conf.GrpcConfig) (*grpc.ClientConn, error)

func StartWebserver

func StartWebserver(config conf.AppConfig, appContext *AppContext, handler ...WebHandler) error

Types

type AppContext

type AppContext struct {
	Context ContextManager
}

func NewAppContext

func NewAppContext(context ContextManager) *AppContext

func (*AppContext) DBAdd

func (m *AppContext) DBAdd(ca *CrudAdd) error

CRUD 增加数据对象

func (*AppContext) DBDelete

func (m *AppContext) DBDelete(table string, ids []string) error

根据id删除表数据

func (*AppContext) DBDeleteWithFilter

func (m *AppContext) DBDeleteWithFilter(table string, filter map[string]interface{}) error

func (*AppContext) DBDeleteWithFilterTx

func (m *AppContext) DBDeleteWithFilterTx(tx *sql.Tx, table string, filter map[string]interface{}) error

func (*AppContext) DBDeleteWithTx

func (m *AppContext) DBDeleteWithTx(tx *sql.Tx, table string, ids []string) error

func (*AppContext) DBGet

func (m *AppContext) DBGet(cg *CrudGet) error

func (*AppContext) DBGet2

func (m *AppContext) DBGet2(table string, culumns []string, filter map[string]interface{}, resultRef interface{}) error

CRUD 获取单个对象

func (*AppContext) DBInsert

func (m *AppContext) DBInsert(table string, vals map[string]interface{}) error

CRUD 增加数据对象

func (*AppContext) DBInsertWithTx

func (m *AppContext) DBInsertWithTx(tx *sql.Tx, table string, vals map[string]interface{}) error

func (*AppContext) DBQuery

func (m *AppContext) DBQuery(cq *CrudQuery) error

CRUD 查询列表

func (*AppContext) DBTrucate

func (m *AppContext) DBTrucate(table string) error

清空表

func (*AppContext) DBUpdate

func (m *AppContext) DBUpdate(cu *CrudUpdate) error

func (*AppContext) DBUpdate2

func (m *AppContext) DBUpdate2(table string, vals map[string]interface{}, filter map[string]interface{}) error

CRUD 数据更新

func (*AppContext) DBUpdate2WithTx

func (m *AppContext) DBUpdate2WithTx(tx *sql.Tx, table string, vals map[string]interface{}, filter map[string]interface{}) error

CRUD 数据更新

func (*AppContext) Get

func (m *AppContext) Get(key string) (interface{}, bool)

func (*AppContext) Set

func (m *AppContext) Set(key string, val interface{})

type ContextManager

type ContextManager interface {
	DBPool() *sqlx.DB
	GrpConn() *grpc.ClientConn
	Get(key string) (interface{}, bool)
	Set(key string, val interface{})
}

上下文管理, 用户管理全局对象

type CrudAdd

type CrudAdd struct {
	Table string
	Vals  []map[string]interface{}
}

func NewCrudAdd

func NewCrudAdd(table string, vals []map[string]interface{}) *CrudAdd

type CrudFilterLike

type CrudFilterLike struct {
	Names []string
	Value string
}

type CrudGet

type CrudGet struct {
	Table     string
	Culumns   []string
	Filter    map[string]interface{}
	ResultRef interface{}
}

func NewCrudGet

func NewCrudGet(table string, culumns []string, filter map[string]interface{}, resultRef interface{}) *CrudGet

type CrudQuery

type CrudQuery struct {
	Table      string
	Culumns    []string
	Tags       string
	LikeNames  []string
	LikeValue  interface{}
	DateRange  DateRange
	DateColumn string
	Joins      []string
	LeftJoins  []string
	Eq         sq.Eq
	LtOrEq     sq.LtOrEq
	GtOrEq     sq.GtOrEq
	Wheres     []string
	Pager      bool
	PageSize   uint64
	PagePos    uint64
	ResultRef  interface{}
	ResultPage *PageResult
}

func NewCrudQuery

func NewCrudQuery(table string, culumns []string, resultRef interface{}) *CrudQuery

func (*CrudQuery) SetEqValue

func (cq *CrudQuery) SetEqValue(key, val string)

type CrudUpdate

type CrudUpdate struct {
	Table  string
	Vals   map[string]interface{}
	Eq     sq.Eq
	LtOrEq sq.LtOrEq
	GtOrEq sq.GtOrEq
	// contains filtered or unexported fields
}

func NewCrudUpdate

func NewCrudUpdate(table string, vals map[string]interface{}, filter map[string]interface{}) *CrudUpdate

type DateRange

type DateRange struct {
	Start string `json:"start"`
	End   string `json:"end"`
}

type HTTPError

type HTTPError struct {
	Code     int         `json:"-"`
	Message  interface{} `json:"message"`
	Internal error       `json:"-"` // Stores the error returned by an external dependency
}

func NewHTTPError

func NewHTTPError(code int, message ...interface{}) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

type HttpHandler

type HttpHandler struct {
	Ctx *WebContext
}

func (*HttpHandler) FetchExcelData

func (h *HttpHandler) FetchExcelData(c echo.Context, sheet string) ([]map[string]string, error)

func (*HttpHandler) GetAppContext

func (h *HttpHandler) GetAppContext() *AppContext

func (*HttpHandler) GetConfig

func (h *HttpHandler) GetConfig() *conf.AppConfig

func (*HttpHandler) GetInternalError

func (h *HttpHandler) GetInternalError(err interface{}) *echo.HTTPError

func (*HttpHandler) GoInternalErrPage

func (h *HttpHandler) GoInternalErrPage(c echo.Context, err interface{}) error

func (*HttpHandler) ParseFormInt64

func (h *HttpHandler) ParseFormInt64(c echo.Context, name string) (int64, error)

func (*HttpHandler) RestError

func (h *HttpHandler) RestError(msg string) *RestResult

func (*HttpHandler) RestResult

func (h *HttpHandler) RestResult(data interface{}) *RestResult

func (*HttpHandler) RestSucc

func (h *HttpHandler) RestSucc(msg string) *RestResult

type JsonOptions

type JsonOptions struct {
	Id    string      `json:"id"`
	Value interface{} `json:"value"`
}

界面通用下拉选项模型

type PageResult

type PageResult struct {
	TotalCount int64       `json:"total_count,omitempty"`
	Pos        int64       `json:"pos"`
	Data       interface{} `json:"data"`
}

分页对象

type RestResult

type RestResult struct {
	Code    int         `json:"code"`
	Msgtype string      `json:"msgtype"`
	Msg     string      `json:"msg"`
	Data    interface{} `json:"data"`
}

type WebContext

type WebContext struct {
	AppCtx    *AppContext
	AppConfig *conf.AppConfig
}

func NewWebContext

func NewWebContext(appCtx *AppContext, config *conf.AppConfig) *WebContext

type WebForm

type WebForm struct {
	FormItem interface{}
	Posts    url.Values        `json:"-" form:"-" query:"-"`
	Gets     url.Values        `json:"-" form:"-" query:"-"`
	Params   map[string]string `json:"-" form:"-" query:"-"`
}

WEB 参数

func NewWebForm

func NewWebForm(c echo.Context) *WebForm

func (*WebForm) GetDateRange

func (f *WebForm) GetDateRange(name string) (DateRange, error)

func (*WebForm) GetInt64Val

func (f *WebForm) GetInt64Val(name string, defval int64) int64

func (*WebForm) GetIntVal

func (f *WebForm) GetIntVal(name string, defval int) int

func (*WebForm) GetMustVal

func (f *WebForm) GetMustVal(name string) (string, error)

func (*WebForm) GetUpdateMap

func (f *WebForm) GetUpdateMap(names []string) map[string]interface{}

func (*WebForm) GetVal

func (f *WebForm) GetVal(name string) string

func (*WebForm) GetVal2

func (f *WebForm) GetVal2(name string, defval string) string

func (*WebForm) Param

func (f *WebForm) Param(name string) string

func (*WebForm) Param2

func (f *WebForm) Param2(name string, defval string) string

func (*WebForm) Set

func (f *WebForm) Set(name string, value string)

type WebHandler

type WebHandler interface {
	InitRouter(webctx *WebContext, g *echo.Group)
}

type WebixTableColumn

type WebixTableColumn struct {
	Id         string      `json:"id,omitempty"`
	Header     interface{} `json:"header,omitempty"`
	Headermenu interface{} `json:"headermenu,omitempty"`
	Adjust     interface{} `json:"adjust,omitempty"`
	Hidden     interface{} `json:"hidden,omitempty"`
	Sort       string      `json:"sort,omitempty"`
	Fillspace  interface{} `json:"fillspace,omitempty"`
	Css        string      `json:"css,omitempty"`
	Template   string      `json:"template,omitempty"`
	Width      int         `json:"width,omitempty"`
	Height     int         `json:"height,omitempty"`
}

Webix 表格列定义

Jump to

Keyboard shortcuts

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