Browse Source

同步章节信息小程序变更

xyxie 11 months ago
parent
commit
030aa9366b

+ 0 - 382
controller/eta/classify.go

@@ -1,382 +0,0 @@
-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/crm"
-	"hongze/hz_crm_eta/models/eta"
-	"hongze/hz_crm_eta/utils"
-	"time"
-)
-
-type ClassifyController struct{}
-
-// ListClassify
-// @Title 获取分类列表
-// @Description 获取分类列表
-// @Param   KeyWord   query   string  true       "检索关键词"
-// @Param   CompanyType   query   string  false       "产品类型,枚举值:'ficc','权益';不传默认返回全部"
-// @Param   HideDayWeek   query   int  false       "是否隐藏晨周报"
-// @Success 200 {object} models.Classify
-// @router /classify/list [get]
-func (this *ClassifyController) ListClassify(c *gin.Context) {
-	var req eta.ClassifyListReq
-	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
-	}
-
-	keyWord := req.Keyword
-	companyType := req.CompanyType
-	hideDayWeek := req.HideDayWeek
-
-	list, err := eta.GetClassifyList(keyWord, companyType, hideDayWeek)
-	if err != nil {
-		resp.FailData("获取失败", err.Error(), c)
-		return
-	}
-	finalList := make([]*eta.ClassifyList, 0)
-	parentIds := make([]int, 0)
-	for i := range list {
-		tmp := new(eta.ClassifyList)
-		tmp.ClassifyListItem = *list[i]
-		finalList = append(finalList, tmp)
-		parentIds = append(parentIds, list[i].Id)
-	}
-	parentIdLen := len(parentIds)
-	if parentIdLen == 0 {
-		data := &eta.ClassifyListResp{
-			List: finalList,
-		}
-		resp.OkData("操作成功", data, c)
-		return
-	}
-
-	// 获取一级分类-子目录列表
-	menuListMap := make(map[int][]*eta.ClassifyMenu, 0)
-	var menuCond string
-	var menuPars []interface{}
-	menuCond += ` classify_id IN (?)`
-	menuPars = append(menuPars, parentIds)
-	menuOb := new(eta.ClassifyMenu)
-	parentMenus, e := menuOb.GetClassifyMenuList(menuCond, menuPars)
-	if e != nil {
-		resp.FailData("获取失败", "获取一级分类子目录列表失败", c)
-		return
-	}
-	for i := range parentMenus {
-		if menuListMap[parentMenus[i].ClassifyId] == nil {
-			menuListMap[parentMenus[i].ClassifyId] = make([]*eta.ClassifyMenu, 0)
-		}
-		menuListMap[parentMenus[i].ClassifyId] = append(menuListMap[parentMenus[i].ClassifyId], parentMenus[i])
-	}
-
-	// 获取子分类
-	children, e := eta.GetClassifyChildByParentIds(parentIds, keyWord)
-	if e != nil {
-		resp.FailData("获取失败", "获取子分类失败", c)
-		return
-	}
-	childrenIds := make([]int, 0)
-	for i := range children {
-		childrenIds = append(childrenIds, children[i].Id)
-	}
-	childrenIdsLen := len(childrenIds)
-
-	// 获取二级分类-子目录关联
-	relateMap := make(map[int]int, 0)
-	if childrenIdsLen > 0 {
-		var relateCond string
-		var relatePars []interface{}
-		relateCond += ` classify_id IN (?)`
-		relatePars = append(relatePars, childrenIds)
-		menuRelationOb := new(eta.ClassifyMenuRelation)
-		relates, e := menuRelationOb.GetClassifyMenuRelationList(relateCond, relatePars)
-		if e != nil {
-			resp.FailData("获取失败", "获取二级分类子目录关联失败, Err: "+e.Error(), c)
-			return
-		}
-		for i := range relates {
-			relateMap[relates[i].ClassifyId] = relates[i].MenuId
-		}
-	}
-
-	permissionMappingOb := new(crm.ChartPermissionSearchKeyWordMapping)
-	permissionList, e := permissionMappingOb.GetPermission()
-	if e != nil {
-		resp.FailData("查询权限失败", e.Error(), c)
-		return
-	}
-	classifyPermissionMap := make(map[string][]int, 0)
-	if len(permissionList) > 0 {
-		for _, v := range permissionList {
-			classifyPermissionMap[v.KeyWord] = append(classifyPermissionMap[v.KeyWord], v.ChartPermissionId)
-		}
-	}
-	// 二级分类
-	childrenMap := make(map[int][]*eta.ClassifyItem, 0)
-	for i := range children {
-
-		if childrenMap[children[i].ParentId] == nil {
-			childrenMap[children[i].ParentId] = make([]*eta.ClassifyItem, 0)
-		}
-		tmp := &eta.ClassifyItem{
-			Classify:       *children[i],
-			ClassifyMenuId: relateMap[children[i].Id],
-		}
-		if permissionIds, ok := classifyPermissionMap[children[i].ClassifyName]; ok {
-			tmp.ChartPermissionIdList = permissionIds
-		}
-		childrenMap[children[i].ParentId] = append(childrenMap[children[i].ParentId], tmp)
-	}
-
-	// 一级分类
-	for i := range finalList {
-		finalList[i].ClassifyMenuList = menuListMap[list[i].Id]
-		finalList[i].Child = childrenMap[list[i].Id]
-	}
-
-	data := new(eta.ClassifyListResp)
-	data.List = finalList
-	resp.OkData("操作成功", data, c)
-}
-
-// SetEnabled
-// @Title 启用/禁用分类接口
-// @Description 启用/禁用分类
-// @Param	request	body models.ClassifyMoveReq true "type json string"
-// @Success 200 新增成功
-// @router /classify/enabled/set [post]
-func (this *ClassifyController) SetEnabled(c *gin.Context) {
-	var req eta.ClassifySetEnabledReq
-	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.ClassifyId <= 0 {
-		resp.Fail("请选择分类", c)
-		return
-	}
-	if req.Enabled != 0 && req.Enabled != 1 {
-		resp.Fail("请选择正确的启用禁用状态", c)
-		return
-	}
-	ob := new(eta.Classify)
-	item, err := ob.GetClassifyById(req.ClassifyId)
-	if err != nil {
-		if err == utils.ErrNoRow {
-			resp.FailData("分类不存在", "Err:"+err.Error(), c)
-			return
-		}
-
-		resp.FailData("获取信息失败", "Err:"+err.Error(), c)
-		return
-	}
-	if item == nil {
-		resp.Fail("分类不存在", c)
-		return
-	}
-	//设置分类启用、禁用状态
-	err = ob.SetEnabled(req.ClassifyId, req.Enabled)
-	if err != nil {
-		resp.FailData("操作失败", "Err:"+err.Error(), c)
-		return
-	}
-
-	resp.Ok("操作成功", c)
-}
-
-// Edit
-// @Title 修改分类接口
-// @Description 修改分类
-// @Param	request	body models.EditClassifyReq true "type json string"
-// @Success 200 Ret=200,修改成功
-// @router /classify/edit [post]
-func (this *ClassifyController) Edit(c *gin.Context) {
-	var req eta.EditClassifyReq
-	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
-	}
-	// 获取系统菜单, 如果没有对应的字段的特殊处理项, 则忽略必填
-	sysMenuObject := new(eta.SysMenu)
-	menus, e := sysMenuObject.GetSysMenuItemsByCondition(` hidden = 0`, make([]interface{}, 0), []string{}, ``)
-	if e != nil {
-		resp.FailData("保存失败", "获取菜单列表失败, Err:"+err.Error(), c)
-		return
-	}
-	menuMap := make(map[string]bool)
-	for _, m := range menus {
-		if m.ButtonCode != "" {
-			menuMap[m.ButtonCode] = true
-		}
-	}
-
-	if req.ClassifyId <= 0 {
-		resp.Fail("参数错误", c)
-		return
-	}
-
-	ob := new(eta.Classify)
-	item, err := ob.GetClassifyById(req.ClassifyId)
-	if err != nil {
-		if err == utils.ErrNoRow {
-			resp.Fail("分类不存在", c)
-			return
-		}
-
-		resp.FailData("获取信息失败", "Err:"+err.Error(), c)
-		return
-	}
-	if item == nil {
-		resp.Fail("分类不存在", c)
-		return
-	}
-
-	if menuMap[eta.MenuSpecialHandleClassifyShowType] && item.ParentId != 0 && req.ShowType == 0 {
-		resp.Fail("展示类型不可为空", c)
-		return
-	}
-	if menuMap[eta.MenuSpecialHandleClassifyReportImgs] && (req.ShowType == 1 || req.ShowType == 3) && req.YbRightBanner == "" && item.ParentId == 0 { //当一级报告分类为列表、品种时,增加“报告合集配图”的配置项
-		resp.Fail("报告合集配图不可为空", c)
-		return
-	}
-	//originRelateTel := item.RelateTel
-	item.ModifyTime = time.Now().Local()
-	/*item.Abstract = req.Abstract
-	item.Descript = req.Descript
-	item.ReportAuthor = req.ReportAuthor
-	item.AuthorDescript = req.AuthorDescript
-	item.ColumnImgUrl = req.ColumnImgUrl
-	item.HeadImgUrl = req.HeadImgUrl
-	item.AvatarImgUrl = req.AvatarImgUrl
-	item.ReportImgUrl = req.ReportImgUrl
-	item.HomeImgUrl = req.HomeImgUrl*/
-	item.ClassifyLabel = req.ClassifyLabel
-	item.ShowType = req.ShowType
-	/*	item.HasTeleconference = req.HasTeleconference
-		item.VipTitle = req.VipTitle*/
-	//	item.Sort = req.Sort
-	item.IsShow = req.IsShow
-	item.YbFiccSort = req.YbFiccSort
-	item.YbFiccIcon = req.YbFiccIcon
-	item.YbFiccPcIcon = req.YbFiccPcIcon
-	item.YbIconUrl = req.YbIconUrl
-	item.YbBgUrl = req.YbBgUrl
-	item.YbListImg = req.YbListImg
-	item.YbShareBgImg = req.YbShareBgImg
-	item.YbRightBanner = req.YbRightBanner
-	item.RelateTel = req.RelateTel
-	item.RelateVideo = req.RelateVideo
-	item.ModifyTime = time.Now().Local()
-	cols := make([]string, 0)
-	/*cols = append(cols, "Abstract", "Descript", "ReportAuthor", "AuthorDescript", "ColumnImgUrl",
-	"HeadImgUrl", "AvatarImgUrl", "ReportImgUrl", "HomeImgUrl", "ClassifyLabel", "ShowType", "HasTeleconference", "VipTitle",
-	"IsShow", "YbFiccSort", "YbFiccIcon", "YbFiccPcIcon", "YbIconUrl", "YbBgUrl", "YbListImg", "YbShareBgImg", "YbRightBanner",
-	"RelateTel", "RelateVideo", "ModifyTime")*/
-	cols = append(cols, "ClassifyLabel", "ShowType",
-		"IsShow", "YbFiccSort", "YbFiccIcon", "YbFiccPcIcon", "YbIconUrl", "YbBgUrl", "YbListImg", "YbShareBgImg", "YbRightBanner",
-		"RelateTel", "RelateVideo", "ModifyTime")
-	if e = item.UpdateClassify(cols); e != nil {
-		resp.FailData("修改失败", "Err:"+e.Error(), c)
-		return
-	}
-	// 一级分类关联设置会强制修改二级分类的所有关联设置
-	if item.ParentId == 0 {
-		if e = item.UpdateChildClassifyRelateSetting(item.Id, req.RelateTel, req.RelateVideo); e != nil {
-			resp.FailData("更新二级分类关联设置失败", "更新二级分类关联设置失败 Err:"+err.Error(), c)
-			return
-		}
-	}
-
-	// 为二级分类时, 更新父级分类是否含电话会字段
-	/*if item.ParentId > 0 {
-		go func() {
-			_ = eta2.UpdateParentClassifyHasTel(req.ClassifyId, item.ParentId, req.HasTeleconference)
-		}()
-	}*/
-
-	// 获取编辑前子目录列表
-	classifyId := item.Id
-	var menuCond string
-	var menuPars []interface{}
-	menuCond += ` classify_id = ?`
-	menuPars = append(menuPars, classifyId)
-	menuOb := new(eta.ClassifyMenu)
-	menuList, e := menuOb.GetClassifyMenuList(menuCond, menuPars)
-	if e != nil {
-		resp.FailData("保存失败", "获取分类子目录列表失败, Err:"+err.Error(), c)
-		return
-	}
-	oriMenuIds := make([]int, 0)
-	for i := range menuList {
-		oriMenuIds = append(oriMenuIds, menuList[i].MenuId)
-	}
-
-	// 一级分类-新增/编辑/删除子目录
-	if item.ParentId == 0 && len(req.MenuList) > 0 {
-		nowTime := time.Now().Local()
-		insertMenus := make([]*eta.ClassifyMenu, 0)
-		editMenus := make([]*eta.ClassifyMenu, 0)
-		deleteMenuIds := make([]int, 0)
-		menuIds := make([]int, 0)
-		for i := range req.MenuList {
-			m := req.MenuList[i]
-
-			v := new(eta.ClassifyMenu)
-			v.MenuName = req.MenuList[i].MenuName
-			v.ClassifyId = classifyId
-			v.Sort = i + 1
-			v.MenuId = m.MenuId
-			v.ModifyTime = nowTime
-			if v.MenuId > 0 {
-				// 编辑
-				editMenus = append(editMenus, v)
-				menuIds = append(menuIds, m.MenuId)
-			} else {
-				// 新增
-				v.CreateTime = nowTime
-				insertMenus = append(insertMenus, v)
-			}
-		}
-		// 编辑前存在子目录则取"编辑前子目录IDs与编辑时子目录IDs的差集"作为删除IDs
-		if len(oriMenuIds) > 0 {
-			deleteMenuIds = utils.MinusInt(oriMenuIds, menuIds)
-		}
-		if e = eta.InsertAndUpdateClassifyMenu(insertMenus, editMenus, deleteMenuIds); e != nil {
-			resp.FailData("保存失败", "新增/编辑/删除分类子目录失败, Err:"+e.Error(), c)
-			return
-		}
-	}
-
-	// 二级分类-新增子目录关联
-	if item.ParentId > 0 {
-		if e := eta.DeleteAndInsertClassifyMenuRelation(classifyId, req.ClassifyMenuId); e != nil {
-			resp.FailData("新增子目录关联失败", "新增子目录关联失败 Err:"+e.Error(), c)
-			return
-		}
-	}
-
-	resp.Ok("操作成功", c)
-}

