|
@@ -2,7 +2,6 @@ package models
|
|
|
|
|
|
import (
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
- "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -14,11 +13,11 @@ type CeLueArticleResultApi struct {
|
|
|
}
|
|
|
|
|
|
type CeLueArticleResultApidate struct {
|
|
|
- CeLueArticleId int `json:"id"`
|
|
|
+ CelueHistoryId int `json:"id"`
|
|
|
Mobile string `json:"phone_number"`
|
|
|
ArticleId string `json:"parameter"`
|
|
|
CreateDate string `json:"access_time"`
|
|
|
- CrmUser *CrmUser `json:"crm_user"`
|
|
|
+ CrmUser *CrmUser `json:"user"`
|
|
|
CompanyName *CrmUser `json:"crm_company"`
|
|
|
}
|
|
|
|
|
@@ -30,108 +29,27 @@ type CrmCompany struct {
|
|
|
CompanyName string `json:"name"`
|
|
|
}
|
|
|
|
|
|
-func GetChartCountById(chartId int) (count int, err error) {
|
|
|
+func GetCeLueArticleCountById(celueHistoryId int) (count int, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
- sql := `SELECT COUNT(1) AS count FROM cygx_celue_article_history_record WHERE chart_id = ? `
|
|
|
- err = o.Raw(sql, chartId).QueryRow(&count)
|
|
|
+ sql := `SELECT COUNT(1) AS count FROM cygx_celue_article_history_record WHERE celue_history_id = ? `
|
|
|
+ err = o.Raw(sql, celueHistoryId).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//新增图表
|
|
|
-func AddCygxChart(item *CygxChart) (lastId int64, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- lastId, err = o.Insert(item)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-//获取图表列表
|
|
|
-func GetChartList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeChartListResp, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- sql := ` SELECT * FROM cygx_chart AS a WHERE a.publish_status=1 `
|
|
|
- if condition != "" {
|
|
|
- sql += condition
|
|
|
- }
|
|
|
- sql += ` ORDER BY create_date DESC LIMIT ?,? `
|
|
|
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-//获取图表列表
|
|
|
-func GetChartListCollection(chartIds string, userId, startSize, pageSize int) (items []*HomeChartListResp, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- sql := ` SELECT a.*,
|
|
|
- t.create_time AS t_create_time,
|
|
|
- c.create_time AS c_create_time,
|
|
|
- ( SELECT COUNT(*) FROM cygx_chart_top AS t WHERE t.chart_id = a.chart_id AND t.user_id = ? ) AS num_top,
|
|
|
- ( SELECT COUNT(*) FROM cygx_chart_collect AS c WHERE c.chart_id = a.chart_id AND c.user_id = ? ) AS num_c
|
|
|
- FROM
|
|
|
- cygx_chart AS a
|
|
|
- LEFT JOIN cygx_chart_top AS t ON t.chart_id = a.chart_id
|
|
|
- LEFT JOIN cygx_chart_collect AS c ON c.chart_id = a.chart_id
|
|
|
- WHERE
|
|
|
- a.publish_status = 1
|
|
|
- AND a.chart_id IN (` + chartIds + `)
|
|
|
- GROUP BY
|
|
|
- a.chart_id
|
|
|
- ORDER BY
|
|
|
- t_create_time DESC,
|
|
|
- c_create_time DESC LIMIT ?,? `
|
|
|
- _, err = o.Raw(sql, userId, userId, startSize, pageSize).QueryRows(&items)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-//获取图表列表本地
|
|
|
-func GetChartListCollectionWithCygx(userId, startSize, pageSize int) (items []*HomeChartListResp, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- sql := ` SELECT
|
|
|
- a.*,
|
|
|
- t.create_time AS t_create_time,
|
|
|
- c.create_time AS c_create_time,
|
|
|
- ( SELECT COUNT(*) FROM cygx_chart_top AS t WHERE t.chart_id = a.chart_id AND t.user_id = ? ) AS num_top,
|
|
|
- ( SELECT COUNT(*) FROM cygx_chart_collect AS c WHERE c.chart_id = a.chart_id AND c.user_id = ? ) AS num_c
|
|
|
- FROM
|
|
|
- cygx_chart_collect AS c
|
|
|
- INNER JOIN cygx_chart AS a ON c.chart_id = a.chart_id
|
|
|
- LEFT JOIN cygx_chart_top AS t ON t.chart_id = a.chart_id
|
|
|
- WHERE
|
|
|
- a.publish_status = 1
|
|
|
- AND c.user_id =?
|
|
|
- GROUP BY
|
|
|
- a.chart_id
|
|
|
- ORDER BY
|
|
|
- t_create_time DESC,
|
|
|
- c_create_time DESC LIMIT ?,? `
|
|
|
- _, err = o.Raw(sql, userId, userId, userId, startSize, pageSize).QueryRows(&items)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-func GetChartListConfig() (items []*HomeChartListResp, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- sql := ` SELECT * FROM cygx_chart AS a WHERE a.publish_status=1 AND ctag_id IN (7,8,9,10) GROUP BY ctag_id ORDER BY create_date DESC LIMIT 4 `
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-//获取图表数量
|
|
|
-func GetChartCount(condition string, pars []interface{}) (count int, err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- sql := `SELECT COUNT(1) AS count
|
|
|
- FROM cygx_chart AS a
|
|
|
- WHERE a.publish_status=1 `
|
|
|
- if condition != "" {
|
|
|
- sql += condition
|
|
|
- }
|
|
|
- err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
- return
|
|
|
+type CygxCelueArticleHistoryRecord struct {
|
|
|
+ Id int `orm:"column(id);pk"`
|
|
|
+ ArticleId string `description:"文章ID"`
|
|
|
+ CelueHistoryId int `description:"策略平台记录的ID"`
|
|
|
+ CreateTime string `description:"本地创建时间"`
|
|
|
+ CreateDateApi time.Time `description:"图表创建时间"`
|
|
|
+ Mobile string `description:"手机号"`
|
|
|
+ CompanyName string `description:"公司名称"`
|
|
|
+ RealName string `description:"用户姓名"`
|
|
|
}
|
|
|
|
|
|
-func GetChartDetailById(chartId, uid int) (item *CygxChartDetail, err error) {
|
|
|
+//新增
|
|
|
+func AddCeLueArticle(item *CygxCelueArticleHistoryRecord) (lastId int64, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
- sql := `SELECT * ,( SELECT COUNT( 1 ) FROM cygx_chart_collect AS c WHERE c.chart_id = a.chart_id AND c.user_id = ? ) AS collection_num
|
|
|
- FROM
|
|
|
- cygx_chart as a
|
|
|
- WHERE
|
|
|
- a.chart_id =? `
|
|
|
- err = o.Raw(sql, uid, chartId).QueryRow(&item)
|
|
|
+ lastId, err = o.Insert(item)
|
|
|
return
|
|
|
}
|