Browse Source

同步章节数据

xyxie 11 months ago
parent
commit
0356998fcc

+ 9 - 0
controllers/report_chapter_type.go

@@ -3,6 +3,7 @@ package controllers
 import (
 	"encoding/json"
 	"hongze/hz_crm_api/models"
+	"hongze/hz_crm_api/services"
 	"hongze/hz_crm_api/utils"
 )
 
@@ -60,6 +61,7 @@ func (this *ReportChapterTypeController) List() {
 			WordsImage:            list[i].YbBottomIcon, // 此处的不一样
 			EditImgUrl:            list[i].EditImgUrl,
 			IsShow:                list[i].IsShow,
+			Enabled:               list[i].Enabled,
 		})
 	}
 
@@ -136,6 +138,13 @@ func (this *ReportChapterTypeController) Edit() {
 		_ = utils.Rc.Delete(key)
 	}
 
+	// 同步eta系统的章节小程序配置
+	go func() {
+		var reqEta services.EditReportChapterTypeSyncReq
+		reqEta.ReportChapterTypeId = req.ReportChapterTypeId
+		_, _ = services.EditReportChapterTypeSync(&reqEta)
+	}()
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 1 - 0
models/report_chapter_type.go

@@ -333,6 +333,7 @@ type ReportChapterTypeListItem struct {
 	WordsImage            string `description:"带字的icon"`
 	EditImgUrl            string `description:"管理后台编辑时选用的图"`
 	IsShow                int    `description:"显示隐藏: 1-显示; 0-隐藏"`
+	Enabled               int    `description:"是否可用,1可用,0禁用"`
 }
 
 // ReportChapterTypeAddReq 新增章节类型请求体

+ 44 - 0
services/report_chapter_type_sync.go

@@ -0,0 +1,44 @@
+package services
+
+import (
+	"encoding/json"
+	"fmt"
+	"hongze/hz_crm_api/services/alarm_msg"
+	"hongze/hz_crm_api/utils"
+)
+
+type EditReportChapterTypeSyncReq struct {
+	ReportChapterTypeId int `description:"报告章节类型id"`
+}
+
+func EditReportChapterTypeSync(pars *EditReportChapterTypeSyncReq) (err error, errMsg string) {
+	defer func() {
+		if err != nil {
+			utils.FileLog.Info("同步章节小程序数据失败, Err: " + err.Error() + errMsg)
+			alarm_msg.SendAlarmMsg("同步章节小程序数据失败,Err:"+err.Error(), 3)
+		}
+	}()
+	if utils.CrmEtaServerUrl == "" {
+		return
+	}
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta/chapter_type/yb/sync")
+	b, err := crmEtaPost(url, pars)
+	if err != nil {
+		errMsg = "更新品种失败"
+		err = fmt.Errorf("url:%s err: %s", url, err.Error())
+		return
+	}
+	result := new(CrmEtaBaseResp)
+	if e := json.Unmarshal(b, &result); e != nil {
+		errMsg = "更新分类失败"
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	utils.FileLog.Info("%s", string(b))
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s, err: %s", string(b), result.ErrMsg)
+		errMsg = result.Msg
+		return
+	}
+	return
+}