123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- 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:'是否可用'"`
- Level int `description:"层级"`
- HasChild int `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
- ReportDetailShowType int `description:"报告详情的展示类型:1-拼接;2:目录"`
- }
- 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 []*ClassifyListV2
- }
- 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-是"`
- ReportDetailShowType int `description:"报告详情的展示类型:1-拼接;2:目录"`
- }
- // 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
- }
- type ClassifyListV2 struct {
- Id int `orm:"column(id);pk"`
- 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禁用"`
- Child []*ClassifyListV2 `gorm:"-"`
- ClassifyMenuId int `description:"二级分类-子目录ID"`
- ClassifyMenuList []*ClassifyMenu `gorm:"-"`
- ChartPermissionIdList []int `description:"绑定的权限ID" gorm:"-"`
- Level int `description:"层级"`
- HasChild int `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
- ReportDetailShowType int `description:"报告详情的展示类型:1-拼接;2:目录"`
- }
- // GetClassifyListByKeyword
- // @Description: 获取分类列表
- // @author: Roc
- // @datetime 2024-06-19 09:49:33
- // @param keyWord string
- // @param enabled int
- // @return items []*ClassifyList
- // @return err error
- func GetClassifyListByKeyword(keyWord string) (items []*ClassifyListV2, err error) {
- sql := ``
- pars := make([]interface{}, 0)
- sql = `SELECT * FROM classify WHERE 1=1 `
- if keyWord != `` {
- sql += ` AND classify_name LIKE ? `
- pars = utils.GetLikeKeywordPars(pars, keyWord, 1)
- }
- sql += ` ORDER BY sort ASC, create_time ASC`
- err = global.MYSQL["rddp"].Raw(sql, pars...).Find(&items).Error
- return
- }
- // GetClassifyListByParentIdList
- // @Description: 获取分类列表
- // @author: Roc
- // @datetime 2024-06-19 09:49:33
- // @param keyWord string
- // @param enabled int
- // @return items []*ClassifyList
- // @return err error
- func GetClassifyListByParentIdList(parentClassifyIdList []int) (items []*ClassifyListV2, err error) {
- num := len(parentClassifyIdList)
- if num <= 0 {
- return
- }
- sql := `SELECT * FROM classify WHERE id in (?) ORDER BY sort ASC, create_time ASC `
- err = global.MYSQL["rddp"].Raw(sql, parentClassifyIdList).Find(&items).Error
- return
- }
|