ginplus

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

README

hzm-ginplus

介绍

在gin框架基础之上封装,贴合java中SpringMVC的模式

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const (
	AccessToken  = "accessToken"  // 请求token变量名
	RequireLogin = "RequireLogin" // Tag的value项,Permission的固定选项值

)
View Source
const (
	Path       = "Path"
	Permission = "Permission" // 权限tag,支持整个controller类和属性
	Default    = "default"    // 默认值tag
)

controller类tag,代表整个controller的统一属性

View Source
const (
	GetMapping     = "GetMapping"
	PostMapping    = "PostMapping"
	PutMapping     = "PutMapping"
	DeleteMapping  = "DeleteMapping"
	MappingHandler = "MappingHandler"
	RequestParam   = "RequestParam"
)

controller字段tag,这里表示的是方法的属性

View Source
const (
	SucCode    = 200
	SucResult  = true
	FailCode   = -1
	FailResult = false
)

Variables

This section is empty.

Functions

func CacheUserJson2Session

func CacheUserJson2Session(token string, userJson string)

func DeleteSession

func DeleteSession(token string)

func GetAccessToken

func GetAccessToken(ctx *gin.Context) string

func GetCurrentUserJson

func GetCurrentUserJson() string

func GetUserJsonByToken

func GetUserJsonByToken(token string) string

func NewBizErr

func NewBizErr(msg string) error

func NewBizErr2

func NewBizErr2(code int, msg string) error

func SameAsStruct

func SameAsStruct(rtResult reflect.Type) bool

func StartHttpServer

func StartHttpServer(register IGinConfiguration)

func StartHttpServerDefault

func StartHttpServerDefault()

StartHttpServerDefault http服务启动入口

Types

type DefaultGinConfiguration

type DefaultGinConfiguration struct {
}

func (*DefaultGinConfiguration) ContextPath

func (dgc *DefaultGinConfiguration) ContextPath() string

func (*DefaultGinConfiguration) RegisControllers

func (dgc *DefaultGinConfiguration) RegisControllers() []IController

func (*DefaultGinConfiguration) ServerPort

func (dgc *DefaultGinConfiguration) ServerPort() string

type IController

type IController interface {
	RequestMapping() string
}

type IGinConfiguration

type IGinConfiguration interface {

	// ContextPath 项目路径配置
	ContextPath() string

	// ServerPort 服务端口配置
	ServerPort() string

	// RegisControllers 注册控制器
	RegisControllers() []IController
}

IGinConfiguration 接口,要使用ginplus必须实现该接口

type MvcPostProcessor

type MvcPostProcessor interface {
}

type MvcPreProcessor

type MvcPreProcessor interface {
}

type RestController

type RestController struct {
	Path string
}

RestController 所有控制器需要继承的父类

func (RestController) RequestMapping

func (rc RestController) RequestMapping() string

type Result

type Result[T any] struct {
	Code    int    `json:"code"`
	Msg     string `json:"msg"`
	Data    any    `json:"data"`
	Success bool   `json:"success"`
}

func Fail

func Fail(msg string) Result[any]

func Fail2

func Fail2(code int, msg string) Result[any]

func Ok

func Ok() Result[any]

func Ok2

func Ok2[T any](data T) Result[T]

Jump to

Keyboard shortcuts

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