From 4eb8624410428e17b3797e562541345e4e2692f2 Mon Sep 17 00:00:00 2001 From: xiangheng <11675084@qq.com> Date: Wed, 3 Jul 2024 11:49:43 +0800 Subject: [PATCH] =?UTF-8?q?Service=E5=90=8D=E7=A7=B0=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=90=8D=EF=BC=8C=E6=96=B9=E4=BE=BF=E5=B0=86?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E6=A8=A1=E5=9D=97=E6=94=BE=E4=B8=80=E8=B5=B7?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E9=83=A8=E5=88=86=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=EF=BC=8C=E8=BF=98=E6=98=AF=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E5=B9=B8=E7=A6=8F=E6=B2=A1=E6=9C=89=E4=BE=9D=E8=B5=96=E7=97=9B?= =?UTF-8?q?=E8=8B=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flow/flow_template/flow_template_ctl.go | 109 +++++++++--------- .../templates/gocode/controller.go.tpl | 16 +-- .../tpl_utils/templates/gocode/service.go.tpl | 2 +- 3 files changed, 64 insertions(+), 63 deletions(-) diff --git a/server/admin/flow/flow_template/flow_template_ctl.go b/server/admin/flow/flow_template/flow_template_ctl.go index 19284be..d7a0439 100644 --- a/server/admin/flow/flow_template/flow_template_ctl.go +++ b/server/admin/flow/flow_template/flow_template_ctl.go @@ -8,21 +8,22 @@ import ( "github.com/gin-gonic/gin" ) -type FlowTemplateHandler struct{} +type FlowTemplateHandler struct { +} -// @Summary 流程模板列表 -// @Tags flow_template-流程模板 -// @Produce json -// @Param Token header string true "token" -// @Param PageNo query int true "页码" -// @Param PageSize query int true "每页数量" -// @Param flowName query string false "流程名称" -// @Param flowGroup query int false "流程分类" -// @Param flowRemark query string false "流程描述" -// @Param flowFormData query string false "表单配置" -// @Param flowProcessData query string false "流程配置" -// @Success 200 {object} response.Response{data=response.PageResp{lists=[]FlowTemplateResp}} "成功" -// @Router /api/admin/flow/flow_template/list [get] +// @Summary 流程模板列表 +// @Tags flow_template-流程模板 +// @Produce json +// @Param Token header string true "token" +// @Param PageNo query int true "页码" +// @Param PageSize query int true "每页数量" +// @Param flowName query string false "流程名称" +// @Param flowGroup query int false "流程分类" +// @Param flowRemark query string false "流程描述" +// @Param flowFormData query string false "表单配置" +// @Param flowProcessData query string false "流程配置" +// @Success 200 {object} response.Response{data=response.PageResp{lists=[]FlowTemplateResp}} "成功" +// @Router /api/admin/flow/flow_template/list [get] func (hd FlowTemplateHandler) List(c *gin.Context) { var page request.PageReq var listReq FlowTemplateListReq @@ -36,21 +37,21 @@ func (hd FlowTemplateHandler) List(c *gin.Context) { response.CheckAndRespWithData(c, res, err) } -// @Summary 流程模板列表-所有 -// @Tags flow_template-流程模板 -// @Router /api/admin/flow/flow_template/listAll [get] +// @Summary 流程模板列表-所有 +// @Tags flow_template-流程模板 +// @Router /api/admin/flow/flow_template/listAll [get] func (hd FlowTemplateHandler) ListAll(c *gin.Context) { res, err := Service.ListAll() response.CheckAndRespWithData(c, res, err) } -// @Summary 流程模板详情 -// @Tags flow_template-流程模板 -// @Produce json -// @Param Token header string true "token" -// @Param id query int false "历史id" -// @Success 200 {object} FlowTemplateResp "成功" -// @Router /api/admin/flow/flow_template/detail [get] +// @Summary 流程模板详情 +// @Tags flow_template-流程模板 +// @Produce json +// @Param Token header string true "token" +// @Param id query int false "历史id" +// @Success 200 {object} FlowTemplateResp "成功" +// @Router /api/admin/flow/flow_template/detail [get] func (hd FlowTemplateHandler) Detail(c *gin.Context) { var detailReq FlowTemplateDetailReq if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) { @@ -60,17 +61,17 @@ func (hd FlowTemplateHandler) Detail(c *gin.Context) { response.CheckAndRespWithData(c, res, err) } -// @Summary 流程模板新增 -// @Tags flow_template-流程模板 -// @Produce json -// @Param Token header string true "token" -// @Param flowName body string false "流程名称" -// @Param flowGroup body int false "流程分类" -// @Param flowRemark body string false "流程描述" -// @Param flowFormData body string false "表单配置" -// @Param flowProcessData body string false "流程配置" -// @Success 200 {object} response.Response "成功" -// @Router /api/admin/flow/flow_template/add [post] +// @Summary 流程模板新增 +// @Tags flow_template-流程模板 +// @Produce json +// @Param Token header string true "token" +// @Param flowName body string false "流程名称" +// @Param flowGroup body int false "流程分类" +// @Param flowRemark body string false "流程描述" +// @Param flowFormData body string false "表单配置" +// @Param flowProcessData body string false "流程配置" +// @Success 200 {object} response.Response "成功" +// @Router /api/admin/flow/flow_template/add [post] func (hd FlowTemplateHandler) Add(c *gin.Context) { var addReq FlowTemplateAddReq if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &addReq)) { @@ -79,18 +80,18 @@ func (hd FlowTemplateHandler) Add(c *gin.Context) { response.CheckAndResp(c, Service.Add(addReq)) } -// @Summary 流程模板编辑 -// @Tags flow_template-流程模板 -// @Produce json -// @Param Token header string true "token" -// @Param id body int false "." -// @Param flowName body string false "流程名称" -// @Param flowGroup body int false "流程分类" -// @Param flowRemark body string false "流程描述" -// @Param flowFormData body string false "表单配置" -// @Param flowProcessData body string false "流程配置" -// @Success 200 {object} response.Response "成功" -// @Router /api/admin/flow/flow_template/edit [post] +// @Summary 流程模板编辑 +// @Tags flow_template-流程模板 +// @Produce json +// @Param Token header string true "token" +// @Param id body int false "." +// @Param flowName body string false "流程名称" +// @Param flowGroup body int false "流程分类" +// @Param flowRemark body string false "流程描述" +// @Param flowFormData body string false "表单配置" +// @Param flowProcessData body string false "流程配置" +// @Success 200 {object} response.Response "成功" +// @Router /api/admin/flow/flow_template/edit [post] func (hd FlowTemplateHandler) Edit(c *gin.Context) { var editReq FlowTemplateEditReq if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &editReq)) { @@ -99,13 +100,13 @@ func (hd FlowTemplateHandler) Edit(c *gin.Context) { response.CheckAndResp(c, Service.Edit(editReq)) } -// @Summary 流程模板删除 -// @Tags flow_template-流程模板 -// @Produce json -// @Param Token header string true "token" -// @Param id body int false "历史id" -// @Success 200 {object} response.Response "成功" -// @Router /api/admin/flow/flow_template/del [post] +// @Summary 流程模板删除 +// @Tags flow_template-流程模板 +// @Produce json +// @Param Token header string true "token" +// @Param id body int false "历史id" +// @Success 200 {object} response.Response "成功" +// @Router /api/admin/flow/flow_template/del [post] func (hd FlowTemplateHandler) Del(c *gin.Context) { var delReq FlowTemplateDelReq if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &delReq)) { diff --git a/server/admin/generator/tpl_utils/templates/gocode/controller.go.tpl b/server/admin/generator/tpl_utils/templates/gocode/controller.go.tpl index a0a72fe..4fe0c47 100644 --- a/server/admin/generator/tpl_utils/templates/gocode/controller.go.tpl +++ b/server/admin/generator/tpl_utils/templates/gocode/controller.go.tpl @@ -40,7 +40,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) List(c *gin.Context) { if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) { return } - res, err := Service.List(page, listReq) + res, err := {{{ title (toCamelCase .EntityName) }}}Service.List(page, listReq) response.CheckAndRespWithData(c, res, err) } @@ -64,7 +64,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) ListAll(c *gin.Context if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) { return } - res, err := Service.ListAll(listReq) + res, err := {{{ title (toCamelCase .EntityName) }}}Service.ListAll(listReq) response.CheckAndRespWithData(c, res, err) } @@ -84,7 +84,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Detail(c *gin.Context) if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) { return } - res, err := Service.Detail(detailReq.{{{ title (toCamelCase .PrimaryKey) }}}) + res, err := {{{ title (toCamelCase .EntityName) }}}Service.Detail(detailReq.{{{ title (toCamelCase .PrimaryKey) }}}) response.CheckAndRespWithData(c, res, err) } @@ -105,7 +105,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Add(c *gin.Context) { if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &addReq)) { return } - response.CheckAndResp(c, Service.Add(addReq)) + response.CheckAndResp(c, {{{ title (toCamelCase .EntityName) }}}Service.Add(addReq)) } // @Summary {{{ .FunctionName }}}编辑 // @Tags {{{ .ModuleName }}}-{{{ .FunctionName }}} @@ -123,7 +123,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Edit(c *gin.Context) { if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &editReq)) { return } - response.CheckAndResp(c, Service.Edit(editReq)) + response.CheckAndResp(c, {{{ title (toCamelCase .EntityName) }}}Service.Edit(editReq)) } // @Summary {{{ .FunctionName }}}删除 // @Tags {{{ .ModuleName }}}-{{{ .FunctionName }}} @@ -141,7 +141,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Del(c *gin.Context) { if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &delReq)) { return } - response.CheckAndResp(c, Service.Del(delReq.{{{ title (toCamelCase .PrimaryKey) }}})) + response.CheckAndResp(c, {{{ title (toCamelCase .EntityName) }}}Service.Del(delReq.{{{ title (toCamelCase .PrimaryKey) }}})) } @@ -166,7 +166,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) ExportFile(c *gin.Cont if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) { return } - res, err := Service.ExportFile(listReq) + res, err := {{{ title (toCamelCase .EntityName) }}}Service.ExportFile(listReq) if err != nil { response.FailWithMsg(c, response.SystemError, "查询信息失败") return @@ -199,6 +199,6 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) ImportFile(c *gin.Cont // for _, t := range importList { // fmt.Printf("%#v", t) // } - err = Service.ImportFile(importList) + err = {{{ title (toCamelCase .EntityName) }}}Service.ImportFile(importList) response.CheckAndResp(c, err) } \ No newline at end of file diff --git a/server/admin/generator/tpl_utils/templates/gocode/service.go.tpl b/server/admin/generator/tpl_utils/templates/gocode/service.go.tpl index 617237a..f7d3f9e 100644 --- a/server/admin/generator/tpl_utils/templates/gocode/service.go.tpl +++ b/server/admin/generator/tpl_utils/templates/gocode/service.go.tpl @@ -8,7 +8,7 @@ import ( "gorm.io/gorm" ) -var Service=New{{{ title (toCamelCase .EntityName) }}}Service() +var {{{ title (toCamelCase .EntityName) }}}Service=New{{{ title (toCamelCase .EntityName) }}}Service() // New{{{ title (toCamelCase .EntityName) }}}Service 初始化 func New{{{ title (toCamelCase .EntityName) }}}Service() *{{{ toCamelCase .EntityName }}}Service { db := core.GetDB()