Documentation ¶
Index ¶
- Constants
- Variables
- func Decimal(value float64) float64
- func DecodeJWT(jwtToken string) (*simplejson.Json, error)
- func EncodeJWT(data Map) string
- func ExtractUniqueIds(datas []IIDable, idType string) []int
- func GetOrmFromContext(ctx context.Context) orm.Ormer
- func GetRequestModeFromCtx(ctx context.Context) *requestMode
- func GetServiceMode() string
- func HostDomain(host string) string
- func ParseTime(strTime string) time.Time
- func ParseUserIdFromJwtData(js *simplejson.Json) (int, int, error)
- func ParseUserIdFromJwtToken(jwtToken string) (int, int, error)
- func RecoverFromCronTaskPanic(ctx go_context.Context)
- func RecoverPanic(ctx *context.Context)
- func Router(r RestResourceInterface)
- func RunInGoroutine(task func())
- func Strftime(t *time.Time, f string) string
- func ToJsonString(obj interface{}) string
- func WrapLog()
- type APIServiceNextPageInfo
- type Area
- type AreaService
- func (this *AreaService) GetAreaByCode(code string) *Area
- func (this *AreaService) GetAreaByName(name string) *Area
- func (this *AreaService) GetCitiesByIds(ids []int) []*City
- func (this *AreaService) GetCitiesByNames(names []string) []*City
- func (this *AreaService) GetCitiesForProvince(provinceId int) []*City
- func (this *AreaService) GetCityById(id int) *City
- func (this *AreaService) GetCityByName(name string) *City
- func (this *AreaService) GetCityByNameInProvince(provinceId int, name string) *City
- func (this *AreaService) GetDistrictById(id int) *District
- func (this *AreaService) GetDistrictByName(cityId int, name string) *District
- func (this *AreaService) GetDistrictsByIds(ids []int) []*District
- func (this *AreaService) GetDistrictsByNames(cityId int, names []string) []*District
- func (this *AreaService) GetDistrictsForCity(cityId int) []*District
- func (this *AreaService) GetProvinceById(id int) *Province
- func (this *AreaService) GetProvinceByName(name string) *Province
- func (this *AreaService) GetProvinces() []*Province
- func (this *AreaService) GetProvincesByIds(ids []int) []*Province
- func (this *AreaService) GetProvincesByNames(names []string) []*Province
- type BusinessError
- type City
- type ConsoleController
- type DingBot
- type District
- type DummyLock
- type EntityBase
- type FillOption
- type GeoService
- type IBusinessContextFactory
- type IIDable
- type ILock
- type IModel
- type INextPageInfo
- func MockPaginate(itemCount int64, page *PageInfo) INextPageInfo
- func MockPaginateV2(itemCount int, page *PageInfo) (INextPageInfo, int, int)
- func NewPaginateResultFromData(js *simplejson.Json) INextPageInfo
- func Paginate(objects orm.QuerySeter, page *PageInfo, container interface{}) (INextPageInfo, error)
- type IndexController
- type LockOption
- type Map
- type OpHealthController
- type PageInfo
- type PaginateResult
- type Province
- type RedisLock
- type RepositoryBase
- type Resource
- func (this *Resource) Delete(service string, resource string, data Map) (resp *ResourceResponse, err error)
- func (this *Resource) DisableRetry() *Resource
- func (this *Resource) Get(service string, resource string, data Map) (resp *ResourceResponse, err error)
- func (this *Resource) LoginAs(username string) *Resource
- func (this *Resource) LoginAsManager() *Resource
- func (this *Resource) LoginAsUser(unionid string) *Resource
- func (this *Resource) Post(service string, resource string, data Map) (resp *ResourceResponse, err error)
- func (this *Resource) Put(service string, resource string, data Map) (resp *ResourceResponse, err error)
- type ResourceResponse
- type Response
- type Response2
- type RestProxy
- type RestRequest
- type RestResource
- func (c *RestResource) Delete()
- func (r *RestResource) DisableTx() bool
- func (r *RestResource) EnableHTMLResource() bool
- func (r *RestResource) Finish()
- func (c *RestResource) Get()
- func (r *RestResource) GetAlias() []string
- func (r *RestResource) GetBusinessContext() context.Context
- func (r *RestResource) GetCorpToken() string
- func (r *RestResource) GetFillOptions(key string) FillOption
- func (r *RestResource) GetFilters() map[string]interface{}
- func (r *RestResource) GetIntArray(key string) []int
- func (r *RestResource) GetJSON(key string) map[string]interface{}
- func (r *RestResource) GetJSONArray(key string) []interface{}
- func (r *RestResource) GetLockKey() string
- func (r *RestResource) GetLockOption() *LockOption
- func (r *RestResource) GetParameters() map[string][]string
- func (r *RestResource) GetRawJSON(key string) *simplejson.Json
- func (r *RestResource) GetStringArray(key string) []string
- func (c *RestResource) HandlerFunc(fnname string) bool
- func (c *RestResource) Head()
- func (c *RestResource) Init(ctx *beego_context.Context, controllerName, actionName string, app interface{})
- func (r *RestResource) IsForDevTest() bool
- func (c *RestResource) Mapping(method string, fn func())
- func (c *RestResource) Options()
- func (c *RestResource) Patch()
- func (c *RestResource) Post()
- func (r *RestResource) Prepare()
- func (c *RestResource) Put()
- func (r *RestResource) Resource() string
- func (r *RestResource) ReturnJSON(response *Response)
- func (r *RestResource) SetBeegoController(ctx *beego_context.Context, data map[interface{}]interface{})
- func (c *RestResource) URLMapping()
- type RestResourceInterface
- type ServiceBase
- type Timedelta
- type WsResponse
Constants ¶
const ERROR_TYPE_BUSINESS = 0
const ERROR_TYPE_SYSTEM = 1
const InvalidJwtError = "jwt:invalid_jwt_token"
const MAX_DISTANCE = -1
const SALT string = "030e2cf548cf9da683e340371d1a74ee"
const SERVICE_MODE_CRON = "cron"
const SERVICE_MODE_EVENT = "event"
const SERVICE_MODE_REST = "rest"
Variables ¶
var ( REQUEST_MODE_PROD = "PROD" REQUEST_MODE_TEST = "TEST" REQUEST_HEADER_FORMAT = "Request-Mode" REQUEST_MODE_CTX_KEY = "REQUEST_MODE" )
var AREA = make(map[string][]map[string]interface{})
var Closer io.Closer
var PROVINCEID2ZONE = map[int]string{
1: "直辖市",
2: "直辖市",
3: "华北-东北",
4: "华北-东北",
5: "华北-东北",
6: "华北-东北",
7: "华北-东北",
8: "华北-东北",
9: "直辖市",
10: "华东地区",
11: "华东地区",
12: "华东地区",
13: "华东地区",
14: "华东地区",
15: "华东地区",
16: "华南-华中",
17: "华南-华中",
18: "华南-华中",
19: "华南-华中",
20: "华南-华中",
21: "华南-华中",
22: "直辖市",
23: "西北-西南",
24: "西北-西南",
25: "西北-西南",
26: "西北-西南",
27: "西北-西南",
28: "西北-西南",
29: "西北-西南",
30: "西北-西南",
31: "西北-西南",
32: "其它",
33: "其它",
34: "其它",
}
var RESOURCES = make([]string, 0, 100)
RESOURCES 所有资源名的集合
var Redis *redisStruct = &redisStruct{}
var Tracer opentracing.Tracer
var ZONE_NAMES = []string{"直辖市", "华北-东北", "华东地区", "华南-华中", "西北-西南", "其它"}
Functions ¶
func ExtractUniqueIds ¶
func GetRequestModeFromCtx ¶
GetRequestModeFromCtx 获取请求模式 首先从ctx中获取,如果没有则进行以下判断
生产环境:默认prod 测试环境:如果请求gaia出错,则默认为test
func GetServiceMode ¶
func GetServiceMode() string
func HostDomain ¶
func ParseUserIdFromJwtData ¶
func RecoverFromCronTaskPanic ¶
func RecoverFromCronTaskPanic(ctx go_context.Context)
RecoverFromCronTaskPanic crontask的recover
func RecoverPanic ¶
func RunInGoroutine ¶
func RunInGoroutine(task func())
func Strftime ¶
Strftime formats time.Date according to the directives in the given format string. The directives begins with a percent (%) character.
func ToJsonString ¶
func ToJsonString(obj interface{}) string
Types ¶
type APIServiceNextPageInfo ¶
Mobile模式的分页结果
func (APIServiceNextPageInfo) ToMap ¶
func (this APIServiceNextPageInfo) ToMap() map[string]interface{}
type AreaService ¶
type AreaService struct {
ServiceBase
}
func NewAreaService ¶
func NewAreaService() *AreaService
func (*AreaService) GetAreaByCode ¶
func (this *AreaService) GetAreaByCode(code string) *Area
GetAreaByCode 根据area code(1_1_1)获取area
func (*AreaService) GetAreaByName ¶
func (this *AreaService) GetAreaByName(name string) *Area
GetAreaByName 根据area name(北京市 北京市 东城区)获得area
func (*AreaService) GetCitiesByIds ¶
func (this *AreaService) GetCitiesByIds(ids []int) []*City
func (*AreaService) GetCitiesByNames ¶
func (this *AreaService) GetCitiesByNames(names []string) []*City
func (*AreaService) GetCitiesForProvince ¶
func (this *AreaService) GetCitiesForProvince(provinceId int) []*City
func (*AreaService) GetCityById ¶
func (this *AreaService) GetCityById(id int) *City
func (*AreaService) GetCityByName ¶
func (this *AreaService) GetCityByName(name string) *City
func (*AreaService) GetCityByNameInProvince ¶
func (this *AreaService) GetCityByNameInProvince(provinceId int, name string) *City
func (*AreaService) GetDistrictById ¶
func (this *AreaService) GetDistrictById(id int) *District
func (*AreaService) GetDistrictByName ¶
func (this *AreaService) GetDistrictByName(cityId int, name string) *District
District相关api
func (*AreaService) GetDistrictsByIds ¶
func (this *AreaService) GetDistrictsByIds(ids []int) []*District
func (*AreaService) GetDistrictsByNames ¶
func (this *AreaService) GetDistrictsByNames(cityId int, names []string) []*District
func (*AreaService) GetDistrictsForCity ¶
func (this *AreaService) GetDistrictsForCity(cityId int) []*District
func (*AreaService) GetProvinceById ¶
func (this *AreaService) GetProvinceById(id int) *Province
func (*AreaService) GetProvinceByName ¶
func (this *AreaService) GetProvinceByName(name string) *Province
func (*AreaService) GetProvinces ¶
func (this *AreaService) GetProvinces() []*Province
func (*AreaService) GetProvincesByIds ¶
func (this *AreaService) GetProvincesByIds(ids []int) []*Province
func (*AreaService) GetProvincesByNames ¶
func (this *AreaService) GetProvincesByNames(names []string) []*Province
type BusinessError ¶
func NewBusinessError ¶
func NewBusinessError(code string, msg string) *BusinessError
func NewSystemError ¶
func NewSystemError(code string, msg string) *BusinessError
func (*BusinessError) Error ¶
func (this *BusinessError) Error() string
func (*BusinessError) IsPanicError ¶
func (this *BusinessError) IsPanicError() bool
type ConsoleController ¶
type ConsoleController struct {
beego.Controller
}
func (*ConsoleController) Get ¶
func (c *ConsoleController) Get()
type DingBot ¶
type DingBot struct {
// contains filtered or unexported fields
}
func NewDingBot ¶
func NewDingBot() *DingBot
type District ¶
func NewDistrict ¶
type EntityBase ¶
type FillOption ¶
type GeoService ¶
type GeoService struct {
ServiceBase
}
func NewGeoService ¶
func NewGeoService(ctx context.Context) *GeoService
func (*GeoService) CalculateDistance ¶
func (this *GeoService) CalculateDistance(lat1, lng1, lat2, lng2 float64) float64
func (*GeoService) CalculateDistanceUseStr ¶
func (this *GeoService) CalculateDistanceUseStr(strLat1, strLng1, strLat2, strLng2 string) float64
type IBusinessContextFactory ¶
type ILock ¶
type ILock interface {
Lock(key string, args ...*LockOption) (*redsync.Mutex, error)
}
var Lock ILock //暴露的锁
type INextPageInfo ¶
type INextPageInfo interface {
ToMap() map[string]interface{}
}
INextPageInfo
func MockPaginate ¶
func MockPaginate(itemCount int64, page *PageInfo) INextPageInfo
MockPaginate 模拟进行分页
func MockPaginateV2 ¶
func MockPaginateV2(itemCount int, page *PageInfo) (INextPageInfo, int, int)
MockPaginate 模拟进行分页
func NewPaginateResultFromData ¶
func NewPaginateResultFromData(js *simplejson.Json) INextPageInfo
func Paginate ¶
func Paginate(objects orm.QuerySeter, page *PageInfo, container interface{}) (INextPageInfo, error)
PaginateAndFill 进行分页,并获取填充数据
type IndexController ¶
type IndexController struct {
beego.Controller
}
func (*IndexController) Get ¶
func (c *IndexController) Get()
type LockOption ¶
type LockOption struct {
// contains filtered or unexported fields
}
func NewLockOption ¶
func NewLockOption(key string) *LockOption
func (*LockOption) SetTimeout ¶
func (this *LockOption) SetTimeout(n int) *LockOption
func (*LockOption) SetTryTimes ¶
func (this *LockOption) SetTryTimes(n int) *LockOption
type OpHealthController ¶
type OpHealthController struct {
beego.Controller
}
func (*OpHealthController) Get ¶
func (c *OpHealthController) Get()
type PageInfo ¶
PageInfo 指示当前查询的数据的page信息
func ExtractPageInfoFromRequest ¶
ExtractPageInfoFromRequest 从Request中抽取page信息
func (*PageInfo) IsApiServerMode ¶
type PaginateResult ¶
type PaginateResult struct { HasPrev bool HasNext bool HasHead bool HasTail bool Prev int Next int CurPage int MaxPage int TotalCount int64 DisplayPages []int Offset int CountInPage int }
PaginateResult 分页的结果
func (PaginateResult) ToMap ¶
func (this PaginateResult) ToMap() map[string]interface{}
type Province ¶
func NewProvince ¶
type RedisLock ¶
type RedisLock struct {
// contains filtered or unexported fields
}
RedisLock 基于redis的锁引擎
type RepositoryBase ¶
type Resource ¶
type Resource struct { Ctx context.Context CustomJWTToken string // contains filtered or unexported fields }
RestResource 扩展beego.Controller, 作为rest中各个资源的基类
func NewResource ¶
func (*Resource) DisableRetry ¶
func (*Resource) LoginAsManager ¶
func (*Resource) LoginAsUser ¶
type ResourceResponse ¶
type ResourceResponse struct {
RespData *simplejson.Json
}
func (*ResourceResponse) Bind ¶
func (this *ResourceResponse) Bind(container interface{}) error
Bind 将respData映射到struct,container一定要是指针类型
func (*ResourceResponse) Data ¶
func (this *ResourceResponse) Data() *simplejson.Json
func (*ResourceResponse) IsSuccess ¶
func (this *ResourceResponse) IsSuccess() bool
type Response ¶
type Response struct { Code int32 `json:"code"` Data interface{} `json:"data"` ErrCode string `json:"errCode"` ErrMsg string `json:"errMsg"` InnerErrMsg string `json:"innerErrMsg"` MachineInfo map[string]interface{} `json:"_pod"` }
func MakeErrorResponse ¶
func MakeResponse ¶
func MakeResponse(data interface{}) *Response
func MakeResponse2 ¶
type RestProxy ¶
type RestProxy struct {
RestResource
}
type RestRequest ¶
type RestResource ¶
type RestResource struct { beego.Controller Name2JSON map[string]map[string]interface{} Name2RAWJSON map[string]*simplejson.Json Name2JSONArray map[string][]interface{} Filters map[string]interface{} }
RestResource 扩展beego.Controller, 作为rest中各个资源的基类
func (*RestResource) Delete ¶
func (c *RestResource) Delete()
Delete adds a request function to handle DELETE request.
func (*RestResource) EnableHTMLResource ¶
func (r *RestResource) EnableHTMLResource() bool
EnableHTMLResource 是否开启html资源
func (*RestResource) Finish ¶
func (r *RestResource) Finish()
func (*RestResource) Get ¶
func (c *RestResource) Get()
Get adds a request function to handle GET request.
func (*RestResource) GetBusinessContext ¶
func (r *RestResource) GetBusinessContext() context.Context
func (*RestResource) GetCorpToken ¶
func (r *RestResource) GetCorpToken() string
func (*RestResource) GetFillOptions ¶
func (r *RestResource) GetFillOptions(key string) FillOption
func (*RestResource) GetFilters ¶
func (r *RestResource) GetFilters() map[string]interface{}
返回filters参数与__f标准查询的map数据
func (*RestResource) GetIntArray ¶
func (r *RestResource) GetIntArray(key string) []int
func (*RestResource) GetJSON ¶
func (r *RestResource) GetJSON(key string) map[string]interface{}
GetJSONArray 与key对应的返回json map数据
func (*RestResource) GetJSONArray ¶
func (r *RestResource) GetJSONArray(key string) []interface{}
GetJSONArray 与key对应的返回json array数据
func (*RestResource) GetLockOption ¶
func (r *RestResource) GetLockOption() *LockOption
func (*RestResource) GetParameters ¶
func (r *RestResource) GetParameters() map[string][]string
Parameters 获取需要检查的参数
func (*RestResource) GetRawJSON ¶
func (r *RestResource) GetRawJSON(key string) *simplejson.Json
GetRawJSON 与key对应的返回json数据
func (*RestResource) GetStringArray ¶
func (r *RestResource) GetStringArray(key string) []string
func (*RestResource) HandlerFunc ¶
func (c *RestResource) HandlerFunc(fnname string) bool
HandlerFunc call function with the name
func (*RestResource) Head ¶
func (c *RestResource) Head()
Head adds a request function to handle HEAD request.
func (*RestResource) Init ¶
func (c *RestResource) Init(ctx *beego_context.Context, controllerName, actionName string, app interface{})
Init generates default values of controller operations.
func (*RestResource) IsForDevTest ¶
func (r *RestResource) IsForDevTest() bool
IsForDevTest 是否是开发时支持的资源
func (*RestResource) Mapping ¶
func (c *RestResource) Mapping(method string, fn func())
Mapping the method to function
func (*RestResource) Options ¶
func (c *RestResource) Options()
Options adds a request function to handle OPTIONS request.
func (*RestResource) Patch ¶
func (c *RestResource) Patch()
Patch adds a request function to handle PATCH request.
func (*RestResource) Post ¶
func (c *RestResource) Post()
Post adds a request function to handle POST request.
func (*RestResource) Prepare ¶
func (r *RestResource) Prepare()
Prepare 实现beego.Controller的Prepare函数
func (*RestResource) Put ¶
func (c *RestResource) Put()
Put adds a request function to handle PUT request.
func (*RestResource) ReturnJSON ¶
func (r *RestResource) ReturnJSON(response *Response)
ReturnJSON 返回json response
func (*RestResource) SetBeegoController ¶
func (r *RestResource) SetBeegoController(ctx *beego_context.Context, data map[interface{}]interface{})
func (*RestResource) URLMapping ¶
func (c *RestResource) URLMapping()
URLMapping register the internal RestResource router.
type RestResourceInterface ¶
type RestResourceInterface interface { beego.ControllerInterface Resource() string GetAlias() []string EnableHTMLResource() bool IsForDevTest() bool DisableTx() bool GetParameters() map[string][]string GetBusinessContext() context.Context SetBeegoController(ctx *beego_context.Context, data map[interface{}]interface{}) GetLockKey() string GetLockOption() *LockOption }
type ServiceBase ¶
type Timedelta ¶
type Timedelta struct {
Days, Seconds, Microseconds, Milliseconds, Minutes, Hours, Weeks time.Duration
}
Timedelta represents a duration between two dates. All fields are optional and default to 0. You can initialize any type of timedelta by specifying field values which you want to use.
func (*Timedelta) Duration ¶
Duration() returns time.Duration. time.Duration can be added to time.Date.
type WsResponse ¶
func WsRestRecoverPanic ¶
func WsRestRecoverPanic(err interface{}, ctx *context.Context, restReq RestRequest) (resp WsResponse)
Source Files ¶
- area_service.go
- business_model.go
- context.go
- controller_console.go
- controller_index.go
- controller_op_health.go
- date.go
- ding_bot.go
- error.go
- filter.go
- geo_service.go
- iface.go
- jwt.go
- lock.go
- log_util.go
- machine.go
- page_info.go
- paginator.go
- recover.go
- redis.go
- request_mode.go
- resource.go
- response.go
- rest_resource.go
- router.go
- strftime.go
- timedelta.go
- tracing.go
- util.go
- ws_rest_handler.go
- ws_rest_proxy.go
- ws_rest_recover.go
Directories ¶
Path | Synopsis |
---|---|
Package backoff implements backoff algorithms for retrying operations.
|
Package backoff implements backoff algorithms for retrying operations. |
gogap
|
|
stack
Package stack provides utilities to capture and pass around stack traces.
|
Package stack provides utilities to capture and pass around stack traces. |
BatchConsumer 实现了批量同步的向接收端传送数据的功能
|
BatchConsumer 实现了批量同步的向接收端传送数据的功能 |