v2

package module
v1.0.62 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: Apache-2.0 Imports: 27 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

View Source
const BaseConfig = `` /* 1256-byte string literal not displayed */

Variables

View Source
var ConfigPath = gfile.Pwd() + "/manifest/config/config.yaml"

Functions

func AuthAdmin

func AuthAdmin(r *ghttp.Request)

AuthAdmin 鉴权中间件,只有后端登录成功之后才能通过

func AuthBase

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

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

func AuthIndex

func AuthIndex(r *ghttp.Request)

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

func Compress added in v1.0.6

func Compress(filePath string) string

Compress 图片压缩

  • @param filePath string 图片路径
  • @return string
  • 压缩图片

func ConfigInit added in v1.0.6

func ConfigInit()

ConfigInit 初始化配置文件

func CreateCron added in v0.0.6

func CreateCron(ctx context.Context, time string, name string, operate func())

CreateCron 创建定时任务

func CreateDB added in v0.1.0

func CreateDB(ctx context.Context, sqlHost, sqlPort, sqlRoot, sqlPass, baseName string, debug bool)

CreateDB 创建数据库配置

  • @param ctx context.Context
  • @param sqlHost string 数据库地址
  • @param sqlPort string 数据库端口
  • @param sqlRoot string 数据库用户名
  • @param sqlPass string 数据库密码
  • @param baseName string 数据库名
  • @param debug bool 是否开启调试模式

func CreateFileDir added in v1.0.6

func CreateFileDir() error

CreateFileDir 创建文件目录

func GetCapitalPass added in v0.0.6

func GetCapitalPass(val string) string

GetCapitalPass MD5化并转换为大写

func GetResult added in v0.0.6

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

func InStrArray added in v1.0.6

func InStrArray(ext string, code int) bool

InStrArray 判断是否在数组中

  • @param ext string 要判断的字符串
  • @param code int
  • 判断是否在字符串数组中

func LoginJson added in v1.0.6

func LoginJson(r *ghttp.Request, msg string, data ...interface{})

LoginJson 返回登录json数据

  • @param ctx 上下文
  • @param msg 返回信息
  • @param data 返回数据

func MiddlewareError

func MiddlewareError(r *ghttp.Request)

MiddlewareError 异常处理中间件

func NoLogin

func NoLogin(r *ghttp.Request)

NoLogin 未登录返回

func PostResult added in v0.0.6

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

PostResult 建立POST请求并返回结果

func RemoveCron added in v0.0.6

func RemoveCron(name string)

RemoveCron 停止并删除定时任务

func ResAddFile added in v1.0.6

func ResAddFile(onePath string)

ResAddFile 添加文件到资源包

  • @param onePath string
  • 例:gf pack resource/dist internal/boot/boot_resource.go -n boot
  • 需要在boot中 打包引入 并在main.go中引入boot

func ResponseJson

func ResponseJson(ctx context.Context, data interface{})

ResponseJson 返回json数据

  • @param ctx 上下文
  • @param data 返回数据

func SearchCron added in v1.0.6

func SearchCron(name string) *gcron.Entry

SearchCron 查询定时任务运行状态 如果定时任务未运行则返回NIL 运行则返回运行状态

func Sha256 added in v1.0.6

func Sha256(src string) string

Sha256 sha256加密

  • @param src string 被加密字符串
  • @return string
  • 将字符串进行hash加密

func Start

func Start(agent string, maxSessionTime time.Duration, isApi bool, maxBody ...int64) *ghttp.Server

Start 启动服务

  • @param agent string 浏览器标识
  • @param maxSessionTime time.Duration session最大时间
  • @param isApi bool 是否开启api
  • @param maxBody ...int64 最大上传文件大小 默认200M
  • @return *ghttp.Server 服务实例

func StartCrons added in v0.0.6

func StartCrons(name string)

StartCrons 开始指定的定时任

func StopCron added in v0.0.6

func StopCron(name string)

StopCron 紧停止指定定时任务

func Transaction added in v0.0.6

func Transaction(function func() error)

Transaction 简单封装事务操作

Types

type ApiRes

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

func Error

func Error(ctx context.Context) *ApiRes

func Success

func Success(ctx context.Context) *ApiRes

func (*ApiRes) End

func (a *ApiRes) End()

func (*ApiRes) FileDownload added in v1.0.6

func (a *ApiRes) FileDownload(path, name string)

func (*ApiRes) FileSelect added in v1.0.6

func (a *ApiRes) FileSelect(path string)

func (*ApiRes) SetCode

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

func (*ApiRes) SetData

func (a *ApiRes) SetData(data interface{}) *ApiRes

func (*ApiRes) SetMsg

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

type Json

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

type Logs added in v1.0.6

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

type PageSize

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

func SetPage

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

SetPage 设置分页

  • @param page 当前页
  • @param limit 每页显示条数
  • @param total 总条数
  • @param data 返回数据
  • @return PageSize

Jump to

Keyboard shortcuts

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