+ 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)
+}

+ 0 - 1
init_serve/router.go

@@ -21,6 +21,5 @@ func InitRouter() (r *gin.Engine) {
 	routers.InitEtaTrial(rBase)
 	routers.InitChartPermission(rBase)
 	routers.InitReportChapterType(rBase)
-	routers.InitReportClassify(rBase)
 	return
 }

+ 0 - 244
models/eta/classify.go

@@ -1,244 +0,0 @@
-package eta
-
-import (
-	"hongze/hz_crm_eta/global"
-	"hongze/hz_crm_eta/utils"
-	"time"
-)
-
-type Classify struct {
-	Id                int       `gorm:"column:id;primary_key;AUTO_INCREMENT;NOT NULL"`
-	ClassifyName      string    `gorm:"column:classify_name;default:;comment:'分类名称'"`
-	Sort              int       `gorm:"column:sort;default:0;comment:'排序'"`
-	ParentId          int       `gorm:"column:parent_id;default:0;comment:'父级分类id'"`
-	CreateTime        time.Time `gorm:"column:create_time;default:CURRENT_TIMESTAMP"`
-	ModifyTime        time.Time `gorm:"column:modify_time;default:CURRENT_TIMESTAMP"`
-	Abstract          string    `gorm:"column:abstract;default:;comment:'栏目简介'"`
-	Descript          string    `gorm:"column:descript;default:;comment:'分享描述'"`
-	ReportAuthor      string    `gorm:"column:report_author;default:;comment:'栏目作者'"`
-	AuthorDescript    string    `gorm:"column:author_descript;default:;comment:'作者简介'"`
-	ReportImgUrl      string    `gorm:"column:report_img_url;default:;comment:'报告配图'"`
-	HeadImgUrl        string    `gorm:"column:head_img_url;default:;comment:'头部banner'"`
-	AvatarImgUrl      string    `gorm:"column:avatar_img_url;default:;comment:'头像'"`
-	ColumnImgUrl      string    `gorm:"column:column_img_url;default:;comment:'栏目配图'"`
-	IsHomeColumn      int       `gorm:"column:is_home_column;default:0;comment:'1:首页专栏'"`
-	HomeImgUrl        string    `gorm:"column:home_img_url;default:;comment:'首页配图'"`
-	ClassifyLabel     string    `gorm:"column:classify_label;default:"`
-	ShowType          int       `gorm:"column:show_type;default:0;NOT NULL;comment:'展示类型:1-列表 2-专栏 3-品种'"`
-	HasTeleconference int       `gorm:"column:has_teleconference;default:0;NOT NULL;comment:'是否有电话会 0-否 1-是'"`
-	VipTitle          string    `gorm:"column:vip_title;default:NULL;comment:'研究员头衔'"`
-	YbIconUrl         string    `gorm:"column:yb_icon_url;default:;comment:'研报3.0已购页面icon图片地址'"`
-	YbBgUrl           string    `gorm:"column:yb_bg_url;default:;comment:'研报3.0已购详情背景图地址'"`
-	IsShow            int       `gorm:"column:is_show;default:1;NOT NULL;comment:'是否展示报告:1,展示该分类下的报告,0隐藏分类下的报告'"`
-	YbFiccSort        int       `gorm:"column:yb_ficc_sort;default:0;comment:'研报小程序端ficc页面排序'"`
-	YbFiccIcon        string    `gorm:"column:yb_ficc_icon;default:NULL;comment:'研报小程序端ficc页码图标'"`
-	YbFiccPcIcon      string    `gorm:"column:yb_ficc_pc_icon;default:NULL;comment:'研报 pc端ficc页码图标'"`
-	YbListImg         string    `gorm:"column:yb_list_img;default:;NOT NULL;comment:'研报小程序-列表封面图'"`
-	YbShareBgImg      string    `gorm:"column:yb_share_bg_img;default:;NOT NULL;comment:'研报小程序-报告分享背景图'"`
-	YbRightBanner     string    `gorm:"column:yb_right_banner;default:NULL;comment:'Pc端详情页,右侧,报告合集背景图'"`
-	RelateTel         int       `gorm:"column:relate_tel;default:0;NOT NULL;comment:'是否在电话会中可选: 0-否; 1-是'"`
-	RelateVideo       int       `gorm:"column:relate_video;default:0;NOT NULL;comment:'是否在路演视频中可选: 0-否; 1-是'"`
-	IsMassSend        int       `gorm:"column:is_mass_send;default:0;comment:'1:群发,0:非群发'"`
-	Enabled           int       `gorm:"column:enabled;default:1;comment:'是否可用'"`
-}
-
-func (c *Classify) TableName() string {
-	return "classify"
-}
-
-type ClassifyListItem struct {
-	Id                int       `description:"id"`
-	ClassifyName      string    `description:"分类名称"`
-	Sort              int       `description:"排序"`
-	ParentId          int       `description:"父级分类id"`
-	CreateTime        time.Time `description:"创建时间"`
-	ModifyTime        time.Time `description:"修改时间"`
-	Abstract          string    `description:"简介"`
-	Descript          string    `description:"描述"`
-	ClassifyLabel     string    `description:"分类标签"`
-	ShowType          int       `description:"展示类型:1-列表 2-专栏"`
-	HasTeleconference int       `description:"是否有电话会:0-否 1-是"`
-	IsShow            int       `description:"是否在小程序显示:1-显示 0-隐藏"`
-	YbFiccSort        int       `description:"小程序FICC页排序"`
-	YbFiccIcon        string    `description:"小程序FICC页icon"`
-	YbFiccPcIcon      string    `description:"小程序PC端FICC页背景图"`
-	YbIconUrl         string    `description:"小程序已购页icon"`
-	YbBgUrl           string    `description:"小程序已购详情背景图"`
-	YbListImg         string    `description:"小程序研报列表封面图"`
-	YbShareBgImg      string    `description:"小程序研报详情分享背景图"`
-	YbRightBanner     string    `description:"Pc端详情页,右侧,报告合集背景图"`
-	RelateTel         int       `description:"是否在电话会中可选: 0-否; 1-是"`
-	RelateVideo       int       `description:"是否在路演视频中可选: 0-否; 1-是"`
-	Enabled           int       `description:"是否可用,1可用,0禁用"`
-}
-
-type ClassifyList struct {
-	ClassifyListItem
-	Child            []*ClassifyItem
-	ClassifyMenuList []*ClassifyMenu
-}
-type ClassifyItem struct {
-	Classify
-	ClassifyMenuId        int `description:"二级分类-子目录ID"`
-	ClassifyMenuList      []*ClassifyMenu
-	ChartPermissionIdList []int `description:"绑定的权限ID"`
-}
-
-// 获取分类列表
-func GetClassifyList(keyWord, companyType string, hideDayWeek int) (items []*ClassifyListItem, err error) {
-	sql := ``
-	companyTypeSqlStr := ``
-	if companyType == "ficc" {
-		companyTypeSqlStr = " AND id != 40 AND parent_id != 40 "
-	} else if companyType == "权益" {
-		companyTypeSqlStr = " AND (id = 40 or parent_id = 40)  "
-	}
-	pars := make([]interface{}, 0)
-	if keyWord != "" {
-		sql = `SELECT * FROM (
-                   SELECT * FROM classify
-                   WHERE parent_id=0 ` + companyTypeSqlStr + `  AND classify_name LIKE ?
-                   UNION
-                   SELECT * FROM classify
-                   WHERE id IN( SELECT parent_id FROM classify
-                   WHERE parent_id>0 ` + companyTypeSqlStr + `  AND classify_name LIKE ? )
-                   )AS t
-                   ORDER BY sort ASC,create_time ASC`
-		pars = utils.GetLikeKeywordPars(pars, keyWord, 2)
-	} else {
-		sql = `SELECT * FROM classify WHERE parent_id=0 ` + companyTypeSqlStr
-		if hideDayWeek == 1 {
-			sql += ` AND classify_name <> '晨报' AND classify_name <> '周报' `
-		}
-		sql += ` ORDER BY sort ASC, create_time ASC`
-	}
-	pars = append(pars)
-	err = global.MYSQL["rddp"].Raw(sql, pars...).Scan(&items).Error
-	return
-}
-
-func GetClassifyChildByParentIds(parentId []int, keyWord string) (items []*Classify, err error) {
-	parentIdLen := len(parentId)
-	if parentIdLen == 0 {
-		return
-	}
-	sql := ``
-	pars := make([]interface{}, 0)
-	pars = append(pars, parentId)
-	if keyWord != "" {
-		sql = `SELECT * FROM classify WHERE parent_id IN (?) AND classify_name LIKE ? ORDER BY create_time ASC `
-		pars = append(pars, utils.GetLikeKeyword(keyWord))
-	} else {
-		sql = `SELECT * FROM classify WHERE parent_id IN (?) ORDER BY create_time ASC `
-	}
-	err = global.MYSQL["rddp"].Raw(sql, pars...).Scan(&items).Error
-	return
-}
-
-func GetClassifyChild(parentId int, keyWord string) (items []*Classify, err error) {
-	sql := ``
-	pars := make([]interface{}, 0)
-	if keyWord != "" {
-		sql = `SELECT * FROM classify WHERE classify_name LIKE ? AND parent_id=? ORDER BY create_time ASC `
-		pars = append(pars, utils.GetLikeKeyword(keyWord))
-	} else {
-		sql = `SELECT * FROM classify WHERE parent_id=? ORDER BY create_time ASC `
-	}
-	pars = append(pars, parentId)
-	err = global.MYSQL["rddp"].Raw(sql, pars...).Scan(&items).Error
-	return
-}
-
-type ClassifyListReq struct {
-	Keyword     string
-	CompanyType string
-	HideDayWeek int
-}
-
-type ClassifyListResp struct {
-	List []*ClassifyList
-}
-
-type ClassifySetEnabledReq struct {
-	ClassifyId int `description:"分类ID"`
-	Enabled    int `description:"是否可用,1可用,0禁用"`
-}
-
-func (c *Classify) SetEnabled(id, enabled int) (err error) {
-	tx := global.MYSQL["rddp"].Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-	sql := ` UPDATE classify SET enabled =?  WHERE id = ?`
-	err = tx.Exec(sql, enabled, id).Error
-	if err != nil {
-		return
-	}
-	sql = ` UPDATE classify SET enabled =?  WHERE parent_id = ?`
-	err = tx.Exec(sql, enabled, id).Error
-	if err != nil {
-		return
-	}
-	return
-}
-
-// GetClassifyById 查询分类
-func (c *Classify) GetClassifyById(classifyId int) (item *Classify, err error) {
-	err = global.MYSQL["rddp"].Where("id = ?", classifyId).First(&item).Error
-	return
-}
-
-type EditClassifyReq struct {
-	ClassifyId int `description:"分类ID"`
-	/*Abstract          string `description:"栏目简介"`
-	Descript          string `description:"分享描述"`
-	ReportAuthor      string `description:"栏目作者"`
-	AuthorDescript    string `description:"作者简介"`
-	ColumnImgUrl      string `description:"栏目配图"`
-	ReportImgUrl      string `description:"报告配图"`
-	HeadImgUrl        string `description:"头部banner"`
-	AvatarImgUrl      string `description:"头像"`
-	HomeImgUrl        string `description:"首页配图"`
-	HasTeleconference int    `description:"是否有电话会:0-否 1-是"`
-	VipTitle          string `description:"研究员头衔"`*/
-	//Sort              int                    `description:"后台排序"`
-
-	ShowType       int                    `description:"展示类型:1-列表 2-专栏"`
-	MenuList       []*ClassifyMenuSaveReq `description:"子目录列表"`
-	ClassifyLabel  string                 `description:"分类标签"`
-	IsShow         int                    `description:"是否在小程序显示:1-显示 0-隐藏"`
-	YbFiccSort     int                    `description:"小程序FICC页排序"`
-	YbFiccIcon     string                 `description:"小程序FICC页icon"`
-	YbFiccPcIcon   string                 `description:"小程序PC端FICC页背景图"`
-	YbIconUrl      string                 `description:"小程序已购页icon"`
-	YbBgUrl        string                 `description:"小程序已购详情背景图"`
-	YbListImg      string                 `description:"小程序研报列表封面图"`
-	YbShareBgImg   string                 `description:"小程序研报详情分享背景图"`
-	YbRightBanner  string                 `description:"Pc端详情页,右侧,报告合集背景图"`
-	ClassifyMenuId int                    `description:"二级分类-子目录ID"`
-	RelateTel      int                    `description:"是否在电话会中可选: 0-否; 1-是"`
-	RelateVideo    int                    `description:"是否在路演视频中可选: 0-否; 1-是"`
-}
-
-// ClassifyMenuSaveReq 保存分类子目录请求体
-type ClassifyMenuSaveReq struct {
-	MenuId   int    `description:"子目录ID, 0为新增, 大于0为编辑"`
-	MenuName string `description:"子目录名称"`
-}
-
-// UpdateClassify 更新权限
-func (c *Classify) UpdateClassify(cols []string) (err error) {
-	err = global.MYSQL["rddp"].Model(c).Select(cols).Updates(c).Error
-	return
-}
-
-// UpdateChildClassifyRelateSetting 更新子分类关联设置
-func (c *Classify) UpdateChildClassifyRelateSetting(parentId, relateTel, relateVideo int) (err error) {
-	sql := `UPDATE classify SET relate_tel = ?, relate_video = ? WHERE parent_id = ?`
-	err = global.MYSQL["rddp"].Exec(sql, relateTel, relateVideo, parentId).Error
-	return
-}

