|
- package kq
-
- import (
- "context"
- "encoding/json"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/model"
- "gitlink.org.cn/jcce-pcm/utils/tool"
- )
-
- /*
- *
- Listening to the payment flow status change notification message queue
- */
- type ScheduleAiMq struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
-
- func NewScheduleAiMq(ctx context.Context, svcCtx *svc.ServiceContext) *ScheduleAiMq {
- return &ScheduleAiMq{
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
-
- func (l *ScheduleAiMq) Consume(_, val string) error {
- // 接受消息
- var task *types.TaskInfo
- json.Unmarshal([]byte(val), &task)
- ai := model.Ai{
- TaskId: task.TaskId,
- Status: "Saved",
- ServiceName: task.ServiceName,
- YamlString: val,
- }
- tool.Convert(task.Metadata, &ai)
- // 存储数据
- tx := l.svcCtx.DbEngin.Create(&ai)
- if tx.Error != nil {
- return tx.Error
- }
- return nil
- }
|