2 Star 2 Fork 4

联犀/core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
opsWorkOrderUpdateLogic.go 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
杨磊 提交于 2024-10-22 14:47 . feat: 添加工作流完成通知
package opslogic
import (
"context"
"database/sql"
"gitee.com/unitedrhino/core/service/syssvr/internal/repo/relationDB"
"gitee.com/unitedrhino/core/service/syssvr/internal/svc"
"gitee.com/unitedrhino/core/service/syssvr/pb/sys"
"gitee.com/unitedrhino/share/domain/ops"
"gitee.com/unitedrhino/share/eventBus"
"github.com/zeromicro/go-zero/core/logx"
"time"
)
type OpsWorkOrderUpdateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewOpsWorkOrderUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OpsWorkOrderUpdateLogic {
return &OpsWorkOrderUpdateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *OpsWorkOrderUpdateLogic) OpsWorkOrderUpdate(in *sys.OpsWorkOrder) (*sys.Empty, error) {
old, err := relationDB.NewOpsWorkOrderRepo(l.ctx).FindOne(l.ctx, in.Id)
if err != nil {
return nil, err
}
var isFinish bool
if in.Status != 0 && in.Status > old.Status {
switch in.Status {
case ops.WorkOrderStatusHandling:
if old.Status == ops.WorkOrderStatusWait {
old.Status = in.Status
old.HandleTime = sql.NullTime{Valid: true, Time: time.Now()}
}
case ops.WorkOrderStatusFinished:
if old.Status == ops.WorkOrderStatusHandling {
old.Status = in.Status
old.FinishedTime = sql.NullTime{Valid: true, Time: time.Now()}
isFinish = true
}
}
}
err = relationDB.NewOpsWorkOrderRepo(l.ctx).Update(l.ctx, old)
if err == nil && isFinish {
err = l.svcCtx.FastEvent.Publish(l.ctx, eventBus.SysCoreOpsWorkOrderFinish, old.ID)
if err != nil {
l.Error(err)
}
}
return &sys.Empty{}, err
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/unitedrhino/core.git
git@gitee.com:unitedrhino/core.git
unitedrhino
core
core
v1.1.3

搜索帮助

0d507c66 1850385 C8b1a773 1850385