+ 0 - 79
models/eta/classify_menu.go

@@ -1,79 +0,0 @@
-package eta
-
-import (
-	"fmt"
-	"hongze/hz_crm_eta/global"
-	"time"
-)
-
-type ClassifyMenu struct {
-	MenuId     int       `gorm:"column:menu_id;primary_key;AUTO_INCREMENT;NOT NULL;comment:'子目录ID'"`
-	MenuName   string    `gorm:"column:menu_name;default:;NOT NULL;comment:'子目录名称'"`
-	ClassifyId int       `gorm:"column:classify_id;default:0;NOT NULL;comment:'分类ID'"`
-	Sort       int       `gorm:"column:sort;default:0;NOT NULL;comment:'排序'"`
-	CreateTime time.Time `gorm:"column:create_time;default:NULL;comment:'创建时间'"`
-	ModifyTime time.Time `gorm:"column:modify_time;default:NULL;comment:'更新时间'"`
-}
-
-func (c *ClassifyMenu) TableName() string {
-	return "classify_menu"
-}
-
-// GetClassifyMenuList 获取子目录列表
-func (c *ClassifyMenu) GetClassifyMenuList(condition string, pars []interface{}) (items []*ClassifyMenu, err error) {
-	// todo 当condition为空时
-	err = global.MYSQL["rddp"].Model(c).Where(condition, pars...).Order("sort ASC, create_time ASC").Scan(&items).Error
-	return
-}
-
-// InsertAndUpdateClassifyMenu 新增/编辑/删除分类子目录
-func InsertAndUpdateClassifyMenu(insertMenus []*ClassifyMenu, editMenus []*ClassifyMenu, deleteMenuIds []int) (err error) {
-	tx := global.MYSQL["rddp"].Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-
-	// 编辑
-	sql := ``
-	if len(editMenus) > 0 {
-		for i := range editMenus {
-			sql = fmt.Sprintf(`UPDATE classify_menu SET menu_name = '%s', sort = %d, modify_time = NOW() WHERE menu_id = %d`,
-				editMenus[i].MenuName, editMenus[i].Sort, editMenus[i].MenuId)
-			if e := tx.Exec(sql).Error; e != nil {
-				err = e
-				return
-			}
-		}
-	}
-
-	// 删除
-	if len(deleteMenuIds) > 0 {
-		for i := range deleteMenuIds {
-			sql = fmt.Sprintf(`DELETE FROM classify_menu WHERE menu_id = %d LIMIT 1`, deleteMenuIds[i])
-			if e := tx.Exec(sql).Error; e != nil {
-				err = e
-				return
-			}
-			// 删除关联关系
-			sql = fmt.Sprintf(`DELETE FROM classify_menu_relation WHERE menu_id = %d`, deleteMenuIds[i])
-			if e := tx.Exec(sql).Error; e != nil {
-				err = e
-				return
-			}
-		}
-	}
-
-	// 新增
-	if len(insertMenus) > 0 {
-		e := tx.CreateInBatches(insertMenus, len(insertMenus)).Error
-		if e != nil {
-			err = e
-			return
-		}
-	}
-	return
-}

