123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "strings"
- )
- type CygxArticle struct {
- Id int `orm:"column(id);pk"`
- ArticleId int `description:"文章id"`
- Title string `description:"标题"`
- TitleEn string `description:"英文标题 "`
- UpdateFrequency string `description:"更新周期"`
- CreateDate string `description:"创建时间"`
- PublishDate string `description:"发布时间"`
- Body string `description:"内容"`
- BodyText string `description:"内容"`
- Abstract string `description:"摘要"`
- CategoryName string `description:"一级分类"`
- SubCategoryName string `description:"二级分类"`
- PublishStatus int `description:"发布状态"`
- CategoryId int `description:"分类id"`
- CategoryIdTwo int `description:"分类id用作修改匹配类型使用"`
- ExpertBackground string `description:"专家背景"`
- ExpertNumber string `description:"专家编号"`
- InterviewDate string `description:"访谈日期"`
- Department string `description:"作者"`
- ArticleIdMd5 string `description:"ID,md5值"`
- IsClass int `description:"是否归类,1是,0否"`
- IsSummary int `description:"是否是纪要库,1是,0否"`
- IsReport int `description:"是否属于报告,1是,0否"`
- ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
- FileLink string `description:"下载预览链接"`
- MatchTypeName string `description:"匹配类型"`
- Periods string `description:"期数"`
- ReportLink string `description:"报告链接"`
- ArticleType string `description:"文章类型 文章类型,lyjh:路演精华 "`
- HavePublish int `description:"是否发布过,1是 ,0 否"`
- Source int `description:"来源 0策略平台同步,1小程序后台添加"`
- SellerAndMobile string `description:"销售和手机号"`
- VideoUrl string `description:"音频文件URL"`
- VideoName string `description:"音频文件名称"`
- VideoPlaySeconds string `description:"音频播放时长"`
- Stock string `description:"个股标签"`
- FieldName string `description:"产业标签"`
- Annotation string `description:"核心观点"`
- TypeName string `description:"策略平台报告类型"`
- ModifyTimeByCl string `description:"策略平台报告更新时间"`
- CeLueFieldId int `description:"策略平台领域ID"`
- }
- type ArticleDetail struct {
- ArticleId int `description:"报告id"`
- ArticleIdMd5 string `description:"报告MD5id"`
- IsReport int `description:"是否属于报告,1是,0否"`
- Title string `description:"标题"`
- CategoryName string `description:"一级分类"`
- CategoryId int `description:"分类ID"`
- CreateDate string `description:"创建时间"`
- PublishDate string `description:"发布时间"`
- Body string `description:"内容"`
- Abstract string `description:"摘要"`
- Annotation string `description:"核心观点"`
- IsInterviewApply bool `description:"是否申请访谈:true,已申请,false:未申请"`
- InterviewApplyStatus string `description:"当前访谈申请状态:'待邀请','待访谈','已完成','已取消'"`
- IsFollow bool `description:"是否关注,1是,0否"`
- FollowNum int `description:"关注数量"`
- IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
- CollectionNum int `description:"收藏数量"`
- DepartmentId int `description:"作者ID"`
- DepartmentImgUrl string `description:"作者头像"`
- NickName string `description:"作者昵称"`
- HttpUrl string `description:"文章链接跳转地址"`
- IsNeedJump bool `description:"是否需要跳转链接地址"`
- Seller SellerResp `description:"作者昵称"`
- DepartmentDetail *DepartmentResp `description:"作者昵称"`
- Disclaimers string `description:"免责声明"`
- IsSpecialArticle bool `description:"是否属于专项调研报告"`
- SubCategoryName string `description:"二级分类"`
- ArticleTypeId int `description:"文章类型ID"`
- IsApplyAppointmentExpert bool `description:"是否属于专家访谈"`
- ShareImg string `description:"分享图片"`
- ChartPermissionName string `description:"行业名称"`
- Stock string `description:"个股标签"`
- }
- type CygxArticleIdReq struct {
- ArticleId int `description:"文章id"`
- }
- type SellerResp struct {
- SellerMobile string `description:"销售手机号"`
- SellerName string `description:"销售名称"`
- }
- type ArticleDetailResp struct {
- IsResearch bool `description:"是否属于研选"`
- Mobile string `description:"用户手机号"`
- PopupMsg string `description:"权限弹窗信息"`
- SellerMobile string `description:"销售电话"`
- SellerName string `description:"销售姓名"`
- Detail *ArticleDetail
- IsSpecialArticle bool `description:"是否属于专项调研报告"`
- HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
- }
- func GetArticleDetailById(articleId int) (item *ArticleDetail, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_article WHERE article_id = ? AND publish_status = 1 `
- err = o.Raw(sql, articleId).QueryRow(&item)
- return
- }
- func GetArticleDetailByReportId(reportId int) (item *ArticleDetail, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_article WHERE report_id = ? AND publish_status = 1 `
- err = o.Raw(sql, reportId).QueryRow(&item)
- return
- }
- func GetArticlePermission(companyId int) (item *ChartPermissionItemResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- a.chart_permission_name as permission_name,a.match_type_name
- FROM
- cygx_report_mapping AS a
- WHERE
- a.category_id = ? LIMIT 1 `
- err = o.Raw(sql, companyId).QueryRow(&item)
- //_, err = o.Raw(sql, companyId).QueryRows(&item)
- return
- }
- type ArticleFollowDetail struct {
- DNum int `description:"作者被关注的数量"`
- MdNum int `description:"本人是否关注这个作者"`
- AcNum int `description:"文章被收藏的数量"`
- MacNum int `description:"本人是否收藏这个文章"`
- }
- // 获取文章被关注被收藏的详情
- func GetArticleFollowDetail(articleId, uid int) (item *ArticleFollowDetail, err error) {
- //d_num 作者被关注的数量 、 md_num 本人是否关注这个作者 、ac_num 文章被收藏的数量 、 mac_num 本人是否收藏这个文章
- o := orm.NewOrm()
- sql := ` SELECT
- ( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.department_id = art.department_id AND af.type = 1 ) AS d_num,
- ( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.department_id = art.department_id AND af.type = 1 AND af.user_id = ? ) AS md_num,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = art.article_id ) AS ac_num,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = art.article_id AND ac.user_id = ? ) AS mac_num
- FROM
- cygx_article AS art
- LEFT JOIN cygx_article_department_follow AS af ON af.department_id = art.department_id
- LEFT JOIN cygx_article_collect AS ac ON ac.article_id = art.article_id
- WHERE
- art.article_id = ?
- GROUP BY art.article_id `
- err = o.Raw(sql, uid, uid, articleId).QueryRow(&item)
- return
- }
- func GetArticleCountById(articleId int) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT COUNT(1) AS count FROM cygx_article WHERE article_id = ? `
- err = o.Raw(sql, articleId).QueryRow(&count)
- return
- }
- // 用户收藏榜start
- type ArticleCollectionResp struct {
- ArticleId int `description:"文章id"`
- Title string `description:"标题"`
- PublishDate string `description:"发布时间"`
- DepartmentId int `description:"作者Id"`
- NickName string `description:"作者昵称"`
- IsCollect bool `description:"本人是否收藏"`
- Pv int `description:"PV"`
- CollectNum int `description:"收藏人数"`
- Source int `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
- List []*IndustrialManagementResp `description:"产业列表"`
- Body string `description:"内容"`
- Abstract string `description:"摘要"`
- Annotation string `description:"核心观点"`
- CategoryName string `description:"一级分类"`
- SubCategoryName string `description:"二级分类"`
- IsResearch bool `description:"是否属于研选"`
- ImgUrlPc string `description:"图片链接"`
- CategoryId string `description:"文章分类"`
- HttpUrl string `description:"文章链接跳转地址"`
- IsNeedJump bool `description:"是否需要跳转链接地址"`
- MyCollectNum int `description:"本人是否收藏数量"`
- ArticleTypeId int `description:"文章类型ID"`
- IsSpecial int `description:"是否为研选专栏"`
- SpecialTags string `description:"研选专栏标签"`
- UserId int `description:"作者id"`
- SpecialType int `description:"专栏类型 1:笔记,2:观点"`
- }
- // 列表
- func GetArticleCollectionList(condition string, userId int) (items []*ArticleCollectionResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- a.article_id,
- a.title,
- date_format( a.publish_date, '%Y-%m-%d' ) AS publish_date,
- m.industry_name,
- m.industrial_management_id,
- d.nick_name,
- d.department_id,
- ( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id ) AS collect_num,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time ) ) AS collect_num_order,
- ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id AND user_id = ? ) AS my_collect_num
- FROM
- cygx_article AS a
- INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
- INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
- INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id
- WHERE
- 1 = 1 AND a.publish_status = 1 `
- if condition != "" {
- sql += condition
- }
- _, err = o.Raw(sql, userId).QueryRows(&items)
- return
- } //end
- type ArticleCollectionLIstResp struct {
- List []*ArticleCollectionResp
- }
- type CygxArticleEs struct {
- Id int `orm:"column(id);pk"`
- ArticleId int `description:"文章id"`
- Title string `description:"标题"`
- TitleEn string `description:"英文标题 "`
- UpdateFrequency string `description:"更新周期"`
- CreateDate string `description:"创建时间"`
- PublishDate string `description:"发布时间"`
- Body string `description:"内容"`
- BodyText string `description:"内容"`
- Abstract string `description:"摘要"`
- CategoryName string `description:"一级分类"`
- SubCategoryName string `description:"二级分类"`
- PublishStatus int `description:"发布状态"`
- CategoryId string `description:"分类id"`
- ExpertBackground string `description:"专家背景"`
- ExpertNumber string `description:"专家编号"`
- InterviewDate string `description:"访谈日期"`
- Department string `description:"作者"`
- ArticleIdMd5 string `description:"ID,md5值"`
- IsClass int `description:"是否归类,1是,0否"`
- IsSummary bool `description:"是否是纪要库,1是,0否"`
- IsReport bool `description:"是否属于报告,1是,0否"`
- ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
- FileLink string `description:"下载预览链接"`
- MatchTypeName string `description:"匹配类型"`
- }
- // 获取文章列表
- func GetArticleList(condition string, pars []interface{}) (items []*ArticleDetail, err error) {
- o := orm.NewOrm()
- sql := `SELECT article_id,stock FROM cygx_article WHERE 1= 1 ` + condition
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- func GetArticleDetailByIdStr(articleIdStr string) (items []*ArticleDetail, err error) {
- o := orm.NewOrm()
- sql := `SELECT art.*,d.nick_name FROM
- cygx_article AS art
- LEFT JOIN cygx_article_department AS d ON d.department_id = art.department_id WHERE article_id IN(` + articleIdStr + `) `
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- // 检查用户是否阅读某一分类最新文章
- func GetUserIsReadThisNewCategoryArticleCount(categoryId, uid int) (count int, err error) {
- sqlCount := `SELECT COUNT(1) as count FROM
- cygx_article_history_record
- WHERE
- article_id = ( SELECT article_id FROM cygx_article WHERE category_id = ? ORDER BY publish_date DESC LIMIT 0, 1 )
- AND user_id = ?`
- o := orm.NewOrm()
- err = o.Raw(sqlCount, categoryId, uid).QueryRow(&count)
- return
- }
- // 获取最新文章
- func GetNewArticleByCategoryId(categoryId int) (item *ArticleDetail, err error) {
- o := orm.NewOrm()
- sql := ` SELECT * FROM cygx_article WHERE category_id = ? ORDER BY publish_date DESC LIMIT 0, 1`
- err = o.Raw(sql, categoryId).QueryRow(&item)
- return
- }
- func GetArticleDetailByIdMd5(articleIdMd5 string) (item *ArticleDetail, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_article WHERE article_id_md5 = ? `
- err = o.Raw(sql, articleIdMd5).QueryRow(&item)
- return
- }
- type SummaryArticleStock struct {
- Id int `description:"新ID"`
- ArticleId int `description:"文章id"`
- Stock string `description:"个股标签"`
- }
- type SummaryArticleStockResp struct {
- List []*SummaryArticleStock
- }
- // 综述报告
- func GetArticleStock() (items []*SummaryArticleStock, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- stock,article_id
- FROM
- cygx_article AS art
- WHERE
- 1 = 1
- AND type_name = '综述报告' `
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- // 列表
- func GetCygxCygxArticleList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticle, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_article as art WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- // 获取数量
- func GetCygxArticleCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article as art WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 列表
- func GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, industryStr, subjectNameStr, articleTypeStr string) (artIds, actIds, mmIds string, err error) {
- o := orm.NewOrm()
- artSql := `SELECT GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS art_ids FROM cygx_article as art `
- actSql := ` SELECT GROUP_CONCAT(DISTINCT act.activity_id SEPARATOR ',') AS act_ids FROM cygx_activity as act `
- mmSql := ` SELECT GROUP_CONCAT(DISTINCT mmc.id SEPARATOR ',') AS mm_ids FROM cygx_morning_meeting_review_chapter as mmc `
- if industryStr != "" {
- artSql += ` INNER JOIN cygx_industrial_article_group_management AS iam ON iam.article_id = art.article_id
- INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
- actSql += ` INNER JOIN cygx_industrial_activity_group_management AS iam ON iam.activity_id = act.activity_id
- INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
- mmSql += ` INNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
- INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=mmc.industry_id `
- }
- if subjectNameStr != "" {
- artSql += ` INNER JOIN cygx_industrial_article_group_subject AS ias ON ias.article_id = art.article_id
- INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
- actSql += ` INNER JOIN cygx_industrial_activity_group_subject AS ias ON ias.activity_id = act.activity_id
- INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
- mmSql += ` IINNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
- INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=mmc.industrial_subject_ids `
- }
- artSql += ` WHERE 1=1 `
- if articleTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
- if industryStr != "" && subjectNameStr != "" {
- artSql += articleTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
- } else if industryStr == "" && subjectNameStr != "" {
- artSql += articleTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
- } else if industryStr != "" && subjectNameStr == "" {
- artSql += articleTypesCond + ` AND im.industry_name In (` + industryStr + `) `
- } else {
- artSql += articleTypesCond
- }
- err = o.Raw(artSql).QueryRow(&artIds)
- if err != nil {
- return
- }
- }
- actSql += ` WHERE 1=1 `
- if activityTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
- if industryStr != "" && subjectNameStr != "" {
- actSql += activityTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
- } else if industryStr == "" && subjectNameStr != "" {
- actSql += activityTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
- } else if industryStr != "" && subjectNameStr == "" {
- actSql += activityTypesCond + ` AND im.industry_name In (` + industryStr + `) `
- } else {
- actSql += activityTypesCond
- }
- err = o.Raw(actSql).QueryRow(&actIds)
- if err != nil {
- return
- }
- }
- if strings.Contains(articleTypeStr, "晨会精华") {
- mmSql += ` WHERE 1=1 `
- if industryStr != "" && subjectNameStr != "" {
- mmSql += ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
- } else if industryStr == "" && subjectNameStr != "" {
- mmSql += ` AND cis.subject_name In (` + subjectNameStr + `) `
- } else if industryStr != "" && subjectNameStr == "" {
- mmSql += ` AND im.industry_name In (` + industryStr + `) `
- }
- err = o.Raw(mmSql).QueryRow(&mmIds)
- if err != nil {
- return
- }
- }
- return
- }
- // 单个tag时用,取合集
- func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityTypesCondSlice, industriesCondSlice, subjectNamesSlice, articleTypeSlice []string) (artIds, actIds, mmIds string, err error) {
- o := orm.NewOrm()
- artSql := `SELECT GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS art_ids FROM cygx_article as art `
- actSql := ` SELECT GROUP_CONCAT(DISTINCT act.activity_id SEPARATOR ',') AS act_ids FROM cygx_activity as act `
- mmSql := ` SELECT GROUP_CONCAT(DISTINCT mmc.id SEPARATOR ',') AS mm_ids FROM cygx_morning_meeting_review_chapter as mmc `
- for _, s := range industriesCondSlice {
- if s != "" {
- artSql += ` INNER JOIN cygx_industrial_article_group_management AS iam ON iam.article_id = art.article_id
- INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
- actSql += ` INNER JOIN cygx_industrial_activity_group_management AS iam ON iam.activity_id = act.activity_id
- INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
- mmSql += ` INNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
- INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=mmc.industry_id `
- break
- }
- }
- for _, s := range subjectNamesSlice {
- if s != "" {
- artSql += ` INNER JOIN cygx_industrial_article_group_subject AS ias ON ias.article_id = art.article_id
- INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
- actSql += ` INNER JOIN cygx_industrial_activity_group_subject AS ias ON ias.activity_id = act.activity_id
- INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
- mmSql += ` IINNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
- INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=mmc.industrial_subject_ids `
- break
- }
- }
- artSql += ` WHERE 1=1 AND ((1=1 `
- actSql += ` WHERE 1=1 AND ((1=1 `
- mmSql += ` WHERE 1=1 AND ((1=1 `
- var isNeedArt, isNeedAct, isNeedMm bool
- for i, _ := range articleTypeCondSlice {
- articleTypesCond := articleTypeCondSlice[i]
- activityTypesCond := activityTypesCondSlice[i]
- industryStr := industriesCondSlice[i]
- subjectNameStr := subjectNamesSlice[i]
- articleTypeStr := articleTypeSlice[i]
- if articleTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
- if industryStr != "" && subjectNameStr != "" {
- artSql += articleTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
- } else if industryStr == "" && subjectNameStr != "" {
- artSql += articleTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
- } else if industryStr != "" && subjectNameStr == "" {
- artSql += articleTypesCond + ` AND im.industry_name In (` + industryStr + `) `
- } else {
- artSql += articleTypesCond
- }
- if i == len(articleTypeCondSlice)-1 {
- artSql += `)) `
- } else {
- artSql += `) OR (1=1 `
- }
- isNeedArt = true
- }
- if activityTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
- if industryStr != "" && subjectNameStr != "" {
- actSql += activityTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
- } else if industryStr == "" && subjectNameStr != "" {
- actSql += activityTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
- } else if industryStr != "" && subjectNameStr == "" {
- actSql += activityTypesCond + ` AND im.industry_name In (` + industryStr + `) `
- } else {
- actSql += activityTypesCond
- }
- if i == len(articleTypeCondSlice)-1 {
- actSql += `)) `
- } else {
- actSql += `) OR (1=1 `
- }
- isNeedAct = true
- }
- if strings.Contains(articleTypeStr, "晨会精华") {
- if industryStr != "" && subjectNameStr != "" {
- mmSql += ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
- } else if industryStr == "" && subjectNameStr != "" {
- mmSql += ` AND cis.subject_name In (` + subjectNameStr + `) `
- } else if industryStr != "" && subjectNameStr == "" {
- mmSql += ` AND im.industry_name In (` + industryStr + `) `
- }
- if i == len(articleTypeCondSlice)-1 {
- mmSql += `)) `
- } else {
- mmSql += `) OR (1=1 `
- }
- isNeedMm = true
- }
- }
- if isNeedArt {
- err = o.Raw(artSql).QueryRow(&artIds)
- if err != nil {
- return
- }
- }
- if isNeedAct {
- err = o.Raw(actSql).QueryRow(&actIds)
- if err != nil {
- return
- }
- }
- if isNeedMm {
- err = o.Raw(mmSql).QueryRow(&mmIds)
- if err != nil {
- return
- }
- }
- return
- }
|