common

package module
v0.1.119 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

README

Copyright 2021 black1552

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthBase

func AuthBase(r *ghttp.Request, name string)

AuthBase 鉴权中间件,只有前端或者后端登录成功之后才能通过

func CreateCron

func CreateCron(time string, name string, operate func())

CreateCron 创建定时任务

func GetCapitalPass

func GetCapitalPass(val string) string

GetCapitalPass MD5化并转换为大写

func GetResult

func GetResult(url string, data g.Map, va *gvar.Var) (string, error)

func MiddlewareError

func MiddlewareError(r *ghttp.Request)

MiddlewareError 异常处理中间件

func NoLogin added in v0.1.114

func NoLogin(r *ghttp.Request)

func PostResult

func PostResult(url string, data g.Map, header string, class string) (string, error)

PostResult 建立POST请求并返回结果

func RemoveCron

func RemoveCron(name string)

RemoveCron 停止并删除定时任务

func ResultVersion

func ResultVersion(r *ghttp.Request, data interface{})

func Start

func Start(time time.Duration)

Start 创建无定时的http

func StartCorn

func StartCorn(time time.Duration, cronTime, name string, cron func())

StartCorn 创建有定时任务的http

func StartCrons added in v0.0.16

func StartCrons(name string)

StartCrons 开始指定的定时任

func StartTcp added in v0.1.111

func StartTcp(time time.Duration, tcpFun func())

StartTcp 创建一个TCP的http

func StartWebSocket added in v0.1.112

func StartWebSocket(time time.Duration, webFun func())

StartWebSocket 创建一个带websocket的http

func StopCron

func StopCron(name string)

StopCron 紧停止指定定时任务

func Transaction

func Transaction(function func() error)

Transaction 简单封装事务操作

Types

type ApiResp

type ApiResp struct {
	// contains filtered or unexported fields
}

func Error

func Error(r *ghttp.Request) *ApiResp

Error 设置错误JSON

func Success

func Success(r *ghttp.Request) *ApiResp

Success 设置成功JSON

func (*ApiResp) End

func (a *ApiResp) End()

End 返回JSON

func (*ApiResp) SetCode

func (a *ApiResp) SetCode(code int) *ApiResp

SetCode 设置状态码

func (*ApiResp) SetDate

func (a *ApiResp) SetDate(data interface{}) *ApiResp

SetDate 设置数据

func (*ApiResp) SetMsg

func (a *ApiResp) SetMsg(msg string) *ApiResp

SetMsg 设置信息

type Json

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

type PageSize

type PageSize struct {
	CurrentPage int         `json:"current_page"`
	Data        interface{} `json:"data"`
	LastPage    int         `json:"last_page"`
	PerPage     int         `json:"per_page"`
	Total       int         `json:"total"`
}

func SetPage

func SetPage(page, limit, total int, data interface{}) *PageSize

SetPage 设置分页

Jump to

Keyboard shortcuts

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