|
@@ -1,6 +1,7 @@
|
|
|
package cygx
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"hongze/hz_crm_api/models/company"
|
|
@@ -352,6 +353,7 @@ type UserInteraction struct {
|
|
|
IsEnd bool `description:"是否最后一页,配合前端分页添加的参数"`
|
|
|
CurrentIndex int `description:"当前页页码,配合前端分页添加的参数"`
|
|
|
RegisterPlatform int `description:"来源 1小程序,2:网页 ,3:策略平台"`
|
|
|
+ RegisterPlatformText string `description:"阅读来源(文本描述)"`
|
|
|
SourcePlatform string `description:"来源 'MOBILE:移动端小程序','PC:PC端小程序','CELUE:上海策略平台','WEB:查研观向网页版'"`
|
|
|
TagId int
|
|
|
TagName string // 标签名
|
|
@@ -360,6 +362,8 @@ type UserInteraction struct {
|
|
|
Industries string // 产业
|
|
|
SubjectNames string // 标的
|
|
|
SpecialType int `description:"专栏类型 1:笔记,2:观点"`
|
|
|
+ ArticleNum int // 已发布的文章数量
|
|
|
+ FansNum int // 粉丝数量
|
|
|
}
|
|
|
|
|
|
// 查研观向图表
|
|
@@ -455,21 +459,58 @@ func GetCygxArticleHistoryRecordByUserNew(condition string, startSize, pageSize
|
|
|
1= 1
|
|
|
AND is_del = 0 ` + condition
|
|
|
|
|
|
- sql += ` UNION ALL `
|
|
|
+ //sql += ` UNION ALL `
|
|
|
+ //sql += ` SELECT
|
|
|
+ // art.title,
|
|
|
+ // art.id AS article_id,
|
|
|
+ // '' AS article_id_md5,
|
|
|
+ // art.publish_time AS publish_date,
|
|
|
+ // '' AS category_name,
|
|
|
+ // r.create_time,
|
|
|
+ // r.stop_time,
|
|
|
+ // r.register_platform AS source_platform,
|
|
|
+ // r.register_platform,
|
|
|
+ // art.type AS special_type
|
|
|
+ // FROM
|
|
|
+ // cygx_yanxuan_special_record AS r
|
|
|
+ // INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
|
|
|
+ // WHERE 1 = 1 ` + condition
|
|
|
+
|
|
|
+ totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
|
|
|
+ err = o.Raw(totalSql).QueryRow(&total)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += ` ORDER BY create_time DESC, article_id DESC `
|
|
|
+ if startSize > 0 || pageSize > 0 {
|
|
|
+ sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
|
|
|
+ }
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户阅读记录列表
|
|
|
+func GetCygxYanxuaSspecialHistoryRecordByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
+ var sql string
|
|
|
sql += ` SELECT
|
|
|
art.title,
|
|
|
art.id AS article_id,
|
|
|
- '' AS article_id_md5,
|
|
|
art.publish_time AS publish_date,
|
|
|
- '' AS category_name,
|
|
|
r.create_time,
|
|
|
r.stop_time,
|
|
|
+ r.user_id,
|
|
|
+ r.mobile,
|
|
|
+ r.company_id,
|
|
|
+ r.company_name,
|
|
|
+ r.real_name,
|
|
|
r.register_platform AS source_platform,
|
|
|
- r.register_platform,
|
|
|
- art.type AS special_type
|
|
|
+ art.type AS special_type,
|
|
|
+ art.industry_tags as industry_name
|
|
|
FROM
|
|
|
cygx_yanxuan_special_record AS r
|
|
|
- INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
|
|
|
+ INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
|
|
|
WHERE 1 = 1 ` + condition
|
|
|
|
|
|
totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
|
|
@@ -486,10 +527,183 @@ func GetCygxArticleHistoryRecordByUserNew(condition string, startSize, pageSize
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// 用户阅读记录列表
|
|
|
+func GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ art.title,
|
|
|
+ art.id AS article_id,
|
|
|
+ art.publish_time AS publish_date,
|
|
|
+ r.create_time,
|
|
|
+ r.stop_time,
|
|
|
+ r.user_id,
|
|
|
+ r.mobile,
|
|
|
+ r.company_id,
|
|
|
+ r.company_name,
|
|
|
+ r.real_name,
|
|
|
+ r.register_platform AS source_platform,
|
|
|
+ art.type AS special_type,
|
|
|
+ art.industry_tags as industry_name
|
|
|
+ FROM
|
|
|
+ cygx_yanxuan_special_record AS r
|
|
|
+ INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
|
|
|
+ INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
|
|
|
+ WHERE 1 = 1 ` + condition
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
|
|
|
+ err = o.Raw(totalSql).QueryRow(&total)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += ` ORDER BY create_time DESC, article_id DESC `
|
|
|
+ if startSize > 0 || pageSize > 0 {
|
|
|
+ sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
|
|
|
+ }
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户阅读记录列表
|
|
|
+func GetCygxYanxuanSpecialCollectByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ art.title,
|
|
|
+ art.id AS article_id,
|
|
|
+ art.publish_time AS publish_date,
|
|
|
+ r.create_time,
|
|
|
+ r.register_platform AS source_platform,
|
|
|
+ art.type AS special_type,
|
|
|
+ art.industry_tags as industry_name
|
|
|
+ FROM
|
|
|
+ cygx_yanxuan_special_collect AS r
|
|
|
+ INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
|
|
|
+ WHERE 1 = 1 ` + condition
|
|
|
+
|
|
|
+ totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
|
|
|
+ err = o.Raw(totalSql).QueryRow(&total)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += ` ORDER BY create_time DESC, article_id DESC `
|
|
|
+ if startSize > 0 || pageSize > 0 {
|
|
|
+ sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
|
|
|
+ }
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户阅读记录列表
|
|
|
+func GetCygxYanxuanSpecialCollectByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ art.title,
|
|
|
+ art.id AS article_id,
|
|
|
+ art.publish_time AS publish_date,
|
|
|
+ r.create_time,
|
|
|
+ r.register_platform AS source_platform,
|
|
|
+ art.type AS special_type,
|
|
|
+ art.industry_tags as industry_name
|
|
|
+ FROM
|
|
|
+ cygx_yanxuan_special_collect AS r
|
|
|
+ INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
|
|
|
+ INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
|
|
|
+ WHERE 1 = 1 ` + condition
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
|
|
|
+ err = o.Raw(totalSql).QueryRow(&total)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += ` ORDER BY create_time DESC, article_id DESC `
|
|
|
+ if startSize > 0 || pageSize > 0 {
|
|
|
+ sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
|
|
|
+ }
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户阅读记录列表
|
|
|
+func GetCygxYanxuanSpecialAuthorByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ art.special_name as title,
|
|
|
+ art.id AS department_id,
|
|
|
+ art.nick_name,
|
|
|
+ art.article_num,
|
|
|
+ art.fans_num,
|
|
|
+ art.company_id,
|
|
|
+ art.company_name,
|
|
|
+ art.mobile_init as mobile,
|
|
|
+ r.create_time,
|
|
|
+ r.register_platform AS source_platform
|
|
|
+ FROM
|
|
|
+ cygx_yanxuan_special_follow AS r
|
|
|
+ INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
|
|
|
+ WHERE 1 = 1 ` + condition
|
|
|
+
|
|
|
+ totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
|
|
|
+ err = o.Raw(totalSql).QueryRow(&total)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += ` ORDER BY create_time DESC, department_id DESC `
|
|
|
+ if startSize > 0 || pageSize > 0 {
|
|
|
+ sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
|
|
|
+ }
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户阅读记录列表
|
|
|
+func GetCygxYanxuanSpecialAuthorByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ art.special_name as title,
|
|
|
+ art.id AS department_id,
|
|
|
+ art.nick_name,
|
|
|
+ art.article_num,
|
|
|
+ art.fans_num,
|
|
|
+ art.company_id,
|
|
|
+ art.company_name,
|
|
|
+ art.mobile_init as mobile,
|
|
|
+ r.create_time,
|
|
|
+ r.register_platform AS source_platform
|
|
|
+ FROM
|
|
|
+ cygx_yanxuan_special_follow AS r
|
|
|
+ INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
|
|
|
+ INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
|
|
|
+ WHERE 1 = 1 ` + condition
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
|
|
|
+ err = o.Raw(totalSql).QueryRow(&total)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += ` ORDER BY create_time DESC, department_id DESC `
|
|
|
+ if startSize > 0 || pageSize > 0 {
|
|
|
+ sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
|
|
|
+ }
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// 收藏列表数量
|
|
|
-func GetCygxArticleCollectCount(uid int) (count int, err error) {
|
|
|
+func GetCygxArticleCollectCount(uid int, condition string) (count int, err error) {
|
|
|
o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article_collect as r INNER JOIN cygx_article AS art ON art.article_id = r.article_id WHERE user_id = ? `
|
|
|
+ sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article_collect as r INNER JOIN cygx_article AS art ON art.article_id = r.article_id WHERE user_id = ? ` + condition
|
|
|
err = o.Raw(sqlCount, uid).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
@@ -571,21 +785,21 @@ func GetCygArticleDepartmentFollowByUser(uid, startSize, pageSize int) (items []
|
|
|
}
|
|
|
|
|
|
// 用户搜索关键词统计
|
|
|
-func GetCygxSearchKeyWordCount(uid int) (count int, err error) {
|
|
|
+func GetCygxSearchKeyWordCount(uid int, condition string) (count int, err error) {
|
|
|
o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_search_key_word WHERE user_id = ? `
|
|
|
+ sqlCount := ` SELECT COUNT(1) AS count FROM cygx_search_key_word WHERE user_id = ? ` + condition
|
|
|
err = o.Raw(sqlCount, uid).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 用户搜索关键词列表
|
|
|
-func GetCygxSearchKeyWordByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
|
|
|
+func GetCygxSearchKeyWordByUser(condition string, uid, startSize, pageSize int) (items []*UserInteraction, err error) {
|
|
|
o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
sql := `SELECT
|
|
|
key_word,create_time
|
|
|
FROM
|
|
|
cygx_search_key_word as k
|
|
|
- WHERE user_id = ?
|
|
|
+ WHERE user_id = ? ` + condition + `
|
|
|
ORDER BY k.create_time DESC LIMIT ?,? `
|
|
|
_, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
|
|
|
return
|
|
@@ -903,45 +1117,66 @@ ORDER BY
|
|
|
}
|
|
|
|
|
|
type GetUserInteractionTableCountResp struct {
|
|
|
- HistoryNum int `description:"报告阅读"`
|
|
|
- CountNum int `description:"报告收藏"`
|
|
|
- IndustryFllowNum int `description:"产业关注"`
|
|
|
- DepartmentFollowNum int `description:"作者关注"`
|
|
|
- KeyWordNum int `description:"搜索关键词"`
|
|
|
- OnLineNum int `description:"线上互动活动"`
|
|
|
- OfficeNum int `description:"线下互动活动"`
|
|
|
- ActivityNum int `description:"活动数量"`
|
|
|
- ChartNum int `description:"图表数量"`
|
|
|
- TripNum int `description:"图表数量"`
|
|
|
- RoadshowVideoNum int `description:"产业视频播放量"`
|
|
|
- ActivityVideoNum int `description:"活动视频播放量"`
|
|
|
- ActivityVoiceNum int `description:"活动音频播放量"`
|
|
|
- TagNum int `description:"首页标签点击量"`
|
|
|
- YanxuanSpecialNum int `description:"研选专栏阅读数量"`
|
|
|
+ HistoryNum int `description:"报告阅读"`
|
|
|
+ CountNum int `description:"报告收藏"`
|
|
|
+ IndustryFllowNum int `description:"产业关注"`
|
|
|
+ DepartmentFollowNum int `description:"作者关注"`
|
|
|
+ KeyWordNum int `description:"搜索关键词"`
|
|
|
+ OnLineNum int `description:"线上互动活动"`
|
|
|
+ OfficeNum int `description:"线下互动活动"`
|
|
|
+ ActivityNum int `description:"活动数量"`
|
|
|
+ ChartNum int `description:"图表数量"`
|
|
|
+ TripNum int `description:"图表数量"`
|
|
|
+ RoadshowVideoNum int `description:"产业视频播放量"`
|
|
|
+ ActivityVideoNum int `description:"活动视频播放量"`
|
|
|
+ ActivityVoiceNum int `description:"活动音频播放量"`
|
|
|
+ TagNum int `description:"首页标签点击量"`
|
|
|
+ YanxuanSpecialNum int `description:"研选专栏阅读数量"`
|
|
|
+ YanxuanSpecialCollectNum int `description:"研选专栏收藏数量"`
|
|
|
+ YanxuanSpecialFollowNum int `description:"研选专栏作者关注数量"`
|
|
|
}
|
|
|
|
|
|
// 用户互动总数统计
|
|
|
func GetUserInteractionTableCount(uid int) (item *GetUserInteractionTableCountResp, err error) {
|
|
|
o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
sql := `SELECT
|
|
|
- ( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.user_id = ? AND h.is_del = 0 ) AS history_num,
|
|
|
- ( SELECT COUNT( 1 ) FROM cygx_article_collect AS h WHERE h.user_id = ? AND h.article_id > 0 ) AS count_num,
|
|
|
+ ( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.user_id = ? AND h.is_del = 0 AND art.article_type_id = 0 ) AS history_num,
|
|
|
+ ( SELECT COUNT( 1 ) FROM cygx_article_collect AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.user_id = ? AND art.article_type_id = 0 ) AS count_num,
|
|
|
( SELECT COUNT( 1 ) FROM cygx_chart_collect AS h INNER JOIN cygx_chart_all AS a ON h.chart_id = a.chart_id WHERE h.user_id = ? ) AS chart_num,
|
|
|
- ( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h WHERE h.user_id = ? AND h.type = 1 AND h.source IN (0,1,2) ) AS industry_fllow_num,
|
|
|
- ( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = ? AND h.type = 1 ) AS department_follow_num,
|
|
|
- ( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = ? ) AS key_word_num,
|
|
|
+ ( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h INNER JOIN cygx_industrial_management as a ON a.industrial_management_id = h.industrial_management_id WHERE h.user_id = ? AND h.type = 1 AND h.source IN (0,1,2) AND a.chart_permission_id != 31 ) AS industry_fllow_num,
|
|
|
+ ( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = ? AND h.register_platform IN(1,2) ) AS key_word_num,
|
|
|
( SELECT COUNT( DISTINCT a.activity_id ) as count FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.user_id = ?
|
|
|
- AND t.activity_type=1 AND h.do_fail_type = 0 ) AS on_line_num,
|
|
|
+ AND t.activity_type=1 AND h.do_fail_type = 0 AND a.chart_permission_id != 31 ) AS on_line_num,
|
|
|
( SELECT COUNT( DISTINCT a.activity_id ) as count FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.user_id = ?
|
|
|
- AND t.activity_type = 0 AND h.do_fail_type = 0 ) AS office_num,
|
|
|
+ AND t.activity_type = 0 AND h.do_fail_type = 0 AND a.chart_permission_id != 31 ) AS office_num,
|
|
|
( SELECT COUNT( 1 ) FROM cygx_activity_special_meeting_detail AS h INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id WHERE h.user_id = ? AND a.publish_status = 1 AND a.activity_time_end < NOW()) AS trip_num,
|
|
|
( SELECT COUNT( 1 ) FROM cygx_micro_roadshow_video_history AS h INNER JOIN cygx_micro_roadshow_video as v ON v.video_id = h.video_id WHERE h.user_id = ? ) AS roadshow_video_num,
|
|
|
( SELECT COUNT( 1 ) FROM cygx_activity_video_history AS h INNER JOIN cygx_activity_video as v ON v.video_id = h.video_id WHERE h.user_id = ? ) AS activity_video_num,
|
|
|
( SELECT COUNT( 1 ) FROM cygx_activity_voice_history AS h INNER JOIN cygx_activity_voice as v ON v.activity_id = h.activity_id WHERE h.user_id = ? ) AS activity_voice_num,
|
|
|
- ( SELECT COUNT(1) FROM cygx_tag_history as h INNER JOIN cygx_tag AS b ON h.tag_id = b.tag_id WHERE h.user_id = ? ) AS tag_num,
|
|
|
+ ( SELECT COUNT(1) FROM cygx_tag_history as h INNER JOIN cygx_tag AS b ON h.tag_id = b.tag_id WHERE h.user_id = ? ) AS tag_num
|
|
|
+ FROM dual `
|
|
|
+ err = o.Raw(sql, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid).QueryRow(&item)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户互动总数统计
|
|
|
+func GetUserInteractionTableCountByYanXuan(uid int) (item *GetUserInteractionTableCountResp, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("hz_cygx")
|
|
|
+ sql := `SELECT
|
|
|
+ ( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.user_id = ? AND h.is_del = 0 AND art.article_type_id > 0 ) AS history_num,
|
|
|
+ ( SELECT COUNT( 1 ) FROM cygx_article_collect AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.user_id = ? AND art.article_type_id > 0 ) AS count_num,
|
|
|
+ ( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h INNER JOIN cygx_industrial_management as a ON a.industrial_management_id = h.industrial_management_id WHERE h.user_id = ? AND h.type = 1 AND h.source IN (0,1,2) AND a.chart_permission_id = 31 ) AS industry_fllow_num,
|
|
|
+ ( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = ? AND h.type = 1 ) AS department_follow_num,
|
|
|
+ ( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = ? AND h.register_platform IN(5,6) ) AS key_word_num,
|
|
|
+ ( SELECT COUNT( DISTINCT a.activity_id ) as count FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.user_id = ?
|
|
|
+ AND t.activity_type=1 AND h.do_fail_type = 0 AND a.chart_permission_id = 31 ) AS on_line_num,
|
|
|
+ ( SELECT COUNT( DISTINCT a.activity_id ) as count FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.user_id = ?
|
|
|
+ AND t.activity_type = 0 AND h.do_fail_type = 0 AND a.chart_permission_id = 31 ) AS office_num,
|
|
|
+ ( SELECT COUNT(1) FROM cygx_yanxuan_special_collect as h INNER JOIN cygx_yanxuan_special AS b ON h.yanxuan_special_id = b.id WHERE h.user_id = ? ) AS yanxuan_special_collect_num,
|
|
|
+ ( SELECT COUNT(1) FROM cygx_yanxuan_special_follow as h WHERE h.user_id = ? ) AS yanxuan_special_follow_num,
|
|
|
( SELECT COUNT(1) FROM cygx_yanxuan_special_record as h INNER JOIN cygx_yanxuan_special AS b ON h.yanxuan_special_id = b.id WHERE h.user_id = ? ) AS yanxuan_special_num
|
|
|
FROM dual `
|
|
|
- err = o.Raw(sql, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
|
|