+ 0 - 56
models/eta/classify_menu_relation.go

@@ -1,56 +0,0 @@
-package eta
-
-import (
-	"hongze/hz_crm_eta/global"
-	"time"
-)
-
-type ClassifyMenuRelation struct {
-	Id         int       `gorm:"column:id;primary_key;AUTO_INCREMENT;NOT NULL;comment:'主键ID'"`
-	ClassifyId int       `gorm:"column:classify_id;default:0;NOT NULL;comment:'二级分类ID'"`
-	MenuId     int       `gorm:"column:menu_id;default:0;NOT NULL;comment:'子目录ID'"`
-	CreateTime time.Time `gorm:"column:create_time;default:NULL;comment:'创建时间'"`
-}
-
-func (c *ClassifyMenuRelation) TableName() string {
-	return "classify_menu_relation"
-}
-
-// GetClassifyMenuRelationList 获取子目录关联列表
-func (c *ClassifyMenuRelation) GetClassifyMenuRelationList(condition string, pars []interface{}) (items []*ClassifyMenuRelation, err error) {
-	err = global.MYSQL["rddp"].Model(c).Where(condition, pars...).Order("create_time ASC").Scan(&items).Error
-	return
-}
-
-// DeleteAndInsertClassifyMenuRelation 新增子目录关联
-func DeleteAndInsertClassifyMenuRelation(classifyId, menuId int) (err error) {
-	tx := global.MYSQL["rddp"].Begin()
-	defer func() {
-		if err != nil {
-			tx.Rollback()
-		} else {
-			tx.Commit()
-		}
-	}()
-
-	// 删除
-	sql := `DELETE FROM classify_menu_relation WHERE classify_id = ?`
-	if e := tx.Exec(sql, classifyId).Error; e != nil {
-		err = e
-		return
-	}
-
-	// 新增
-	if menuId > 0 {
-		relate := &ClassifyMenuRelation{
-			ClassifyId: classifyId,
-			MenuId:     menuId,
-			CreateTime: time.Now().Local(),
-		}
-		e := tx.Create(relate).Error
-		if e != nil {
-			err = e
-		}
-	}
-	return
-}

