完善生成模版,调整目录

This commit is contained in:
xh
2025-06-25 01:31:34 +08:00
parent cf4e879fe2
commit 915bcfe22c
35 changed files with 57 additions and 67 deletions

View File

@@ -0,0 +1,129 @@
package flowController
import (
"x_admin/config"
"x_admin/core/request"
"x_admin/core/response"
. "x_admin/schema/flowSchema"
"x_admin/service/flowService"
"x_admin/util"
"github.com/gin-gonic/gin"
)
type FlowApplyHandler struct{}
// @Summary 申请流程列表
// @Tags flow_apply-申请流程
// @Produce json
// @Param Token header string true "token"
// @Param PageNo query int true "页码"
// @Param PageSize query int true "每页数量"
// @Param templateId query int false "模板"
// @Param applyUserId query int false "申请人id"
// @Param applyUserNickname query string false "申请人昵称"
// @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 "流程配置"
// @Param status query int false "状态1待提交2审批中3审批完成4审批失败"
// @Success 200 {object} response.Response{data=response.PageResp{lists=[]FlowApplyResp}} "成功"
// @Router /api/admin/flow/flow_apply/list [get]
func (hd FlowApplyHandler) List(c *gin.Context) {
var page request.PageReq
var listReq FlowApplyListReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &page)) {
return
}
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
return
}
res, err := flowService.ApplyService.List(page, listReq)
response.CheckAndRespWithData(c, res, err)
}
// @Summary 申请流程详情
// @Tags flow_apply-申请流程
// @Produce json
// @Param Token header string true "token"
// @Param id query int false "申请id"
// @Success 200 {object} response.Response{data=FlowApplyResp} "成功"
// @Router /api/admin/flow/flow_apply/detail [get]
func (hd FlowApplyHandler) Detail(c *gin.Context) {
var detailReq FlowApplyDetailReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
return
}
res, err := flowService.ApplyService.Detail(detailReq.Id)
response.CheckAndRespWithData(c, res, err)
}
// @Summary 申请流程新增
// @Tags flow_apply-申请流程
// @Produce json
// @Param Token header string true "token"
// @Param templateId body int false "模板"
// @Param applyUserId body int false "申请人id"
// @Param applyUserNickname body string 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 "流程配置"
// @Param status body int false "状态1待提交2审批中3审批完成4审批失败"
// @Success 200 {object} response.Response "成功"
// @Router /api/admin/flow/flow_apply/add [post]
func (hd FlowApplyHandler) Add(c *gin.Context) {
var addReq FlowApplyAddReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &addReq)) {
return
}
var Nickname = config.AdminConfig.GetNickname(c)
var AdminId = config.AdminConfig.GetAdminId(c)
addReq.ApplyUserNickname = Nickname
addReq.ApplyUserId = int(AdminId)
addReq.Status = 1
response.CheckAndResp(c, flowService.ApplyService.Add(addReq))
}
// @Summary 申请流程编辑
// @Tags flow_apply-申请流程
// @Produce json
// @Param Token header string true "token"
// @Param id body int false "申请id"
// @Param templateId body int false "模板"
// @Param applyUserId body int false "申请人id"
// @Param applyUserNickname body string 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 "流程配置"
// @Param status body int false "状态1待提交2审批中3审批完成4审批失败"
// @Success 200 {object} response.Response "成功"
// @Router /api/admin/flow/flow_apply/edit [post]
func (hd FlowApplyHandler) Edit(c *gin.Context) {
var editReq FlowApplyEditReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &editReq)) {
return
}
response.CheckAndResp(c, flowService.ApplyService.Edit(editReq))
}
// @Summary 申请流程删除
// @Tags flow_apply-申请流程
// @Produce json
// @Param Token header string true "token"
// @Param id body int false "申请id"
// @Success 200 {object} response.Response "成功"
// @Router /api/admin/flow/flow_apply/del [post]
func (hd FlowApplyHandler) Del(c *gin.Context) {
var delReq FlowApplyDelReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &delReq)) {
return
}
response.CheckAndResp(c, flowService.ApplyService.Del(delReq.Id))
}

