Browse Source

增加了前端api模板

main
pixel 5 years ago
parent
commit
82d1603232
  1. 29
      QMPlusServer/tpl/te/api.go.tpl
  2. 0
      QMPlusServer/tpl/te/model.go.tpl
  3. 0
      QMPlusServer/tpl/te/router.go.tpl

29
QMPlusServer/tpl/te/api.go.tpl

@ -0,0 +1,29 @@
package api
import (
"fmt"
"gin-vue-admin/controller/servers"
"gin-vue-admin/model/modelInterface"
"gin-vue-admin/model/sysModel"
"github.com/gin-gonic/gin"
)
// @Tags {{.StructName}}
// @Summary 创建{{.StructName}}
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body {{.PackageName}}.{{.StructName}} true "创建{{.StructName}}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /{{.Abbreviation}}/create{{.StructName}} [post]
func Create{{.StructName}}(c *gin.Context) {
var {{.Abbreviation}} {{.PackageName}}.{{.StructName}}
_ = c.ShouldBindJSON(&{{.Abbreviation}})
err := {{.Abbreviation}}.Create{{.StructName}}()
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{})
} else {
servers.ReportFormat(c, true, "创建成功", gin.H{})
}
}

0
QMPlusServer/tpl/te/struct.go.tpl → QMPlusServer/tpl/te/model.go.tpl

0
QMPlusServer/tpl/te/router.go.tpl

Loading…
Cancel
Save