|
@@ -5,6 +5,7 @@ import (
|
|
"eta/eta_mini_bridge/models/response"
|
|
"eta/eta_mini_bridge/models/response"
|
|
"eta/eta_mini_bridge/utils"
|
|
"eta/eta_mini_bridge/utils"
|
|
"html"
|
|
"html"
|
|
|
|
+ "strconv"
|
|
|
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
)
|
|
)
|
|
@@ -15,7 +16,11 @@ type ReportController struct {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -30,11 +35,21 @@ func (this *ReportController) List() {
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
chartPermissionId, _ := this.GetInt("ChartPermissionId")
|
|
chartPermissionId, _ := this.GetInt("ChartPermissionId")
|
|
level, _ := this.GetInt("Level")
|
|
level, _ := this.GetInt("Level")
|
|
|
|
+ rangeType, _ := this.GetInt("RangeType")
|
|
|
|
|
|
if chartPermissionId <= 0 {
|
|
if chartPermissionId <= 0 {
|
|
br.Msg = "品种参数错误"
|
|
br.Msg = "品种参数错误"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ var condition string
|
|
|
|
+ switch rangeType {
|
|
|
|
+ case 1:
|
|
|
|
+ condition += ` AND DATE(a.modify_time)=DATE(NOW()) `
|
|
|
|
+ case 2:
|
|
|
|
+ condition += ` AND DATE(a.modify_time) BETWEEN DATE_SUB(NOW(),INTERVAL 1 WEEK) AND NOW() `
|
|
|
|
+ case 3:
|
|
|
|
+ condition += ` AND DATE(a.modify_time) BETWEEN DATE_SUB(NOW(),INTERVAL 6 MONTH) AND NOW() `
|
|
|
|
+ }
|
|
|
|
|
|
var startSize int
|
|
var startSize int
|
|
if pageSize <= 0 {
|
|
if pageSize <= 0 {
|
|
@@ -55,14 +70,14 @@ func (this *ReportController) List() {
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- tmptotal, err := models.GetReportCountByClassifyIds(classifyIds)
|
|
+ tmptotal, err := models.GetReportCountByClassifyIds(classifyIds, condition)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "获取数据失败"
|
|
br.Msg = "获取数据失败"
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
total = tmptotal
|
|
total = tmptotal
|
|
- tmpReportList, err := models.GetReportListByClassifyIds(classifyIds, startSize, pageSize)
|
|
+ tmpReportList, err := models.GetReportListByClassifyIds(classifyIds, condition, startSize, pageSize)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "获取报告列表失败"
|
|
br.Msg = "获取报告列表失败"
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
@@ -82,14 +97,14 @@ func (this *ReportController) List() {
|
|
br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
|
|
br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- tmptotal, err := models.GetReportCountByClassifyIds(classifyIds)
|
|
+ tmptotal, err := models.GetReportCountByClassifyIds(classifyIds, condition)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "获取数据失败"
|
|
br.Msg = "获取数据失败"
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
total = tmptotal
|
|
total = tmptotal
|
|
- tmpReportList, err := models.GetReportListByClassifyIds(classifyIds, startSize, pageSize)
|
|
+ tmpReportList, err := models.GetReportListByClassifyIds(classifyIds, condition, startSize, pageSize)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "获取报告列表失败"
|
|
br.Msg = "获取报告列表失败"
|
|
br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
|
|
br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
|
|
@@ -115,6 +130,7 @@ func (this *ReportController) List() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
func (this *ReportController) Detail() {
|
|
func (this *ReportController) Detail() {
|
|
@@ -124,6 +140,7 @@ func (this *ReportController) Detail() {
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
}()
|
|
}()
|
|
reportId, err := this.GetInt("ReportId")
|
|
reportId, err := this.GetInt("ReportId")
|
|
|
|
+ userId, err := this.GetInt("UserId")
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "参数获取失败"
|
|
br.Msg = "参数获取失败"
|
|
br.ErrMsg = "参数获取失败,Err:" + err.Error()
|
|
br.ErrMsg = "参数获取失败,Err:" + err.Error()
|
|
@@ -134,6 +151,11 @@ func (this *ReportController) Detail() {
|
|
br.ErrMsg = "参数错误,报告id小于等于0"
|
|
br.ErrMsg = "参数错误,报告id小于等于0"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ if userId <= 0 {
|
|
|
|
+ br.Msg = "参数错误"
|
|
|
|
+ br.ErrMsg = "参数错误,用户id小于等于0"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
|
|
report, err := models.GetReportById(reportId)
|
|
report, err := models.GetReportById(reportId)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -146,6 +168,60 @@ func (this *ReportController) Detail() {
|
|
br.Msg = "报告不存在"
|
|
br.Msg = "报告不存在"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ reportChartPermissionIds, err := models.GetChartPermissionIdsListByClassifyId(report.ClassifyIdSecond)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "获取研报权限失败"
|
|
|
|
+ br.ErrMsg = "获取研报权限失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ chartPermissionList, err := models.GetChartPermissionIdsByIds(reportChartPermissionIds)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "获取研报权限失败"
|
|
|
|
+ br.ErrMsg = "获取研报权限失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var IsHas bool
|
|
|
|
+ var IsPublic bool
|
|
|
|
+ for _, v := range chartPermissionList {
|
|
|
|
+ if v.IsPublic == 1 {
|
|
|
|
+ IsPublic = true
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if !IsPublic {
|
|
|
|
+ chartPermissionIds, err := models.GetChartPermissionIdByUserId(userId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "获取用户权限失败"
|
|
|
|
+ br.ErrMsg = "获取用户权限失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if len(chartPermissionIds) <= 0 {
|
|
|
|
+ br.Msg = "用户权限不足"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ classifyIds, err := models.GetClassifyIdsListByIds(chartPermissionIds)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "获取用户权限失败"
|
|
|
|
+ br.ErrMsg = "获取用户分类权限失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if len(classifyIds) <= 0 {
|
|
|
|
+ br.Msg = "用户权限不足"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ reportClassifyIdStr := strconv.Itoa(report.ClassifyIdSecond)
|
|
|
|
+ for _, v := range classifyIds {
|
|
|
|
+ if v == reportClassifyIdStr {
|
|
|
|
+ IsHas = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if !IsHas {
|
|
|
|
+ br.Msg = "用户权限不足"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
report.ContentSub = html.UnescapeString(report.ContentSub)
|
|
report.ContentSub = html.UnescapeString(report.ContentSub)
|
|
report.Content = html.UnescapeString(report.Content)
|
|
report.Content = html.UnescapeString(report.Content)
|
|
|
|
|