+ 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

+ 5 - 0
routers/report_chapter_type.go

@@ -3,10 +3,15 @@ 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)
 }

+ 0 - 14
routers/report_classify.go

@@ -1,14 +0,0 @@
-package routers
-
-import (
-	"github.com/gin-gonic/gin"
-	eta2 "hongze/hz_crm_eta/controller/eta"
-)
-
-func InitReportClassify(r *gin.RouterGroup) {
-	control := new(eta2.ClassifyController)
-	group := r.Group("eta/classify")
-	group.POST("list", control.ListClassify)
-	group.POST("edit", control.Edit)
-	group.POST("enabled/set", control.SetEnabled)
-}

+ 65 - 0
services/eta/report_chapter_type.go

@@ -0,0 +1,65 @@
+package crm
+
+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
+}

+ 0 - 72
services/eta/report_classify.go

@@ -1,72 +0,0 @@
-package eta
-
-import (
-	"fmt"
-	"hongze/hz_crm_eta/models/eta"
-	"hongze/hz_crm_eta/services/alarm_msg"
-	"hongze/hz_crm_eta/utils"
-)
-
-// UpdateParentClassifyHasTel 更新父级分类是否含有电话字段
-func UpdateParentClassifyHasTel(classifyId, parentId, hasTeleconference int) (err error) {
-	if classifyId <= 0 || parentId <= 0 {
-		return
-	}
-	defer func() {
-		if err != nil {
-			alarm_msg.SendAlarmMsg("编辑分类后-修改父级分类电话会信息失败, ErrMsg: "+err.Error(), 3)
-		}
-	}()
-	ob := new(eta.Classify)
-	parentClassify, e := ob.GetClassifyById(parentId)
-	if e != nil {
-		if e == utils.ErrNoRow {
-			err = fmt.Errorf("父级分类不存在")
-			return
-		}
-		err = fmt.Errorf("获取父级分类信息失败, Err: %s", e.Error())
-		return
-	}
-	if parentClassify == nil {
-		err = fmt.Errorf("父级分类不存在")
-		return
-	}
-	updateParent := false
-	updateCols := make([]string, 0)
-	updateCols = append(updateCols, "HasTeleconference")
-	if hasTeleconference == 1 {
-		// 二级分类包含电话会,则一级分类也默认包含电话会
-		if parentClassify.HasTeleconference == 0 {
-			parentClassify.HasTeleconference = 1
-			updateParent = true
-		}
-	} else {
-		// 二级分类均无电话会,则一级分类也无电话会
-		if parentClassify.HasTeleconference == 1 {
-			child, e := eta.GetClassifyChild(parentClassify.Id, "")
-			if e != nil {
-				err = fmt.Errorf("获取子分类失败, Err: %s", e.Error())
-				return
-			}
-			// 存在同一级分类下的二级分类有电话会则不变动
-			hasTel := false
-			for i := 0; i < len(child); i++ {
-				if child[i].HasTeleconference == 1 && child[i].Id != classifyId {
-					hasTel = true
-					break
-				}
-			}
-			if !hasTel {
-				parentClassify.HasTeleconference = 0
-				updateParent = true
-			}
-		}
-	}
-	if updateParent {
-		if e = parentClassify.UpdateClassify(updateCols); e != nil {
-			err = fmt.Errorf("更新父级分类失败, Err: %s", e.Error())
-			return
-		}
-	}
-	return
-}