Files
x_admin/server/controller/admin_ctl/flowController/flow_apply_ctl.go
2025-06-25 01:31:34 +08:00

130 lines
5.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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