✨ Init
This commit is contained in:
35
resource/plug_template/api/api.go.tpl
Normal file
35
resource/plug_template/api/api.go.tpl
Normal 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 -}}
|
||||
|
||||
}
|
||||
}
|
7
resource/plug_template/api/enter.go.tpl
Normal file
7
resource/plug_template/api/enter.go.tpl
Normal file
@@ -0,0 +1,7 @@
|
||||
package api
|
||||
|
||||
type ApiGroup struct {
|
||||
{{ .PlugName}}Api
|
||||
}
|
||||
|
||||
var ApiGroupApp = new(ApiGroup)
|
Reference in New Issue
Block a user