Service名称包含模块名,方便将两个模块放一起,解决部分循环依赖,还是前端幸福没有依赖痛苦

This commit is contained in:
xiangheng
2024-07-03 11:49:43 +08:00
parent 7355b4fe8d
commit 4eb8624410
3 changed files with 64 additions and 63 deletions

View File

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

View File

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

View File

@@ -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()