zhangqian
2023-08-26 5193dcb9336e853502baf8a539d3f45efebe2f86
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package api
 
import (
    "srm/global"
    "srm/model/common/response"
{{ if .NeedModel }}    "srm/plugin/{{ .Snake}}/model" {{ end }}
    "srm/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 -}}
 
    }
}