beeplus

package module
v0.0.0-...-45e94a2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

README

beeplus

beego 扩展库

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	G         M
	LibLoader LibLoaderClass
)
View Source
var (
	Cache cache.Cache
)
View Source
var (
	Options map[string]string
)

Functions

func DBInit

func DBInit(dbname string)

func DBInstall

func DBInstall(installer DBInstaller)

func GetOptions

func GetOptions(key string) string

func Hook

func Hook(hash, position string, hook beego.FilterFunc, params ...bool)

注册Hook

func Lib

func Lib(base, dir string)

注册静态lib路径

func MySQL

func MySQL(conf_names ...string)

加载数据库配置,注册数据库,传入配置文件字段标题

func RegTable

func RegTable(models ...interface{})

注册数据表模型

func Router

func Router(base string, routers []RouterIndex, config ...RouterConfig)

注册路由

func SetOptions

func SetOptions(key, value string)

func WWWROOT

func WWWROOT(config RouterConfig)

以web根目录启动一个web框架

Types

type ApiResult

type ApiResult struct {
	Result bool        `json:"result";`
	Code   interface{} `json:"code";`
	Data   interface{} `json:"data";`
}

type Base

type Base struct {
	UID       int64
	Post_JSON gjson.Result
	Config    RouterConfig
	VData     *fplib.SJSON
	BaseUtils
	beego.Controller
}

func (*Base) ApiOut

func (this *Base) ApiOut(result bool, obj ...interface{})

api输出

func (*Base) Default

func (this *Base) Default(json gjson.Result, defaults ...interface{}) gjson.Result

设置gjson的默认值

func (*Base) Die

func (this *Base) Die()

结束

func (*Base) Err

func (this *Base) Err(obj ...interface{})

api错误输出

func (*Base) Finish

func (this *Base) Finish()

func (*Base) GetJSON

func (this *Base) GetJSON(keys ...string) gjson.Result

获取post上来的json数据

func (*Base) GetMap

func (this *Base) GetMap(key string) gjson.Result

获取post上来的表单数据

func (*Base) Goto

func (this *Base) Goto(url string)

跳转网页

func (*Base) Has

func (this *Base) Has(v interface{}, msgs ...string) *Base

判断变量是否为空,如果为空直接输出api错误

func (*Base) HasAll

func (this *Base) HasAll(vs ...interface{}) *Base

func (*Base) MakeURL

func (this *Base) MakeURL(url string) string

获取带前缀的url

func (*Base) Ok

func (this *Base) Ok(obj ...interface{})

api正常输出

func (*Base) Out

func (this *Base) Out(data string) *Base

字符串输出

func (*Base) PageErr

func (this *Base) PageErr(msg string)

带模板的页面错误提示

func (*Base) ParseAllVData

func (this *Base) ParseAllVData()

解析所有变量到VData

func (*Base) Prepare

func (this *Base) Prepare()

func (*Base) SetConfig

func (this *Base) SetConfig(conf RouterConfig)

设置配置

func (*Base) URL

func (this *Base) URL(urls ...string) string

获取访问地址

func (*Base) V

func (this *Base) V(key string, defaults ...interface{}) gjson.Result

获取变量,可设置默认值

func (*Base) View

func (this *Base) View(files ...string)

调用模板

type BaseControllerInterface

type BaseControllerInterface interface {
	beego.ControllerInterface
	SetConfig(RouterConfig)
}

type BaseUtils

type BaseUtils struct{}

func (*BaseUtils) J2ORM

func (this *BaseUtils) J2ORM(o interface{}, ps ...string) orm.Params

json转orm.Params

func (*BaseUtils) J2S

func (this *BaseUtils) J2S(json interface{}, o interface{}, ps ...string) error

json转struct

func (*BaseUtils) S2J

func (this *BaseUtils) S2J(o interface{}, ps ...string) *fplib.SJSON

struct转json

type DBClass

type DBClass struct {
	Orm   orm.Ormer
	Seter orm.RawSeter
	Count int64
}

func DB

func DB(db ...string) *DBClass

获取数据库对象

func (*DBClass) Arr

func (this *DBClass) Arr(seters ...interface{}) []orm.Params

从Raw查询中解析结果到数组

func (*DBClass) Begin

func (this *DBClass) Begin()

func (*DBClass) Commit

func (this *DBClass) Commit()

func (*DBClass) Debug

func (this *DBClass) Debug(b ...bool)

开启debug

func (*DBClass) Delete

func (this *DBClass) Delete(t interface{}, p ...string) (int64, error)

删除

func (*DBClass) Disable

func (this *DBClass) Disable(t interface{}, p ...string) (int64, error)

禁用,软删除功能,直接写入数据库

func (*DBClass) Enable

func (this *DBClass) Enable(t interface{}, p ...string) (int64, error)

设置启用状态,直接写入数据库

func (*DBClass) I

func (this *DBClass) I(t interface{}) (int64, error)

插入新,并使记录保持可用 status=1 delete_at=null

func (*DBClass) Init

func (this *DBClass) Init(db ...string) *DBClass

初始化

func (*DBClass) Insert

func (this *DBClass) Insert(t interface{}) (int64, error)

插入

func (*DBClass) InsertMulti

func (this *DBClass) InsertMulti(c int, t interface{}) (int64, error)

批量插入

func (*DBClass) One

func (this *DBClass) One(seters ...interface{}) orm.Params

从Raw查询中解析一条结果到数组

func (*DBClass) P

func (this *DBClass) P(p ...interface{}) orm.RawSeter

设置Raw的参数

func (*DBClass) Q

func (this *DBClass) Q(sql string, p ...interface{}) []orm.Params

执行查询语句,返回结果数组

func (*DBClass) Raw

