|
@@ -1,8 +1,11 @@
|
|
package report
|
|
package report
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "context"
|
|
|
|
+ "encoding/json"
|
|
"errors"
|
|
"errors"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "hongze/hongze_yb/global"
|
|
"hongze/hongze_yb/models/tables/company"
|
|
"hongze/hongze_yb/models/tables/company"
|
|
"hongze/hongze_yb/models/tables/company_report_permission"
|
|
"hongze/hongze_yb/models/tables/company_report_permission"
|
|
"hongze/hongze_yb/models/tables/research_report"
|
|
"hongze/hongze_yb/models/tables/research_report"
|
|
@@ -116,6 +119,9 @@ func GetResearchReportInfo(researchReportId, userId uint64) (result ResearchRepo
|
|
fmt.Println("AddUserViewHistory err", err.Error())
|
|
fmt.Println("AddUserViewHistory err", err.Error())
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //添加阅读日志的数据加入到redis
|
|
|
|
+ go PushViewRecordNewRedisData(userViewHistory, int(wxUserInfo.CompanyID))
|
|
|
|
+
|
|
result = ResearchReportInfo{
|
|
result = ResearchReportInfo{
|
|
ResearchReportInfo: reportInfo,
|
|
ResearchReportInfo: reportInfo,
|
|
ResearchReportTypeList: researchReportTypeList,
|
|
ResearchReportTypeList: researchReportTypeList,
|
|
@@ -237,6 +243,10 @@ func GetResearchReportTypeContentInfo(researchReportTypeId, userId uint64) (resu
|
|
if err != nil {
|
|
if err != nil {
|
|
fmt.Println("AddUserViewHistory err", err.Error())
|
|
fmt.Println("AddUserViewHistory err", err.Error())
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //添加阅读日志的数据加入到redis
|
|
|
|
+ go PushViewRecordNewRedisData(userViewHistory, int(wxUserInfo.CompanyID))
|
|
|
|
+
|
|
result = ResearchReportTypeContentInfo{
|
|
result = ResearchReportTypeContentInfo{
|
|
ResearchReportTypeContentList: researchReportTypeContentList,
|
|
ResearchReportTypeContentList: researchReportTypeContentList,
|
|
ResearchReportTypeInfo: researchReportTypeInfo,
|
|
ResearchReportTypeInfo: researchReportTypeInfo,
|
|
@@ -244,3 +254,37 @@ func GetResearchReportTypeContentInfo(researchReportTypeId, userId uint64) (resu
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// UserViewRedisData 阅读数据
|
|
|
|
+type UserViewRedisData struct {
|
|
|
|
+ Mobile string `json:"mobile"`
|
|
|
|
+ Email string `json:"email"`
|
|
|
|
+ RealName string `json:"real_name"`
|
|
|
|
+ CompanyName string `json:"company_name"`
|
|
|
|
+ ViewTime string `json:"view_time" description:"阅读时间,格式:2022-02-17 13:06:13"`
|
|
|
|
+ ProductId int `json:"product_id" description:"报告所属产品,ficc:1,权益:2"`
|
|
|
|
+ CompanyId int `json:"company_id" description:"客户id"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// PushViewRecordNewRedisData 阅读数据加入到redis
|
|
|
|
+func PushViewRecordNewRedisData(userViewHistory *user_view_history.UserViewHistory, companyId int) bool {
|
|
|
|
+ data := &UserViewRedisData{
|
|
|
|
+ Mobile: userViewHistory.Mobile,
|
|
|
|
+ Email: userViewHistory.Email,
|
|
|
|
+ RealName: userViewHistory.RealName,
|
|
|
|
+ CompanyName: userViewHistory.CompanyName,
|
|
|
|
+ ViewTime: userViewHistory.CreatedTime.Format(utils.FormatDateTime),
|
|
|
|
+ ProductId: 1,
|
|
|
|
+ CompanyId: companyId,
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if global.Redis != nil {
|
|
|
|
+ dataStr, _ := json.Marshal(data)
|
|
|
|
+ _, err := global.Redis.LPush(context.TODO(), utils.CACHE_KEY_USER_VIEW, dataStr).Result()
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("PushViewRecordNewRedisData LPush Err:" + err.Error())
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ return false
|
|
|
|
+}
|