123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // Copyright 2019 autocareai.com. All rights reserved.
- // Use of this source code is governed by autocareai.com.
- package handle
- import (
- "gadm-ods/apis"
- "gadm-ods/common.in/clinit"
- "gadm-ods/common.in/utils"
- "gadm-ods/model"
- dutils "gadm-ods/utils"
- "encoding/json"
- "github.com/tidwall/gjson"
- "go.uber.org/zap"
- )
- // 处理手动修改
- func HandleManualAmendmentData(msg *apis.OdsMessage) error {
- // 1 存储到本地
- // 2 发送
- if msg.SourceCode == "" && len(msg.TaskList) <=0 {
- l.Error("func",
- zap.String("call", "HandleManualAmendmentData"),
- zap.String("args", msg.SourceCode),
- zap.String("error", "source code is null"))
- return nil
- }
- manual := &model.ManualAmendment{}
- manual.NewContent = gjson.Get(msg.Content, "new_content").String()
- if manual.NewContent == "" {
- l.Error("func",
- zap.String("call", "HandleManualAmendmentData"),
- zap.String("args", msg.SourceCode),
- zap.String("error", "new content is null "))
- return nil
- }
- manual.Source = msg.SourceCode
- manual.OldContent = gjson.Get(msg.Content, "old_content").String()
- err := manual.Insert(clinit.DB())
- if err != nil {
- return err
- }
- dwsMsg := dutils.NewDwsMessage(msg)
- var dataMapList []map[string]interface{}
- dataMap := make(map[string]interface{})
- json.Unmarshal([]byte(manual.NewContent) ,&dataMap)
- dataMapList = append(dataMapList, dataMap)
- dwsMsg.Content = utils.MarshalJsonString(dataMapList)
- err = dutils.SendDwsMsg(dwsMsg)
-
- return err
- }
|