|
@@ -2,27 +2,35 @@ package v1
|
|
|
|
|
|
import (
|
|
|
"gin-vue-admin/global"
|
|
|
- "gin-vue-admin/model"
|
|
|
- "gin-vue-admin/model/request"
|
|
|
- "gin-vue-admin/model/response"
|
|
|
+ "gin-vue-admin/model/autocode"
|
|
|
+ "gin-vue-admin/model/common/requset"
|
|
|
+ autocodeReq "gin-vue-admin/model/autocode/requset"
|
|
|
+ "gin-vue-admin/model/common/response"
|
|
|
"gin-vue-admin/service"
|
|
|
+ "gin-vue-admin/utils"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"go.uber.org/zap"
|
|
|
)
|
|
|
|
|
|
+type {{.StructName}}Api struct {
|
|
|
+}
|
|
|
+
|
|
|
+var {{.Abbreviation}}Service = service.ServiceGroupApp.AutoCodeServiceGroup.{{.StructName}}Service
|
|
|
+
|
|
|
+
|
|
|
// Create{{.StructName}} 创建{{.StructName}}
|
|
|
// @Tags {{.StructName}}
|
|
|
// @Summary 创建{{.StructName}}
|
|
|
// @Security ApiKeyAuth
|
|
|
// @accept application/json
|
|
|
// @Produce application/json
|
|
|
-// @Param data body model.{{.StructName}} true "创建{{.StructName}}"
|
|
|
+// @Param data body autocode.{{.StructName}} true "创建{{.StructName}}"
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
|
// @Router /{{.Abbreviation}}/create{{.StructName}} [post]
|
|
|
-func Create{{.StructName}}(c *gin.Context) {
|
|
|
+func ({{.Abbreviation}}Api *{{.StructName}}Api) Create{{.StructName}}(c *gin.Context) {
|
|
|
var {{.Abbreviation}} model.{{.StructName}}
|
|
|
_ = c.ShouldBindJSON(&{{.Abbreviation}})
|
|
|
- if err := service.Create{{.StructName}}({{.Abbreviation}}); err != nil {
|
|
|
+ if err := {{.Abbreviation}}Service.Create{{.StructName}}({{.Abbreviation}}); err != nil {
|
|
|
global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
|
|
|
response.FailWithMessage("创建失败", c)
|
|
|
} else {
|
|
@@ -36,13 +44,13 @@ func Create{{.StructName}}(c *gin.Context) {
|
|
|
// @Security ApiKeyAuth
|
|
|
// @accept application/json
|
|
|
// @Produce application/json
|
|
|
-// @Param data body model.{{.StructName}} true "删除{{.StructName}}"
|
|
|
+// @Param data body autocode.{{.StructName}} true "删除{{.StructName}}"
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
|
|
// @Router /{{.Abbreviation}}/delete{{.StructName}} [delete]
|
|
|
-func Delete{{.StructName}}(c *gin.Context) {
|
|
|
- var {{.Abbreviation}} model.{{.StructName}}
|
|
|
+func ({{.Abbreviation}}Api *{{.StructName}}Api) Delete{{.StructName}}(c *gin.Context) {
|
|
|
+ var {{.Abbreviation}} autocode.{{.StructName}}
|
|
|
_ = c.ShouldBindJSON(&{{.Abbreviation}})
|
|
|
- if err := service.Delete{{.StructName}}({{.Abbreviation}}); err != nil {
|
|
|
+ if err := {{.Abbreviation}}Service.Delete{{.StructName}}({{.Abbreviation}}); err != nil {
|
|
|
global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
|
|
|
response.FailWithMessage("删除失败", c)
|
|
|
} else {
|
|
@@ -59,10 +67,10 @@ func Delete{{.StructName}}(c *gin.Context) {
|
|
|
// @Param data body request.IdsReq true "批量删除{{.StructName}}"
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
|
|
|
// @Router /{{.Abbreviation}}/delete{{.StructName}}ByIds [delete]
|
|
|
-func Delete{{.StructName}}ByIds(c *gin.Context) {
|
|
|
+func ({{.Abbreviation}}Api *{{.StructName}}Api) Delete{{.StructName}}ByIds(c *gin.Context) {
|
|
|
var IDS request.IdsReq
|
|
|
_ = c.ShouldBindJSON(&IDS)
|
|
|
- if err := service.Delete{{.StructName}}ByIds(IDS); err != nil {
|
|
|
+ if err := {{.Abbreviation}}Service.Delete{{.StructName}}ByIds(IDS); err != nil {
|
|
|
global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
|
|
|
response.FailWithMessage("批量删除失败", c)
|
|
|
} else {
|
|
@@ -76,13 +84,13 @@ func Delete{{.StructName}}ByIds(c *gin.Context) {
|
|
|
// @Security ApiKeyAuth
|
|
|
// @accept application/json
|
|
|
// @Produce application/json
|
|
|
-// @Param data body model.{{.StructName}} true "更新{{.StructName}}"
|
|
|
+// @Param data body autocode.{{.StructName}} true "更新{{.StructName}}"
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
|
|
// @Router /{{.Abbreviation}}/update{{.StructName}} [put]
|
|
|
-func Update{{.StructName}}(c *gin.Context) {
|
|
|
- var {{.Abbreviation}} model.{{.StructName}}
|
|
|
+func ({{.Abbreviation}}Api *{{.StructName}}Api) Update{{.StructName}}(c *gin.Context) {
|
|
|
+ var {{.Abbreviation}} autocode.{{.StructName}}
|
|
|
_ = c.ShouldBindJSON(&{{.Abbreviation}})
|
|
|
- if err := service.Update{{.StructName}}({{.Abbreviation}}); err != nil {
|
|
|
+ if err := {{.Abbreviation}}Service.Update{{.StructName}}({{.Abbreviation}}); err != nil {
|
|
|
global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
|
|
|
response.FailWithMessage("更新失败", c)
|
|
|
} else {
|
|
@@ -96,13 +104,13 @@ func Update{{.StructName}}(c *gin.Context) {
|
|
|
// @Security ApiKeyAuth
|
|
|
// @accept application/json
|
|
|
// @Produce application/json
|
|
|
-// @Param data body model.{{.StructName}} true "用id查询{{.StructName}}"
|
|
|
+// @Param data body autocode.{{.StructName}} true "用id查询{{.StructName}}"
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
|
|
// @Router /{{.Abbreviation}}/find{{.StructName}} [get]
|
|
|
-func Find{{.StructName}}(c *gin.Context) {
|
|
|
- var {{.Abbreviation}} model.{{.StructName}}
|
|
|
+func ({{.Abbreviation}}Api *{{.StructName}}Api) Find{{.StructName}}(c *gin.Context) {
|
|
|
+ var {{.Abbreviation}} autocode.{{.StructName}}
|
|
|
_ = c.ShouldBindQuery(&{{.Abbreviation}})
|
|
|
- if err, re{{.Abbreviation}} := service.Get{{.StructName}}({{.Abbreviation}}.ID); err != nil {
|
|
|
+ if err, re{{.Abbreviation}} := {{.Abbreviation}}Service.Get{{.StructName}}({{.Abbreviation}}.ID); err != nil {
|
|
|
global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
|
|
|
response.FailWithMessage("查询失败", c)
|
|
|
} else {
|
|
@@ -116,13 +124,13 @@ func Find{{.StructName}}(c *gin.Context) {
|
|
|
// @Security ApiKeyAuth
|
|
|
// @accept application/json
|
|
|
// @Produce application/json
|
|
|
-// @Param data body request.{{.StructName}}Search true "分页获取{{.StructName}}列表"
|
|
|
+// @Param data body autocodeReq.{{.StructName}}Search true "分页获取{{.StructName}}列表"
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
|
// @Router /{{.Abbreviation}}/get{{.StructName}}List [get]
|
|
|
-func Get{{.StructName}}List(c *gin.Context) {
|
|
|
- var pageInfo request.{{.StructName}}Search
|
|
|
+func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}List(c *gin.Context) {
|
|
|
+ var pageInfo autocodeReq.{{.StructName}}Search
|
|
|
_ = c.ShouldBindQuery(&pageInfo)
|
|
|
- if err, list, total := service.Get{{.StructName}}InfoList(pageInfo); err != nil {
|
|
|
+ if err, list, total := {{.Abbreviation}}Service.Get{{.StructName}}InfoList(pageInfo); err != nil {
|
|
|
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
|
|
|
response.FailWithMessage("获取失败", c)
|
|
|
} else {
|