refactor: 精简base.repo与base.app等

This commit is contained in:
meilin.huang
2024-04-28 23:45:57 +08:00
parent 653953ee76
commit f2c7ef78c0
91 changed files with 758 additions and 957 deletions

View File

@@ -26,7 +26,7 @@ func (p *Procdef) GetProcdef(rc *req.Ctx) {
biz.NotEmpty(defkey, "流程定义key不能为空")
procdef := &entity.Procdef{DefKey: defkey}
biz.ErrIsNil(p.ProcdefApp.GetBy(procdef), "该流程定义不存在")
biz.ErrIsNil(p.ProcdefApp.GetByCond(procdef), "该流程定义不存在")
rc.ResData = procdef
}

View File

@@ -51,7 +51,7 @@ func (p *Procinst) GetProcinstDetail(rc *req.Ctx) {
// 流程实例任务信息
instTasks := new([]*entity.ProcinstTask)
biz.ErrIsNil(p.ProcinstTaskRepo.ListByCond(&entity.ProcinstTask{ProcinstId: pi.Id}, instTasks))
biz.ErrIsNil(p.ProcinstTaskRepo.SelectByCond(&entity.ProcinstTask{ProcinstId: pi.Id}, instTasks))
pivo.ProcinstTasks = *instTasks
rc.ResData = pivo

View File

@@ -41,7 +41,7 @@ func (p *procdefAppImpl) Save(ctx context.Context, def *entity.Procdef) error {
return err
}
if def.Id == 0 {
if p.GetBy(&entity.Procdef{DefKey: def.DefKey}) == nil {
if p.GetByCond(&entity.Procdef{DefKey: def.DefKey}) == nil {
return errorx.NewBiz("该流程实例key已存在")
}
return p.Insert(ctx, def)

View File

@@ -57,7 +57,7 @@ func (p *procinstAppImpl) GetProcinstTasks(condition *entity.ProcinstTaskQuery,
func (p *procinstAppImpl) StartProc(ctx context.Context, procdefKey string, reqParam *StarProcParam) (*entity.Procinst, error) {
procdef := &entity.Procdef{DefKey: procdefKey}
if err := p.procdefApp.GetBy(procdef); err != nil {
if err := p.procdefApp.GetByCond(procdef); err != nil {
return nil, errorx.NewBiz("流程实例[%s]不存在", procdefKey)
}
@@ -208,7 +208,7 @@ func (p *procinstAppImpl) BackTask(ctx context.Context, instTaskId uint64, remar
func (p *procinstAppImpl) cancelInstTasks(ctx context.Context, procinstId uint64, cancelReason string) error {
// 流程实例任务信息
instTasks := new([]*entity.ProcinstTask)
p.procinstTaskRepo.ListByCond(&entity.ProcinstTask{ProcinstId: procinstId, Status: entity.ProcinstTaskStatusProcess}, instTasks)
p.procinstTaskRepo.SelectByCond(&entity.ProcinstTask{ProcinstId: procinstId, Status: entity.ProcinstTaskStatusProcess}, instTasks)
for _, instTask := range *instTasks {
instTask.Status = entity.ProcinstTaskStatusCanceled
instTask.Remark = cancelReason

View File

@@ -4,7 +4,6 @@ import (
"mayfly-go/internal/flow/domain/entity"
"mayfly-go/internal/flow/domain/repository"
"mayfly-go/pkg/base"
"mayfly-go/pkg/gormx"
"mayfly-go/pkg/model"
)
@@ -17,8 +16,8 @@ func newProcdefRepo() repository.Procdef {
}
func (p *procdefImpl) GetPageList(condition *entity.Procdef, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
qd := gormx.NewQuery(new(entity.Procdef)).
qd := model.NewCond().
Like("name", condition.Name).
Like("def_key", condition.DefKey)
return gormx.PageQuery(qd, pageParam, toEntity)
return p.PageByCond(qd, pageParam, toEntity)
}

View File

@@ -4,7 +4,6 @@ import (
"mayfly-go/internal/flow/domain/entity"
"mayfly-go/internal/flow/domain/repository"
"mayfly-go/pkg/base"
"mayfly-go/pkg/gormx"
"mayfly-go/pkg/model"
)
@@ -17,8 +16,8 @@ func newProcinstRepo() repository.Procinst {
}
func (p *procinstImpl) GetPageList(condition *entity.ProcinstQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
qd := gormx.NewQuery(new(entity.Procinst)).WithCondModel(condition)
return gormx.PageQuery(qd, pageParam, toEntity)
qd := model.NewModelCond(condition)
return p.PageByCond(qd, pageParam, toEntity)
}
//-----------procinst task--------------
@@ -32,6 +31,6 @@ func newProcinstTaskRepo() repository.ProcinstTask {
}
func (p *procinstTaskImpl) GetPageList(condition *entity.ProcinstTaskQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
qd := gormx.NewQuery(new(entity.ProcinstTask)).WithCondModel(condition)
return gormx.PageQuery(qd, pageParam, toEntity)
qd := model.NewModelCond(condition)
return p.PageByCond(qd, pageParam, toEntity)
}