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