This commit is contained in:
2023-11-02 04:34:46 +08:00
commit c4548fe498
369 changed files with 40208 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package api
import (
"miniapp/global"
"miniapp/model/common/response"
{{ if .NeedModel }} "miniapp/plugin/{{ .Snake}}/model" {{ end }}
"miniapp/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 {{ if .HasResponse }} res, {{ end }} err:= 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 -}}
}
}

View File

@@ -0,0 +1,7 @@
package api
type ApiGroup struct {
{{ .PlugName}}Api
}
var ApiGroupApp = new(ApiGroup)

View File

@@ -0,0 +1,9 @@
package config
{{- if .HasGlobal }}
type {{ .PlugName }} struct {
{{- range .Global }}
{{ .Key }} {{ .Type }} {{- if ne .Desc "" }} // {{ .Desc }} {{ end -}}
{{- end }}
}
{{ end -}}

View File

@@ -0,0 +1,8 @@
package global
{{- if .HasGlobal }}
import "miniapp/plugin/{{ .Snake}}/config"
var GlobalConfig = new(config.{{ .PlugName}})
{{ end -}}

View File

@@ -0,0 +1,29 @@
package {{ .Snake}}
import (
{{- if .HasGlobal }}
"miniapp/plugin/{{ .Snake}}/global"
{{- end }}
"miniapp/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}}"
}

View File

@@ -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 -}}

View File

@@ -0,0 +1,7 @@
package router
type RouterGroup struct {
{{ .PlugName}}Router
}
var RouterGroupApp = new(RouterGroup)

View File

@@ -0,0 +1,17 @@
package router
import (
"miniapp/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)
}
}

View File

@@ -0,0 +1,7 @@
package service
type ServiceGroup struct {
{{ .PlugName}}Service
}
var ServiceGroupApp = new(ServiceGroup)

View File

@@ -0,0 +1,14 @@
package service
{{- if .NeedModel }}
import (
"miniapp/plugin/{{ .Snake}}/model"
)
{{ end }}
type {{ .PlugName}}Service struct{}
func (e *{{ .PlugName}}Service) PlugService({{- if .HasRequest }}req model.Request {{ end -}}) ({{- if .HasResponse }}res model.Response,{{ end -}} err error) {
//
return {{- if .HasResponse }} res,{{ end }} nil
}