View File

@@ -0,0 +1,197 @@
package flowController
import (
"fmt"
"x_admin/core/request"
"x_admin/core/response"
. "x_admin/schema/flowSchema"
"x_admin/service/flowService"
"x_admin/util"
"github.com/gin-gonic/gin"
)
type FlowHistoryHandler struct {
}
// @Summary 流程历史列表
// @Tags flow_history-流程历史
// @Produce json
// @Param Token header string true "token"
// @Param PageNo query int true "页码"
// @Param PageSize query int true "每页数量"
// @Param applyId query int false "申请id"
// @Param templateId query int false "模板id"
// @Param applyUserId query int false "申请人id"
// @Param applyUserNickname query string false "申请人昵称"
// @Param approverId query int false "审批人id"
// @Param approverNickname query string false "审批用户昵称"
// @Param nodeId query string false "节点"
// @Param formValue query string false "表单值"
// @Param passStatus query int false "通过状态0待处理1通过2拒绝"
// @Param passRemark query string false "通过备注"
// @Success 200 {object} response.Response{data=response.PageResp{lists=[]FlowHistoryResp}} "成功"
// @Router /api/admin/flow/flow_history/list [get]
func (hd FlowHistoryHandler) List(c *gin.Context) {
var page request.PageReq
var listReq = FlowHistoryListReq{
PassStatus: -9999,
}
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &page)) {
return
}
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
return
}
res, err := flowService.HistoryService.List(page, listReq)
response.CheckAndRespWithData(c, res, err)
}
// @Summary 流程历史列表-所有
// @Tags flow_history-流程历史
// @Produce json
// @Success 200 {object} response.Response{data=FlowHistoryResp} "成功"
// @Router /api/admin/flow/flow_history/listAll [get]
func (hd FlowHistoryHandler) ListAll(c *gin.Context) {
var listReq FlowHistoryListReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
return
}
res, err := flowService.HistoryService.ListAll(listReq)
response.CheckAndRespWithData(c, res, err)
}
// @Summary 流程历史详情
// @Tags flow_history-流程历史
// @Produce json
// @Param Token header string true "token"
// @Param id query int false "历史id"
// @Success 200 {object} response.Response{data=FlowHistoryResp} "成功"
// @Router /api/admin/flow/flow_history/detail [get]
func (hd FlowHistoryHandler) Detail(c *gin.Context) {
var detailReq FlowHistoryDetailReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
return
}
res, err := flowService.HistoryService.Detail(detailReq.Id)
response.CheckAndRespWithData(c, res, err)
}
// @Summary 流程历史新增
// @Tags flow_history-流程历史
// @Produce json
// @Param Token header string true "token"
// @Param applyId body int false "申请id"
// @Param templateId body int false "模板id"
// @Param applyUserId body int false "申请人id"
// @Param applyUserNickname body string false "申请人昵称"
// @Param approverId body int false "审批人id"
// @Param approverNickname body string false "审批用户昵称"
// @Param nodeId body string false "节点"
// @Param formValue body string false "表单值"
// @Param passStatus body int false "通过状态0待处理1通过2拒绝"
// @Param passRemark body string false "通过备注"
// @Success 200 {object} response.Response "成功"
// @Router /api/admin/flow/flow_history/add [post]
func (hd FlowHistoryHandler) Add(c *gin.Context) {
var addReq FlowHistoryAddReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &addReq)) {
return
}
response.CheckAndResp(c, flowService.HistoryService.Add(addReq))
}
// @Summary 流程历史编辑
// @Tags flow_history-流程历史
// @Produce json
// @Param Token header string true "token"
// @Param id body int false "历史id"
// @Param applyId body int false "申请id"
// @Param templateId body int false "模板id"
// @Param applyUserId body int false "申请人id"
// @Param applyUserNickname body string false "申请人昵称"
// @Param approverId body int false "审批人id"
// @Param approverNickname body string false "审批用户昵称"
// @Param nodeId body string false "节点"
// @Param formValue body string false "表单值"
// @Param passStatus body int false "通过状态0待处理1通过2拒绝"
// @Param passRemark body string false "通过备注"
// @Success 200 {object} response.Response "成功"
// @Router /api/admin/flow/flow_history/edit [post]
func (hd FlowHistoryHandler) Edit(c *gin.Context) {
var editReq FlowHistoryEditReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &editReq)) {
return
}
response.CheckAndResp(c, flowService.HistoryService.Edit(editReq))
}
// @Summary 流程历史删除
// @Tags flow_history-流程历史
// @Produce json
// @Param Token header string true "token"
// @Param id body int false "历史id"
// @Success 200 {object} response.Response "成功"
// @Router /api/admin/flow/flow_history/del [post]
func (hd FlowHistoryHandler) Del(c *gin.Context) {
var delReq FlowHistoryDelReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &delReq)) {
return
}
response.CheckAndResp(c, flowService.HistoryService.Del(delReq.Id))
}
// 提交申请,通过审批
//
// @Tags flow_history-流程历史
//
// @Router /api/admin/flow/flow_apply/pass [post]
func (hd FlowHistoryHandler) Pass(c *gin.Context) {
var pass PassReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &pass)) {
return
}
err := flowService.HistoryService.Pass(pass)
response.CheckAndResp(c, err)
}
// 拒绝审批
//
// @Tags flow_history-流程历史
//
// @Router /api/admin/flow/flow_apply/back [post]
func (hd FlowHistoryHandler) Back(c *gin.Context) {
var back BackReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &back)) {
return
}
err := flowService.HistoryService.Back(back)
fmt.Println(err)
response.CheckAndResp(c, err)
}
// 获取下一个审批节点,中间可能存在系统任务节点和网关
func (hd FlowHistoryHandler) NextNode(c *gin.Context) {
var nextNode NextNodeReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &nextNode)) {
return
}
res, _, _, err := flowService.HistoryService.GetNextNode(nextNode.ApplyId)
response.CheckAndRespWithData(c, res, err)
}
// 获取节点的可审批用户
func (hd FlowHistoryHandler) GetApprover(c *gin.Context) {
var nextNode NextNodeReq
// var node FlowTree
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &nextNode)) {
return
}
res, err := flowService.HistoryService.GetApprover(nextNode.ApplyId)
if err != nil {
response.FailWithMsg(c, response.Failed, err.Error())
return
}
response.OkWithData(c, res)
}

