Documentation ¶
Index ¶
- Constants
- func APIGET(path string, h fasthttp.RequestHandler, checktoken bool)
- func APIGETWITHOUTSIGN(path string, h fasthttp.RequestHandler)
- func APIPOST(path string, h fasthttp.RequestHandler, checktoken bool)
- func APIPOSTWITHOUTSIGN(path string, h fasthttp.RequestHandler)
- func APIPOSTv2(path string, fn interface{}, checktoken bool)
- func AddBeanToSynList(bean interface{})
- func BuildSqlByQueryMap(qmap map[string]interface{}) (string, string, []interface{}, error)
- func DBEngineClose()
- func DoSynBeans(sourceName string)
- func GET(path string, h fasthttp.RequestHandler, checksession bool)
- func GetDBEngine() *xorm.EngineGroup
- func GetDBEngineByName(sourceName string) *xorm.EngineGroup
- func GetIniByKey(section string, key string) string
- func GetIniByKeyWithReload(section string, key string, reloadini bool) string
- func GetRedisConn() (redis.Conn, error)
- func GetRequestHandler(ctx *fasthttp.RequestCtx)
- func GetRouter() *fasthttprouter.Router
- func GetSqlByCondition(cond *QryConditions) (string, []interface{}, error)
- func GetSqlByConditionGroup(condlist []QryConditions) (string, []interface{}, error)
- func GetSqlByWhereFeildList(wheremap []QMapWhereField) (string, []interface{}, error)
- func GetSyncModelBeanlist() []interface{}
- func GetUserIdFromToken(passToken string) (uid int64, err error)
- func LoadConfigFrom(fname string)
- func ModuleRegist(m GGModule)
- func POST(path string, h fasthttp.RequestHandler, checksession bool)
- func POSTv2(path string, fn interface{}, checksession bool)
- func QueryListByMap(qmap map[string]interface{}) ([]map[string]string, int64, error)
- func RedisDeleteKey(key string) (int, error)
- func RedisGeoAdd(key string, lat, lng float64, id string) (int, error)
- func RedisGeoDist(key, id1, id2 string) (string, error)
- func RedisGeoPos(key, id string) (lat, lng float64, err error)
- func RedisGeoRadius(key string, lat, lng float64, radius int) ([]string, error)
- func RedisGeoRemove(setkey string, members ...string) (int, error)
- func RedisGetKey(key string) (string, error)
- func RedisKeyExists(key string) (int, error)
- func RedisListLPush(key string, val interface{}) (int, error)
- func RedisListLen(key string) (int, error)
- func RedisListRPush(key string, val interface{}) (int, error)
- func RedisListRange(key string, begin, end int) ([]string, error)
- func RedisPublish(chenel, message string) (int, error)
- func RedisSETNX(key, val string) (int, error)
- func RedisSetAdd(setkey string, members ...string) (int, error)
- func RedisSetExist(setkey string, member string) (bool, error)
- func RedisSetKey(key, value, expiretime string, ifexpire bool) (string, error)
- func RedisSetMemberCount(setkey string) (int, error)
- func RedisSetMultiKey(key, value []string) (string, error)
- func RedisSetRemove(setkey string, members ...string) (int, error)
- func RedisSetSDIFF(setkey1, setkey2 string) ([]string, error)
- func RedisSetScan(setkey string) ([]string, error)
- func RedisSetSinter(setkey1, setkey2 string) ([]string, error)
- func SessionGetKeyIntVal(key string, ctx *fasthttp.RequestCtx) int64
- func SessionGetKeyStringVal(key string, ctx *fasthttp.RequestCtx) string
- func SetUpSourceDatabase(dbtype, sourceName string, dbUrls []string, prefix, isdefault bool)
- func ShowSysModules()
- func SignKey() string
- func TokenPrefix() string
- func TokenSecretKey() string
- func UUID() int64
- func UUIDWithNoteId(nid int64) int64
- func Validate(form interface{}) error
- func WEBSOCKET(path string, h fasthttp.RequestHandler)
- type GGModule
- type QMapWhereField
- type QryConditions
- type RedisHelper
- type RequestCtxExtent
- type Server
Constants ¶
const ( // HTTP配置-固定常量 K_GGF_CONFIG_HTTP_SECTION = "HTTP" K_GGF_CONFIG_HTTP_DOMAIN = "DOMAIN" K_GGF_CONFIG_HTTP_PORT = "PORT" // 代码配置-固定常量 K_GGF_CONFIG_CODE_SECTION = "CODE" K_GGF_CONFIG_CODE_PROJNAME = "PRJNAME" K_GGF_CONFIG_CODE_PRJPREX = "PRJPREX" K_GGF_CONFIG_CODE_TOKEN_SECRETKEY = "TOKEN_SECRETKEY" K_GGF_CONFIG_CODE_REQ_SIGNKEY = "REQ_SIGNKEY" // 数据库配置 K_GGF_CONFIG_DB_SECTION = "DATABASE" K_GGF_CONFIG_DB_MASTER = "MASTER_DB" // 授权相关 K_GGF_CONFIG_AUTH_SECTION = "AUTH" K_GGF_CONFIG_AUTH_LOGINURL = "LOGINURL" )
const (
TOKEN_EXPIRE_CODE = 10001
)
Variables ¶
This section is empty.
Functions ¶
func APIGET ¶
func APIGET(path string, h fasthttp.RequestHandler, checktoken bool)
注册路由,GET的方式
- parmas @path -- 访问路径 @h -- 处理handler @checktoken -- 是否校验token @checktoken -- 是否校验资源权限 @checkip -- 是否检查调用方ip
func APIGETWITHOUTSIGN ¶
func APIGETWITHOUTSIGN(path string, h fasthttp.RequestHandler)
一些默认不需要签名的接口
func APIPOST ¶
func APIPOST(path string, h fasthttp.RequestHandler, checktoken bool)
注册路由,Post的方式
- parmas @path -- 访问路径 @h -- 处理handler @checktoken -- 是否校验token
func APIPOSTWITHOUTSIGN ¶
func APIPOSTWITHOUTSIGN(path string, h fasthttp.RequestHandler)
一些默认不需要签名的接口
func BuildSqlByQueryMap ¶
内部功能函数-组装mysql 语句
func DBEngineClose ¶
func DBEngineClose()
func GET ¶
func GET(path string, h fasthttp.RequestHandler, checksession bool)
注册路由,GET的方式
- parmas @path -- 访问路径 @h -- 处理handler @checktoken -- 是否校验token
func GetIniByKeyWithReload ¶
* 有时候改了配置,想不重启的情况,调用这个
func GetRequestHandler ¶
func GetRequestHandler(ctx *fasthttp.RequestCtx)
func GetSqlByCondition ¶
func GetSqlByCondition(cond *QryConditions) (string, []interface{}, error)
* 从condition对象中拼接sql
func GetSqlByConditionGroup ¶
func GetSqlByConditionGroup(condlist []QryConditions) (string, []interface{}, error)
* 从condition对象组中拼接sql
func GetSqlByWhereFeildList ¶
func GetSqlByWhereFeildList(wheremap []QMapWhereField) (string, []interface{}, error)
* 从field列表中获取,该条件组条件的sql及参数
func GetUserIdFromToken ¶
JWT-中间件 * GetUserIdFromToken * 从jwt字符串中解析获得userid
func LoadConfigFrom ¶
func LoadConfigFrom(fname string)
func ModuleRegist ¶
func ModuleRegist(m GGModule)
func POST ¶
func POST(path string, h fasthttp.RequestHandler, checksession bool)
注册路由,POST的方式
- parmas @path -- 访问路径 @h -- 处理handler @checktoken -- 是否校验token
func POSTv2 ¶
*params
@fn -- 指向一个函数的interface类型, 此函数第一个参数必须是fasthttp.RequestCtx类型, 第二个参数为承载在body里面json格式数据的对象
处理逻辑 1. 先通过反射,将fn的类型信息查询出来 2. 根据fn的类型信息,判断第一个参数必须是fasthttp.RequestCtx类型,第二个参数是Args,既body里面的数据类型 3. 通过反射,将Args的类型信息提取出来,用于在Unmarshal()中将body里面的数据解析出来
example: lego.POSTv2("/admin/Test_mode/editpage2", vc.ListJson2, lego.LEGO_SESSION_YPE_ADMIN, false)
func (vc *Test_modeCtrl) ListJson2(Ctx *fasthttp.RequestCtx, Args *Args) { fmt.Printf("ListJson2: %v", Args) }
func QueryListByMap ¶
*******************************************************************************************
构建sql语句
func RedisGeoDist ¶
func RedisGeoPos ¶
func RedisGeoRadius ¶
半径内元素个数
func RedisGeoRemove ¶
* SET集合删除成员
func RedisListLen ¶
func RedisListRPush ¶
func RedisSetExist ¶
* SET集合-- 判断元素是否在集合中
func RedisSetKey ¶
* 再多封装一次,get、set的用法.
func RedisSetMultiKey ¶
* 一次性设置多个key、val.
func RedisSetRemove ¶
* SET集合删除成员
func RedisSetSDIFF ¶
* SET集合-- 2个集合的差集
func RedisSetSinter ¶
* SET集合-- 2个集合的交集
func SessionGetKeyIntVal ¶
func SessionGetKeyIntVal(key string, ctx *fasthttp.RequestCtx) int64
通过content获取user_id
func SessionGetKeyStringVal ¶
func SessionGetKeyStringVal(key string, ctx *fasthttp.RequestCtx) string
通过content获取user_id
func SetUpSourceDatabase ¶
func TokenPrefix ¶
func TokenPrefix() string
func TokenSecretKey ¶
func TokenSecretKey() string
func WEBSOCKET ¶
func WEBSOCKET(path string, h fasthttp.RequestHandler)
websocket,注册
- parmas @path -- 访问路径 @h -- 处理handler @checktoken -- 是否校验token
Types ¶
type QMapWhereField ¶
type QMapWhereField struct { FieldName string Opt string Param interface{} CombineWith string // AND OR OmitEmpty bool // 是否忽略空或0值 }
查询where字段参数类定义
type QryConditions ¶
type QryConditions struct { CombineWith string // AND OR FieldList []QMapWhereField }
func NewQryConditions ¶
func NewQryConditions() QryConditions
func (*QryConditions) AddFeild ¶
func (obj *QryConditions) AddFeild(field QMapWhereField)
type RedisHelper ¶
type RedisHelper struct { }
type RequestCtxExtent ¶
type RequestCtxExtent struct {
*fasthttp.RequestCtx
}
func (*RequestCtxExtent) JSON ¶
func (self *RequestCtxExtent) JSON(code int, dataMap map[string]interface{})
输出json
- @parsm code --- 错误码 data --- 数据
func (*RequestCtxExtent) Peek ¶
func (self *RequestCtxExtent) Peek(key string) []byte
获取参数
- @parsm code --- 错误码 data --- 数据
func (*RequestCtxExtent) PureHTML ¶
func (self *RequestCtxExtent) PureHTML(fpath string)
******************************************** HTML
- @parsm name --- 文件路径
func (*RequestCtxExtent) XML ¶
func (self *RequestCtxExtent) XML(dataMap map[string]string)
输出xml
- @parsm code --- 错误码 data --- 数据