mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 00:10:25 +08:00 
			
		
		
		
	refactor: 使用泛型重构参数绑定等
This commit is contained in:
		@@ -48,7 +48,7 @@ func (p *Procdef) ReqConfs() *req.Confs {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *Procdef) GetProcdefPage(rc *req.Ctx) {
 | 
			
		||||
	cond, page := req.BindQueryAndPage(rc, new(entity.Procdef))
 | 
			
		||||
	cond, page := req.BindQueryAndPage[*entity.Procdef](rc)
 | 
			
		||||
 | 
			
		||||
	res, err := p.procdefApp.GetPageList(cond, page)
 | 
			
		||||
	biz.ErrIsNil(err)
 | 
			
		||||
@@ -87,8 +87,7 @@ func (p *Procdef) GetProcdef(rc *req.Ctx) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Procdef) Save(rc *req.Ctx) {
 | 
			
		||||
	form := &form.Procdef{}
 | 
			
		||||
	procdef := req.BindJsonAndCopyTo(rc, form, new(entity.Procdef))
 | 
			
		||||
	form, procdef := req.BindJsonAndCopyTo[*form.Procdef, *entity.Procdef](rc)
 | 
			
		||||
	rc.ReqParam = form
 | 
			
		||||
	biz.ErrIsNil(a.procdefApp.SaveProcdef(rc.MetaCtx, &dto.SaveProcdef{
 | 
			
		||||
		Procdef:   procdef,
 | 
			
		||||
@@ -98,7 +97,7 @@ func (a *Procdef) Save(rc *req.Ctx) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Procdef) SaveFlowDef(rc *req.Ctx) {
 | 
			
		||||
	form := req.BindJsonAndValid(rc, &form.ProcdefFlow{})
 | 
			
		||||
	form := req.BindJsonAndValid[*form.ProcdefFlow](rc)
 | 
			
		||||
	rc.ReqParam = form
 | 
			
		||||
 | 
			
		||||
	biz.ErrIsNil(a.procdefApp.SaveFlowDef(rc.MetaCtx, &dto.SaveFlowDef{
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@ func (p *Procinst) ReqConfs() *req.Confs {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *Procinst) GetProcinstPage(rc *req.Ctx) {
 | 
			
		||||
	cond := req.BindQuery(rc, new(entity.ProcinstQuery))
 | 
			
		||||
	cond := req.BindQuery[*entity.ProcinstQuery](rc)
 | 
			
		||||
	// 非管理员只能获取自己申请的流程
 | 
			
		||||
	if laId := rc.GetLoginAccount().Id; laId != consts.AdminId {
 | 
			
		||||
		cond.CreatorId = laId
 | 
			
		||||
@@ -47,8 +47,7 @@ func (p *Procinst) GetProcinstPage(rc *req.Ctx) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *Procinst) ProcinstStart(rc *req.Ctx) {
 | 
			
		||||
	startForm := new(form.ProcinstStart)
 | 
			
		||||
	req.BindJsonAndValid(rc, startForm)
 | 
			
		||||
	startForm := req.BindJsonAndValid[*form.ProcinstStart](rc)
 | 
			
		||||
	_, err := p.procinstApp.StartProc(rc.MetaCtx, startForm.ProcdefId, &dto.StarProc{
 | 
			
		||||
		BizType: startForm.BizType,
 | 
			
		||||
		BizForm: jsonx.ToStr(startForm.BizForm),
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ func (p *ProcinstTask) ReqConfs() *req.Confs {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *ProcinstTask) GetTasks(rc *req.Ctx) {
 | 
			
		||||
	instTaskQuery := req.BindQuery(rc, new(entity.ProcinstTaskQuery))
 | 
			
		||||
	instTaskQuery := req.BindQuery[*entity.ProcinstTaskQuery](rc)
 | 
			
		||||
	if laId := rc.GetLoginAccount().Id; laId != consts.AdminId {
 | 
			
		||||
		// 赋值操作人为当前登录账号
 | 
			
		||||
		instTaskQuery.Assignee = fmt.Sprintf("%d", rc.GetLoginAccount().Id)
 | 
			
		||||
@@ -74,7 +74,7 @@ func (p *ProcinstTask) GetTasks(rc *req.Ctx) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *ProcinstTask) PassTask(rc *req.Ctx) {
 | 
			
		||||
	auditForm := req.BindJsonAndValid(rc, new(form.ProcinstTaskAudit))
 | 
			
		||||
	auditForm := req.BindJsonAndValid[*form.ProcinstTaskAudit](rc)
 | 
			
		||||
	rc.ReqParam = auditForm
 | 
			
		||||
 | 
			
		||||
	la := rc.GetLoginAccount()
 | 
			
		||||
@@ -84,7 +84,7 @@ func (p *ProcinstTask) PassTask(rc *req.Ctx) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *ProcinstTask) RejectTask(rc *req.Ctx) {
 | 
			
		||||
	auditForm := req.BindJsonAndValid(rc, new(form.ProcinstTaskAudit))
 | 
			
		||||
	auditForm := req.BindJsonAndValid[*form.ProcinstTaskAudit](rc)
 | 
			
		||||
	rc.ReqParam = auditForm
 | 
			
		||||
 | 
			
		||||
	la := rc.GetLoginAccount()
 | 
			
		||||
@@ -94,7 +94,7 @@ func (p *ProcinstTask) RejectTask(rc *req.Ctx) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *ProcinstTask) BackTask(rc *req.Ctx) {
 | 
			
		||||
	auditForm := req.BindJsonAndValid(rc, new(form.ProcinstTaskAudit))
 | 
			
		||||
	auditForm := req.BindJsonAndValid[*form.ProcinstTaskAudit](rc)
 | 
			
		||||
	rc.ReqParam = auditForm
 | 
			
		||||
	biz.ErrIsNil(p.procinstTaskApp.BackTask(rc.MetaCtx, dto.UserTaskOp{TaskId: auditForm.Id, Remark: auditForm.Remark}))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -104,7 +104,9 @@ func (e *executionAppImpl) MoveTo(ctx *ExecutionCtx, nextNode *entity.FlowNode)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 记录当前节点结束
 | 
			
		||||
	e.hisProcinstOpApp.RecordEnd(ctx, "copmpleted")
 | 
			
		||||
	if err := e.hisProcinstOpApp.RecordEnd(ctx, "copmpleted"); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 下一个节点为空,说明流程已结束
 | 
			
		||||
	if nextNode == nil {
 | 
			
		||||
@@ -163,7 +165,9 @@ func (e *executionAppImpl) executeNode(ctx *ExecutionCtx) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 节点开始操作记录
 | 
			
		||||
	e.hisProcinstOpApp.RecordStart(ctx)
 | 
			
		||||
	if err := e.hisProcinstOpApp.RecordStart(ctx); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 执行节点逻辑
 | 
			
		||||
	return node.Execute(ctx)
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,7 @@ func (p *Procdef) GetFlowDef() *FlowDef {
 | 
			
		||||
	if p.FlowDef == "" {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	flow, err := jsonx.To(p.FlowDef, new(FlowDef))
 | 
			
		||||
	flow, err := jsonx.To[*FlowDef](p.FlowDef)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		logx.ErrorTrace("parse flow def failed", err)
 | 
			
		||||
		return flow
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,7 @@ func (a *Procinst) SetEnd() {
 | 
			
		||||
 | 
			
		||||
// GetProcdefFlow 获取流程定义信息
 | 
			
		||||
func (p *Procinst) GetFlowDef() *FlowDef {
 | 
			
		||||
	flow, err := jsonx.To(p.FlowDef, new(FlowDef))
 | 
			
		||||
	flow, err := jsonx.To[*FlowDef](p.FlowDef)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		logx.ErrorTrace("parse procdef flow failed", err)
 | 
			
		||||
		return flow
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user