View File

@@ -0,0 +1,118 @@
package flowController
import (
"x_admin/core/request"
"x_admin/core/response"
. "x_admin/schema/flowSchema"
"x_admin/service/flowService"
"x_admin/util"
"github.com/gin-gonic/gin"
)
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]
func (hd FlowTemplateHandler) List(c *gin.Context) {
var page request.PageReq
var listReq FlowTemplateListReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &page)) {
return
}
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
return
}
res, err := flowService.TemplateService.List(page, listReq)
response.CheckAndRespWithData(c, res, err)
}
// @Summary 流程模板列表-所有
// @Tags flow_template-流程模板
// @Router /api/admin/flow/flow_template/listAll [get]
func (hd FlowTemplateHandler) ListAll(c *gin.Context) {
res, err := flowService.TemplateService.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]
func (hd FlowTemplateHandler) Detail(c *gin.Context) {
var detailReq FlowTemplateDetailReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
return
}
res, err := flowService.TemplateService.Detail(detailReq.Id)
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]
func (hd FlowTemplateHandler) Add(c *gin.Context) {
var addReq FlowTemplateAddReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &addReq)) {
return
}
response.CheckAndResp(c, flowService.TemplateService.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]
func (hd FlowTemplateHandler) Edit(c *gin.Context) {
var editReq FlowTemplateEditReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &editReq)) {
return
}
response.CheckAndResp(c, flowService.TemplateService.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]
func (hd FlowTemplateHandler) Del(c *gin.Context) {
var delReq FlowTemplateDelReq
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &delReq)) {
return
}
response.CheckAndResp(c, flowService.TemplateService.Del(delReq.Id))
}