Bladeren bron

同步章节变更

xyxie 1 jaar geleden
bovenliggende
commit
755792e414

+ 43 - 0
controller/eta/report_chapter_type.go

@@ -0,0 +1,43 @@
+package eta
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/go-playground/validator/v10"
+	"hongze/hz_crm_eta/controller/resp"
+	"hongze/hz_crm_eta/global"
+	"hongze/hz_crm_eta/models/eta"
+	etaService "hongze/hz_crm_eta/services/eta"
+)
+
+type ReportChapterTypeController struct{}
+
+// YbSync
+// @Title 同步报告章节小程序信息
+// @Description 同步报告章节小程序信息
+// @Param	request  body  eta.ReportChapterTypeSyncReq  true  "type json string"
+// @Success 200 string "操作成功"
+// @router /chapter_type/yb/sync [post]
+func (this *ReportChapterTypeController) YbSync(c *gin.Context) {
+	var req eta.ReportChapterTypeSyncReq
+	err := c.Bind(&req)
+	if err != nil {
+		errs, ok := err.(validator.ValidationErrors)
+		if !ok {
+			resp.FailData("参数解析失败", "Err:"+err.Error(), c)
+			return
+		}
+		resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
+		return
+	}
+	if req.ReportChapterTypeId <= 0 {
+		resp.Fail("报告章节序号不能为空", c)
+		return
+	}
+	e, msg := etaService.SyncReportChapterType(&req)
+	if e != nil {
+		resp.FailData(msg, e.Error(), c)
+		return
+	}
+
+	resp.Ok("操作成功", c)
+}

+ 5 - 0
models/eta/report_chapter_type.go

@@ -40,6 +40,11 @@ type ChapterTypeReq struct {
 	ReportType string
 }
 
+type ReportChapterTypeSyncReq struct {
+	ReportChapterTypeId int    `description:"报告章节类型id"`
+	ResearchType        string `description:"研报类型"`
+}
+
 // GetReportChapterType 获取章节类型列表
 func GetReportChapterType(condition string, pars []interface{}) (items []*ReportChapterType, err error) {
 	err = global.MYSQL["rddp"].Model(ReportChapterType{}).Where(condition, pars...).Order("sort ASC, created_time DESC").Scan(&items).Error

+ 6 - 0
routers/report_chapter_type.go

@@ -3,10 +3,16 @@ package routers
 import (
 	"github.com/gin-gonic/gin"
 	"hongze/hz_crm_eta/controller/crm"
+	"hongze/hz_crm_eta/controller/eta"
 )
 
 func InitReportChapterType(r *gin.RouterGroup) {
 	control := new(crm.ReportChapterTypeController)
 	group := r.Group("crm/chapter_type")
 	group.POST("sync", control.Sync)
+
+	controlEta := new(eta.ReportChapterTypeController)
+	groupEta := r.Group("eta/chapter_type")
+	groupEta.POST("yb/sync", controlEta.YbSync)
+
 }

+ 65 - 0
services/eta/report_chapter_type.go

@@ -0,0 +1,65 @@
+package eta
+
+import (
+	"fmt"
+	"hongze/hz_crm_eta/models/crm"
+	"hongze/hz_crm_eta/models/eta"
+	"hongze/hz_crm_eta/utils"
+)
+
+// SyncReportChapterType  同步报表章节类型
+func SyncReportChapterType(req *eta.ReportChapterTypeSyncReq) (err error, errMsg string) {
+	//查询是否存在品种
+	etaOb := new(crm.ReportChapterType)
+	item, e := etaOb.GetReportChapterTypeById(req.ReportChapterTypeId)
+	if e != nil {
+		if e == utils.ErrNoRow {
+			err = fmt.Errorf("章节不存在")
+			return
+		}
+		errMsg = "查询章节信息失败"
+		err = fmt.Errorf("查询章节信息失败, Err: " + e.Error())
+		return
+	}
+	if item.ReportChapterTypeId <= 0 {
+		err = fmt.Errorf("章节不存在")
+		return
+	}
+	ob := &eta.ReportChapterType{
+		ReportChapterTypeId: item.ReportChapterTypeId,
+		//ReportChapterTypeKey:   item.ReportChapterTypeKey,
+		ReportChapterTypeThumb: item.ReportChapterTypeThumb,
+		BannerUrl:              item.BannerUrl,
+		/*ReportChapterTypeName:  item.ReportChapterTypeName,
+		Sort:                   item.Sort,
+		Enabled:                item.Enabled,
+		CreatedTime:            item.CreatedTime,
+		LastUpdatedTime:        item.LastUpdatedTime,
+		ResearchType:           item.ResearchType,*/
+		SelectedImage:     item.SelectedImage,
+		UnselectedImage:   item.UnselectedImage,
+		PcSelectedImage:   item.PcSelectedImage,
+		PcUnselectedImage: item.PcUnselectedImage,
+		EditImgUrl:        item.EditImgUrl,
+		//	TickerTitle:            item.TickerTitle,
+		IsShow: item.IsShow,
+		//PauseStartTime:         item.PauseStartTime,
+		//PauseEndTime:           item.PauseEndTime,
+		//IsSet:                  item.IsSet,
+		YbIconUrl:    item.YbIconUrl,
+		YbBottomIcon: item.YbBottomIcon,
+		//YbHidden:               item.YbHidden,
+	}
+
+	updateCols := []string{"SelectedImage", "UnselectedImage",
+		"PcSelectedImage", "PcUnselectedImage", "EditImgUrl", "YbIconUrl", "YbBottomIcon", "IsShow",
+		"ReportChapterTypeThumb", "BannerUrl",
+	}
+	err = ob.Update(updateCols)
+	if err != nil {
+		errMsg = "更新失败"
+		err = fmt.Errorf("更新章节类型失败, Err: " + err.Error())
+		return
+	}
+	return
+}