|
@@ -7,7 +7,7 @@ import (
|
|
|
"hongze/hongze_yb/models/tables/company_report_permission"
|
|
|
"hongze/hongze_yb/models/tables/research_report"
|
|
|
"hongze/hongze_yb/models/tables/research_report_type"
|
|
|
- "hongze/hongze_yb/models/tables/user_record"
|
|
|
+ "hongze/hongze_yb/models/tables/user_view_history"
|
|
|
"hongze/hongze_yb/models/tables/wx_user"
|
|
|
"hongze/hongze_yb/utils"
|
|
|
"strconv"
|
|
@@ -84,9 +84,20 @@ func GetResearchReportInfo(researchReportId, userId uint64) (result ResearchRepo
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
- userViewHistory := &user_record.UserViewHistory{
|
|
|
- ViewHistoryId: 0,
|
|
|
- UserId: userId,
|
|
|
+
|
|
|
+ //查询是否读过这篇报告,如果未读过则阅读人数+1
|
|
|
+ _, err = user_view_history.GetReportByUserId(userId, reportInfo.ResearchReportID)
|
|
|
+ if err != nil {
|
|
|
+ err = reportInfo.UpdateViewers()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("UpdateViewers err:", err.Error())
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增userViewHistory记录
|
|
|
+ userViewHistory := &user_view_history.UserViewHistory{
|
|
|
+ ViewHistoryID: 0,
|
|
|
+ UserID: userId,
|
|
|
Mobile: wxUserInfo.Mobile,
|
|
|
Email: wxUserInfo.Email,
|
|
|
RealName: wxUserInfo.RealName,
|
|
@@ -94,23 +105,23 @@ func GetResearchReportInfo(researchReportId, userId uint64) (result ResearchRepo
|
|
|
ViewTitle: "",
|
|
|
ViewPage: "",
|
|
|
ReportChapterModule: "",
|
|
|
- CreatedTime: time.Now(),
|
|
|
+ CreatedTime: time.Now(),
|
|
|
LastUpdatedTime: time.Now(),
|
|
|
Type: "weekly_report",
|
|
|
- ResearchReportId: 0,
|
|
|
- ResearchReportTypeId: 0,
|
|
|
+ ResearchReportID: reportInfo.ResearchReportID,
|
|
|
+ ResearchReportTypeID: 0,
|
|
|
}
|
|
|
- historyId, err := user_record.AddUserViewHistory(userViewHistory)
|
|
|
+ err = userViewHistory.AddUserViewHistory()
|
|
|
if err != nil {
|
|
|
fmt.Println("AddUserViewHistory err", err.Error())
|
|
|
}
|
|
|
- fmt.Println("new historyId:", historyId)
|
|
|
|
|
|
result = ResearchReportInfo{
|
|
|
ResearchReportInfo: reportInfo,
|
|
|
ResearchReportTypeList: researchReportTypeList,
|
|
|
HasMenu: 1,
|
|
|
}
|
|
|
+
|
|
|
if len(researchReportTypeList) <= 0 {
|
|
|
|
|
|
} else if len(researchReportTypeList) == 1 {
|
|
@@ -204,9 +215,20 @@ func GetResearchReportTypeContentInfo(researchReportTypeId, userId uint64) (resu
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
- userViewHistory := &user_record.UserViewHistory{
|
|
|
- ViewHistoryId: 0,
|
|
|
- UserId: userId,
|
|
|
+
|
|
|
+ //查询是否读过这篇章节,如果未读过则阅读人数+1
|
|
|
+ _, err = user_view_history.GetReportTypeByUserId(userId, researchReportTypeId)
|
|
|
+ if err != nil {
|
|
|
+ err = reportInfo.UpdateViewers()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("UpdateViewers err:", err.Error())
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增userViewHistory记录
|
|
|
+ userViewHistory := &user_view_history.UserViewHistory{
|
|
|
+ ViewHistoryID: 0,
|
|
|
+ UserID: userId,
|
|
|
Mobile: wxUserInfo.Mobile,
|
|
|
Email: wxUserInfo.Email,
|
|
|
RealName: wxUserInfo.RealName,
|
|
@@ -217,14 +239,13 @@ func GetResearchReportTypeContentInfo(researchReportTypeId, userId uint64) (resu
|
|
|
CreatedTime: time.Now(),
|
|
|
LastUpdatedTime: time.Now(),
|
|
|
Type: "weekly_report",
|
|
|
- ResearchReportId: 0,
|
|
|
- ResearchReportTypeId: 0,
|
|
|
+ ResearchReportID: reportInfo.ResearchReportID,
|
|
|
+ ResearchReportTypeID: researchReportTypeId,
|
|
|
}
|
|
|
- historyId, err := user_record.AddUserViewHistory(userViewHistory)
|
|
|
+ err = userViewHistory.AddUserViewHistory()
|
|
|
if err != nil {
|
|
|
fmt.Println("AddUserViewHistory err", err.Error())
|
|
|
}
|
|
|
- fmt.Println("new historyId:", historyId)
|
|
|
result = ResearchReportTypeContentInfo{
|
|
|
ResearchReportTypeContentList: researchReportTypeContentList,
|
|
|
ResearchReportTypeInfo: researchReportTypeInfo,
|