func (this *DBClass) Raw(sql string, p ...interface{}) orm.RawSeter

执行sql

func (*DBClass) Read

func (this *DBClass) Read(t interface{}, p ...string) error

读取

func (*DBClass) ReadOrCreate

func (this *DBClass) ReadOrCreate(t interface{}, p string, ps ...string) (bool, int64, error)

读取,没有就创建

func (*DBClass) Rollback

func (this *DBClass) Rollback()

func (*DBClass) Select

func (this *DBClass) Select(p ...string) orm.QueryBuilder

通过查询字段返回QueryBuilder

func (*DBClass) SetDisable

func (this *DBClass) SetDisable(t interface{})

设置禁用状态,不写入数据库

func (*DBClass) SetEnable

func (this *DBClass) SetEnable(t interface{})

设置启用状态,不写入数据库

func (*DBClass) T

func (this *DBClass) T(f func()) (Rerr error)

在闭包函数中启用事务处理,随时可以panic,将自动回滚

func (*DBClass) Table

func (this *DBClass) Table(t interface{}) orm.QuerySeter

通过表名返回QueryTable

func (*DBClass) U

func (this *DBClass) U(t interface{}, p ...string) (int64, error)

更新,并使记录保持可用 status=1 delete_at=null

func (*DBClass) Update

func (this *DBClass) Update(t interface{}, p ...string) (int64, error)

更新

type DBInstaller

type DBInstaller interface {
	Install()
}

type ErrorController

type ErrorController struct {
	Base
}

func (*ErrorController) Error401

func (this *ErrorController) Error401()

func (*ErrorController) Error403

func (this *ErrorController) Error403()

func (*ErrorController) Error404

func (this *ErrorController) Error404()

func (*ErrorController) Error500

func (this *ErrorController) Error500()

func (*ErrorController) Error501

func (this *ErrorController) Error501()

func (*ErrorController) Error503

func (this *ErrorController) Error503()

func (*ErrorController) ErrorDb

func (this *ErrorController) ErrorDb()

type GoIndexController

type GoIndexController struct {
	beego.Controller
}

func (*GoIndexController) GoIndex

func (this *GoIndexController) GoIndex()

type HookAfterAction

type HookAfterAction interface {
	After()
}

type HookBeforeAction

type HookBeforeAction interface {
	Before()
}

hook接口

type LibLoaderClass

type LibLoaderClass struct {
	Store map[string][]string
	Group map[string][]string
}

func (*LibLoaderClass) Add

func (this *LibLoaderClass) Add(name string, libs ...string)

func (*LibLoaderClass) AddGroup

func (this *LibLoaderClass) AddGroup(name string, libs ...string)

func (*LibLoaderClass) GetLoadHTML

func (this *LibLoaderClass) GetLoadHTML(name string, base ...string) (string, string)

func (*LibLoaderClass) LoadCSS

func (this *LibLoaderClass) LoadCSS(name string, base ...string) string

func (*LibLoaderClass) LoadJS

func (this *LibLoaderClass) LoadJS(name string, base ...string) string

type M

type M map[string]interface{}

type RouterConfig

type RouterConfig struct {
	WebRoot   string
	SrcRoot   string
	ViewRoot  string
	LibLoader *LibLoaderClass
	PageIndex []RouterIndex
	ApiIndex  []RouterIndex
	fplib.Conf
}

func NewRouterConfig

func NewRouterConfig(p ...string) RouterConfig

type RouterIndex

type RouterIndex struct {
	Key        string
	Param      string
	Action     string
	Controller interface{}
	Remark     string
}

type SettingsClass

type SettingsClass struct{}
var (
	Settings SettingsClass
)

func (*SettingsClass) Get

func (this *SettingsClass) Get(key string, defaults ...string) string

func (*SettingsClass) GetBool

func (this *SettingsClass) GetBool(key string, defaults ...bool) bool

func (*SettingsClass) GetInt

func (this *SettingsClass) GetInt(key string, defaults ...int) int

func (*SettingsClass) Set

func (this *SettingsClass) Set(key string, value string, remark ...string) bool

type SysSettings

type SysSettings struct {
	Id       int       `orm:"auto;pk;description(ID)"`
	Key      string    `orm:"size(512);index;unique;description(key)"`
	Value    string    `orm:"null;type(text);description(value)"`
	CreateAt time.Time `orm:"auto_now_add;type(datetime);description(创建时间)"`
	UpdateAt time.Time `orm:"null;auto_now;type(datetime);description(更新时间)"`
	Remark   string    `orm:"null;type(text);description(备注)"`
}

系统设置表

type TableBase

type TableBase struct {
	Id       int64     `orm:"auto;pk;description(ID)"`
	Status   int64     `orm:"default(1);index;description(状态)"`
	CreateAt time.Time `orm:"auto_now_add;type(datetime);description(创建时间)"`
	UpdateAt time.Time `orm:"null;auto_now;type(datetime);description(更新时间)"`
	DeleteAt time.Time `orm:"null;type(datetime);description(删除时间)"`
	Remark   string    `orm:"null;type(text);description(备注)"`
}

数据表的基础

type UploadResult

type UploadResult struct {
	Result bool        `json:"result";`
	Code   interface{} `json:"code";`
	Data   interface{} `json:"data";`
	// 兼容ckeditor的输出
	Uploaded bool   `json:"uploaded";`
	Url      string `json:"url";`
}

type Uploader

type Uploader struct {
	Base
}

func (*Uploader) Err

func (this *Uploader) Err(obj interface{})

api错误输出

func (*Uploader) GetUploadFile

func (this *Uploader) GetUploadFile(baseDir string)

func (*Uploader) Ok

func (this *Uploader) Ok(obj interface{})

api正常输出

Jump to

Keyboard shortcuts

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