v2.5.1 beta2 (#1048)

* 修复日志中间件报文过大的报错问题

* 修复 Token 失效后导致的白屏问题

* 增加自动创建插件模板功能

* 密码加密方式改为 hash

* 增加刷新防抖

Co-authored-by: songzhibin97 <718428482@qq.com>
Co-authored-by: icedays <icedays@163.com>
Co-authored-by: hedeqiang <laravel_code@163.com>
This commit is contained in:
奇淼(piexlmax
2022-04-25 17:34:17 +08:00
committed by GitHub
co-authored by songzhibin97 icedays hedeqiang
parent 843e5a9ad4
commit 6add2094a6
42 changed files with 635 additions and 43 deletions
+43
View File
@@ -0,0 +1,43 @@
## GVA 阿里云短信发送功能插件
#### 开发者:GIN-VUE-ADMIN 官方
### 使用步骤
#### 1. 前往GVA主程序下的initialize/router.go 在Routers 方法最末尾按照你需要的及安全模式添加本插件
例:
本插件可以采用gva的配置文件 也可以直接写死内容作为配置 建议为gva添加配置文件结构 然后将配置传入
PluginInit(PublicGroup, sms.CreateAliSmsPlug("短信的AccessKey ID", "短信的AccessKey Secret", "短信的 SignName"))
### 2. 配置说明
#### 2-1 全局配置结构体说明
type AliSms struct {
AccessKeyId string `mapstructure:"accessKeyId" json:"accessKeyId" yaml:"accessKeyId"` // 短信的AccessKey ID
AccessSecret string `mapstructure:"accessSecret" json:"accessSecret" yaml:"accessSecret"` // 短信的AccessKey Secret
SignName string `mapstructure:"signName" json:"signName" yaml:"signName"` // 短信的 SignName
}
#### 2-2 入参结构说明
type AliModel struct {
Phones []string `json:"phones"` // 需要发送的手机(可传入多个)
TemplateCode string `json:"templateCode"` // 短信模板的code
TemplateParam string `json:"templateParam"` // 短信模板的填充
}
templateParam: 模板使用json字符串 {"code":"xxx"} 对应你模板里面的变量key和value
### 3. 方法API
// 无
### 4. 可直接调用的接口
发送邮件接口接口: /aliSms/sendSms [post] 已配置swagger
入参:
type AliModel struct {
Phones []string `json:"phones"` // 需要发送的手机(可传入多个)
TemplateCode string `json:"templateCode"` // 短信模板的code
TemplateParam string `json:"templateParam"` // 短信模板的填充
}
@@ -0,0 +1,35 @@
package api
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
{{ if .NeedModel }} "github.com/flipped-aurora/gin-vue-admin/server/plugin/{{ .Snake}}/model" {{ end }}
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{ .Snake}}/service"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
type {{ .PlugName}}Api struct{}
// @Tags {{ .PlugName}}
// @Summary 请手动填写接口功能
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}"
// @Router /{{ .RouterGroup}}/routerName[post]
func (p *{{ .PlugName}}Api) ApiName(c *gin.Context) {
{{- if .HasRequest}}
var plug model.Request
_ = c.ShouldBindJSON(&plug)
{{ end -}}
if err{{- if .HasResponse }},res {{ end -}}:= service.ServiceGroupApp.PlugService({{ if .HasRequest }}plug{{ end -}}); err != nil {
global.GVA_LOG.Error("失败!", zap.Error(err))
response.FailWithMessage("失败", c)
} else {
{{if .HasResponse }}
response.OkWithDetailed(res,"成功",c)
{{else}}
response.OkWithData("成功", c)
{{ end -}}
}
}
@@ -0,0 +1,7 @@
package api
type ApiGroup struct {
{{ .PlugName}}Api
}
var ApiGroupApp = new(ApiGroup)
@@ -0,0 +1,9 @@
package config
{{- if .HasGlobal }}
type {{ .PlugName }} struct {
{{- range .Global }}
{{ .Key }} {{ .Type }} {{- if ne .Desc "" }} // {{ .Desc }} {{ end -}}
{{- end }}
}
{{ end -}}
@@ -0,0 +1,8 @@
package global
{{- if .HasGlobal }}
import "github.com/flipped-aurora/gin-vue-admin/server/plugin/{{ .Snake}}/config"
var GlobalConfig = new(config.{{ .PlugName}})
{{ end -}}
+29
View File
@@ -0,0 +1,29 @@
package {{ .Snake}}
import (
{{- if .HasGlobal }}
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{ .Snake}}/global"
{{- end }}
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{ .Snake}}/router"
"github.com/gin-gonic/gin"
)
type {{ .PlugName}}Plugin struct {
}
func Create{{ .PlugName}}Plug({{- range .Global}} {{.Key}} {{.Type}} {{- end }})*{{ .PlugName}}Plugin {
{{- if .HasGlobal }}
{{- range .Global}}
global.GlobalConfig.{{.Key}} = {{.Key}}
{{- end }}
{{ end }}
return &{{ .PlugName}}Plugin{}
}
func (*{{ .PlugName}}Plugin) Register(group *gin.RouterGroup) {
router.RouterGroupApp.Init{{ .PlugName}}Router(group)
}
func (*{{ .PlugName}}Plugin) RouterPath() string {
return "{{ .RouterGroup}}"
}
@@ -0,0 +1,17 @@
package model
{{- if .HasRequest }}
type Request struct {
{{- range .Request }}
{{ .Key }} {{ .Type }} {{- if ne .Desc "" }} // {{ .Desc }} {{ end -}}
{{- end }}
}
{{ end -}}
{{- if .HasResponse }}
type Response struct {
{{- range .Response }}
{{ .Key }} {{ .Type }} {{- if ne .Desc "" }} // {{ .Desc }} {{ end -}}
{{- end }}
}
{{ end -}}
@@ -0,0 +1,7 @@
package router
type RouterGroup struct {
{{ .PlugName}}Router
}
var RouterGroupApp = new(RouterGroup)
@@ -0,0 +1,17 @@
package router
import (
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{ .Snake}}/api"
"github.com/gin-gonic/gin"
)
type {{ .PlugName}}Router struct {
}
func (s *{{ .PlugName}}Router) Init{{ .PlugName}}Router(Router *gin.RouterGroup) {
plugRouter := Router
plugApi := api.ApiGroupApp.{{ .PlugName}}Api
{
plugRouter.POST("routerName", plugApi.ApiName)
}
}
@@ -0,0 +1,7 @@
package service
type ServiceGroup struct {
{{ .PlugName}}Service
}
var ServiceGroupApp = new(ServiceGroup)
@@ -0,0 +1,14 @@
package service
{{- if .NeedModel }}
import (
"github.com/flipped-aurora/gin-vue-admin/server/plugin/{{ .Snake}}/model"
)
{{ end }}
type {{ .PlugName}}Service struct{}
func (e *{{ .PlugName}}Service) PlugService({{- if .HasRequest }}req model.Request {{ end -}}) (err error{{- if .HasResponse }},res model.Response{{ end -}}) {
//
return nil{{- if .HasResponse }},res {{ end }}
}