Browse Source

fix:修复同步章节类型的Bug

Roc 7 months ago
parent
commit
a0058628ba

+ 26 - 25
models/crm/report_chapter_type.go

@@ -7,31 +7,32 @@ import (
 )
 
 type ReportChapterType struct {
-	ReportChapterTypeId        int       `gorm:"column:report_chapter_type_id;primary_key;AUTO_INCREMENT;NOT NULL;comment:'报告章节类型id'"`
-	ReportChapterTypeKey       string    `gorm:"column:report_chapter_type_key;default:NULL;comment:'章节key'"`
-	ReportChapterTypeThumb     string    `gorm:"column:report_chapter_type_thumb;default:NULL;comment:'H5展示的图片'"`
-	BannerUrl                  string    `gorm:"column:banner_url;default:NULL;comment:'banner显示图片'"`
-	ReportChapterTypeName      string    `gorm:"column:report_chapter_type_name;default:NULL;comment:'报告章节类型名称'"`
-	Sort                       int       `gorm:"column:sort;default:0;NOT NULL;comment:'排序字段'"`
-	Enabled                    int       `gorm:"column:enabled;default:NULL;comment:'报告类型状态'"`
-	CreatedTime                time.Time `gorm:"column:created_time;default:CURRENT_TIMESTAMP;comment:'创建时间'"`
-	LastUpdatedTime            time.Time `gorm:"column:last_updated_time;default:CURRENT_TIMESTAMP;NOT NULL"`
-	ResearchType               string    `gorm:"column:research_type;default:week;comment:'研报类型'"`
-	SelectedImage              string    `gorm:"column:selected_image;default:NULL;comment:'选中时的图片'"`
-	UnselectedImage            string    `gorm:"column:unselected_image;default:NULL;comment:'没选中时的图片'"`
-	PcSelectedImage            string    `gorm:"column:pc_selected_image;default:NULL;comment:'选中时的图片'"`
-	PcUnselectedImage          string    `gorm:"column:pc_unselected_image;default:NULL;comment:'没选中时的图片'"`
-	EditImgUrl                 string    `gorm:"column:edit_img_url;default:NULL;comment:'管理后台编辑时选用的图'"`
-	TickerTitle                string    `gorm:"column:ticker_title;default:NULL;comment:'指标列的标题'"`
-	IsShow                     int       `gorm:"column:is_show;default:1;comment:'是否显示'"`
-	PauseStartTime             string    `gorm:"column:pause_start_time;default:NULL;comment:'暂停开始日期'"`
-	PauseEndTime               string    `gorm:"column:pause_end_time;default:NULL;comment:'暂停结束日期'"`
-	IsSet                      int       `gorm:"column:is_set;default:0;comment:'是否设置:0为设置,1已设置'"`
-	YbIconUrl                  string    `gorm:"column:yb_icon_url;default:NULL;comment:'研报小程序3.0图标地址'"`
-	YbBottomIcon               string    `gorm:"column:yb_bottom_icon;default:NULL;comment:'研报小程序3.0底部菜单图标地址'"`
-	YbHidden                   uint      `gorm:"column:yb_hidden;default:0;NOT NULL;comment:'研报小程序隐藏章节: 0-显示; 1-隐藏'"`
-	ReportClassifyId           int       `description:"所属分类id"`
-	InheritReportChapterTypeId int       `description:"继承的报告章节类型id"`
+	ReportChapterTypeId    int       `gorm:"column:report_chapter_type_id;primary_key;AUTO_INCREMENT;NOT NULL;comment:'报告章节类型id'"`
+	ReportChapterTypeKey   string    `gorm:"column:report_chapter_type_key;default:NULL;comment:'章节key'"`
+	ReportChapterTypeThumb string    `gorm:"column:report_chapter_type_thumb;default:NULL;comment:'H5展示的图片'"`
+	BannerUrl              string    `gorm:"column:banner_url;default:NULL;comment:'banner显示图片'"`
+	ReportChapterTypeName  string    `gorm:"column:report_chapter_type_name;default:NULL;comment:'报告章节类型名称'"`
+	Sort                   int       `gorm:"column:sort;default:0;NOT NULL;comment:'排序字段'"`
+	Enabled                int       `gorm:"column:enabled;default:NULL;comment:'报告类型状态'"`
+	CreatedTime            time.Time `gorm:"column:created_time;default:CURRENT_TIMESTAMP;comment:'创建时间'"`
+	LastUpdatedTime        time.Time `gorm:"column:last_updated_time;default:CURRENT_TIMESTAMP;NOT NULL"`
+	ResearchType           string    `gorm:"column:research_type;default:week;comment:'研报类型'"`
+	SelectedImage          string    `gorm:"column:selected_image;default:NULL;comment:'选中时的图片'"`
+	UnselectedImage        string    `gorm:"column:unselected_image;default:NULL;comment:'没选中时的图片'"`
+	PcSelectedImage        string    `gorm:"column:pc_selected_image;default:NULL;comment:'选中时的图片'"`
+	PcUnselectedImage      string    `gorm:"column:pc_unselected_image;default:NULL;comment:'没选中时的图片'"`
+	EditImgUrl             string    `gorm:"column:edit_img_url;default:NULL;comment:'管理后台编辑时选用的图'"`
+	TickerTitle            string    `gorm:"column:ticker_title;default:NULL;comment:'指标列的标题'"`
+	//IsShow                     int       `gorm:"column:is_show;default:1;comment:'是否显示'"`
+	IsShow                     int    `gorm:"column:is_show;default:0;comment:'是否显示'"`
+	PauseStartTime             string `gorm:"column:pause_start_time;default:NULL;comment:'暂停开始日期'"`
+	PauseEndTime               string `gorm:"column:pause_end_time;default:NULL;comment:'暂停结束日期'"`
+	IsSet                      int    `gorm:"column:is_set;default:0;comment:'是否设置:0为设置,1已设置'"`
+	YbIconUrl                  string `gorm:"column:yb_icon_url;default:NULL;comment:'研报小程序3.0图标地址'"`
+	YbBottomIcon               string `gorm:"column:yb_bottom_icon;default:NULL;comment:'研报小程序3.0底部菜单图标地址'"`
+	YbHidden                   uint   `gorm:"column:yb_hidden;default:0;NOT NULL;comment:'研报小程序隐藏章节: 0-显示; 1-隐藏'"`
+	ReportClassifyId           int    `description:"所属分类id"`
+	InheritReportChapterTypeId int    `description:"继承的报告章节类型id"`
 }
 
 func (r *ReportChapterType) TableName() string {

+ 26 - 25
models/eta/report_chapter_type.go

@@ -7,31 +7,32 @@ import (
 )
 
 type ReportChapterType struct {
-	ReportChapterTypeId        int       `gorm:"column:report_chapter_type_id;primary_key;AUTO_INCREMENT;NOT NULL;comment:'报告章节类型id'"`
-	ReportChapterTypeKey       string    `gorm:"column:report_chapter_type_key;default:NULL;comment:'章节key'"`
-	ReportChapterTypeThumb     string    `gorm:"column:report_chapter_type_thumb;default:NULL;comment:'H5展示的图片'"`
-	BannerUrl                  string    `gorm:"column:banner_url;default:NULL;comment:'banner显示图片'"`
-	ReportChapterTypeName      string    `gorm:"column:report_chapter_type_name;default:NULL;comment:'报告章节类型名称'"`
-	Sort                       int       `gorm:"column:sort;default:0;NOT NULL;comment:'排序字段'"`
-	Enabled                    int       `gorm:"column:enabled;default:NULL;comment:'报告类型状态'"`
-	CreatedTime                time.Time `gorm:"column:created_time;default:CURRENT_TIMESTAMP;comment:'创建时间'"`
-	LastUpdatedTime            time.Time `gorm:"column:last_updated_time;default:CURRENT_TIMESTAMP;NOT NULL"`
-	ResearchType               string    `gorm:"column:research_type;default:week;comment:'研报类型'"`
-	SelectedImage              string    `gorm:"column:selected_image;default:NULL;comment:'选中时的图片'"`
-	UnselectedImage            string    `gorm:"column:unselected_image;default:NULL;comment:'没选中时的图片'"`
-	PcSelectedImage            string    `gorm:"column:pc_selected_image;default:NULL;comment:'选中时的图片'"`
-	PcUnselectedImage          string    `gorm:"column:pc_unselected_image;default:NULL;comment:'没选中时的图片'"`
-	EditImgUrl                 string    `gorm:"column:edit_img_url;default:NULL;comment:'管理后台编辑时选用的图'"`
-	TickerTitle                string    `gorm:"column:ticker_title;default:NULL;comment:'指标列的标题'"`
-	IsShow                     int       `gorm:"column:is_show;default:1;comment:'是否显示'"`
-	PauseStartTime             string    `gorm:"column:pause_start_time;default:NULL;comment:'暂停开始日期'"`
-	PauseEndTime               string    `gorm:"column:pause_end_time;default:NULL;comment:'暂停结束日期'"`
-	IsSet                      int       `gorm:"column:is_set;default:0;comment:'是否设置:0为设置,1已设置'"`
-	YbIconUrl                  string    `gorm:"column:yb_icon_url;default:NULL;comment:'研报小程序3.0图标地址'"`
-	YbBottomIcon               string    `gorm:"column:yb_bottom_icon;default:NULL;comment:'研报小程序3.0底部菜单图标地址'"`
-	YbHidden                   uint      `gorm:"column:yb_hidden;default:0;NOT NULL;comment:'研报小程序隐藏章节: 0-显示; 1-隐藏'"`
-	ReportClassifyId           int       `description:"所属分类id"`
-	InheritReportChapterTypeId int       `description:"继承的报告章节类型id"`
+	ReportChapterTypeId    int       `gorm:"column:report_chapter_type_id;primary_key;AUTO_INCREMENT;NOT NULL;comment:'报告章节类型id'"`
+	ReportChapterTypeKey   string    `gorm:"column:report_chapter_type_key;default:NULL;comment:'章节key'"`
+	ReportChapterTypeThumb string    `gorm:"column:report_chapter_type_thumb;default:NULL;comment:'H5展示的图片'"`
+	BannerUrl              string    `gorm:"column:banner_url;default:NULL;comment:'banner显示图片'"`
+	ReportChapterTypeName  string    `gorm:"column:report_chapter_type_name;default:NULL;comment:'报告章节类型名称'"`
+	Sort                   int       `gorm:"column:sort;default:0;NOT NULL;comment:'排序字段'"`
+	Enabled                int       `gorm:"column:enabled;default:NULL;comment:'报告类型状态'"`
+	CreatedTime            time.Time `gorm:"column:created_time;default:CURRENT_TIMESTAMP;comment:'创建时间'"`
+	LastUpdatedTime        time.Time `gorm:"column:last_updated_time;default:CURRENT_TIMESTAMP;NOT NULL"`
+	ResearchType           string    `gorm:"column:research_type;default:week;comment:'研报类型'"`
+	SelectedImage          string    `gorm:"column:selected_image;default:NULL;comment:'选中时的图片'"`
+	UnselectedImage        string    `gorm:"column:unselected_image;default:NULL;comment:'没选中时的图片'"`
+	PcSelectedImage        string    `gorm:"column:pc_selected_image;default:NULL;comment:'选中时的图片'"`
+	PcUnselectedImage      string    `gorm:"column:pc_unselected_image;default:NULL;comment:'没选中时的图片'"`
+	EditImgUrl             string    `gorm:"column:edit_img_url;default:NULL;comment:'管理后台编辑时选用的图'"`
+	TickerTitle            string    `gorm:"column:ticker_title;default:NULL;comment:'指标列的标题'"`
+	//IsShow                     int       `gorm:"column:is_show;default:1;comment:'是否显示'"`
+	IsShow                     int    `gorm:"column:is_show;default:0;comment:'是否显示'"`
+	PauseStartTime             string `gorm:"column:pause_start_time;default:NULL;comment:'暂停开始日期'"`
+	PauseEndTime               string `gorm:"column:pause_end_time;default:NULL;comment:'暂停结束日期'"`
+	IsSet                      int    `gorm:"column:is_set;default:0;comment:'是否设置:0为设置,1已设置'"`
+	YbIconUrl                  string `gorm:"column:yb_icon_url;default:NULL;comment:'研报小程序3.0图标地址'"`
+	YbBottomIcon               string `gorm:"column:yb_bottom_icon;default:NULL;comment:'研报小程序3.0底部菜单图标地址'"`
+	YbHidden                   uint   `gorm:"column:yb_hidden;default:0;NOT NULL;comment:'研报小程序隐藏章节: 0-显示; 1-隐藏'"`
+	ReportClassifyId           int    `description:"所属分类id"`
+	InheritReportChapterTypeId int    `description:"继承的报告章节类型id"`
 }
 
 func (r *ReportChapterType) TableName() string {

+ 13 - 0
services/crm/report_chapter_type.go

@@ -16,6 +16,7 @@ func SyncReportChapterType(req *crm.ReportChapterTypeSyncReq) (err error, errMsg
 		err = fmt.Errorf("查询章节信息失败, Err: " + e.Error())
 		return
 	}
+	//crmObj := crm.ReportChapterType{}
 	for _, v := range list {
 		ob := &crm.ReportChapterType{
 			ReportChapterTypeId:        v.ReportChapterTypeId,
@@ -45,6 +46,18 @@ func SyncReportChapterType(req *crm.ReportChapterTypeSyncReq) (err error, errMsg
 			InheritReportChapterTypeId: v.InheritReportChapterTypeId,
 		}
 
+		//if v.ReportChapterTypeId >= 157 {
+		//	fmt.Println("a")
+		//}
+		//_, tmpErr := crmObj.GetReportChapterTypeById(v.ReportChapterTypeId)
+		//if tmpErr != nil {
+		//	if errors.Is(tmpErr, utils.ErrNoRow) {
+		//		err = ob.Create()
+		//	}
+		//} else {
+		//	err = ob.Update([]string{"ReportChapterTypeThumb","BannerUrl","Sort","Enabled","CreatedTime","LastUpdatedTime","ResearchType","SelectedImage","UnselectedImage","PcSelectedImage","PcUnselectedImage","EditImgUrl","TickerTitle","IsShow","PauseStartTime","IsSet","YbIconUrl","YbBottomIcon","YbHidden","ReportClassifyId","InheritReportChapterTypeId"})
+		//}
+		//
 		err = ob.UpdateOrCreate()
 		if err != nil {
 			errMsg = "更新失败"