|
@@ -23,8 +23,7 @@ type ReportController struct {
|
|
|
// @Param PageSize query int true "每页数据条数"
|
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
// @Param RangeType query string true "范围类型,1-一天内,2-一周内,3-半年内"
|
|
|
-// @Success 200 {int} models.User.Id
|
|
|
-// @Failure 403 body is empty
|
|
|
+// @Success 200 {object} response.ReportListResp
|
|
|
// @router /list [get]
|
|
|
func (this *ReportController) List() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -147,7 +146,7 @@ func (this *ReportController) List() {
|
|
|
// @Description 研报详情接口
|
|
|
// @Param ReportId query int true "报告id"
|
|
|
// @Param UserId query int true "用户id"
|
|
|
-// @Success 200 {object} models.ReportDetailResp
|
|
|
+// @Success 200 {object} response.ReportDetailResp
|
|
|
// @router /detail [get]
|
|
|
func (this *ReportController) Detail() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -311,7 +310,7 @@ func (this *ReportController) Detail() {
|
|
|
// @Title 研报详情
|
|
|
// @Description 研报详情接口
|
|
|
// @Param ReportId query int true "报告id"
|
|
|
-// @Success 200 {object} models.ReportDetailResp
|
|
|
+// @Success 200 {object} response.ReportDetailResp
|
|
|
// @router /detail/noUser [get]
|
|
|
func (this *ReportController) DetailNoUser() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -360,11 +359,11 @@ func (this *ReportController) DetailNoUser() {
|
|
|
br.Msg = "获取成功"
|
|
|
}
|
|
|
|
|
|
-// @Title List
|
|
|
-// @Description create users
|
|
|
-// @Param body body models.User true "body for user content"
|
|
|
-// @Success 200 {int} models.User.Id
|
|
|
-// @Failure 403 body is empty
|
|
|
+// @Title 今日研报列表
|
|
|
+// @Description 今日研报列表
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Success 200 {object} response.ReportListResp
|
|
|
// @router /daily/list [get]
|
|
|
func (this *ReportController) Today() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -460,12 +459,112 @@ func (this *ReportController) Today() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
+// @Title 最新研报列表
|
|
|
+// @Description 最新研报列表
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Success 200 {object} response.ReportListResp
|
|
|
+// @router /recent/list [get]
|
|
|
+func (this *ReportController) RecentList() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize30
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
+
|
|
|
+ total, err := models.GetReportDailyListCount()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ list, err := models.GetReportRecentList(startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ classifyIds := make([]string, 0)
|
|
|
+ for _, v := range list {
|
|
|
+ classifyIds = append(classifyIds, strconv.Itoa(v.ClassifyIdSecond))
|
|
|
+ }
|
|
|
+ classifyIds = utils.Unique(classifyIds)
|
|
|
+ // 获取二级分类和二级品种权限的映射
|
|
|
+ chartPermissionMapping, err := models.GetChartPermissionIdsListByClassifyIds(classifyIds)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取研报权限失败"
|
|
|
+ br.ErrMsg = "获取研报权限失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ classifyToPermissionMap2 := make(map[int][]int)
|
|
|
+ chartPermissionIds := make([]string, 0)
|
|
|
+ for _, v := range chartPermissionMapping {
|
|
|
+ classifyToPermissionMap2[v.ClassifyId] = append(classifyToPermissionMap2[v.ClassifyId], v.ChartPermissionId)
|
|
|
+ chartPermissionIds = append(chartPermissionIds, strconv.Itoa(v.ChartPermissionId))
|
|
|
+ }
|
|
|
+ // 获取二级品种的权限,并建立映射
|
|
|
+ chartPermissionList2, err := models.GetParentChartPermissionListByIds(chartPermissionIds)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取研报二级品种权限失败"
|
|
|
+ br.ErrMsg = "获取研报二级品种权限失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ chartPermissionViewMap2 := make(map[int]*models.ChartPermission)
|
|
|
+ for _, v := range chartPermissionList2 {
|
|
|
+ chartPermissionViewMap2[v.ChartPermissionId] = v
|
|
|
+ }
|
|
|
+ // 获取一级品种的权限,并建立映射
|
|
|
+ chartPermissionList1, err := models.GetChildChartPermissionListById(0)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取研报一级品种权限失败"
|
|
|
+ br.ErrMsg = "获取研报一级品种权限失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ chartPermissionMap1 := make(map[int]*models.ChartPermission)
|
|
|
+ for _, v := range chartPermissionList1 {
|
|
|
+ chartPermissionMap1[v.ChartPermissionId] = v
|
|
|
+ }
|
|
|
+ // 组合数据
|
|
|
+ for _, v := range list {
|
|
|
+ var permissionNames []string
|
|
|
+ for _, vv := range classifyToPermissionMap2[v.ClassifyIdSecond] {
|
|
|
+ parent2 := chartPermissionViewMap2[vv].ParentId
|
|
|
+ permissionNames = append(permissionNames, chartPermissionMap1[parent2].PermissionName)
|
|
|
+ }
|
|
|
+ v.PermissionNames = utils.Unique(permissionNames)
|
|
|
+ }
|
|
|
+
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+
|
|
|
+ resp := new(response.ReportListResp)
|
|
|
+ resp.Paging = page
|
|
|
+ resp.List = list
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|
|
|
+
|
|
|
// @Title 研报搜索
|
|
|
// @Description 研报搜索
|
|
|
// @Param PageSize query int true "每页数据条数"
|
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
// @Param KeyWord query string true "关键字"
|
|
|
-// @Success 200 {object} models.ReportDetailResp
|
|
|
+// @Success 200 {object} response.ReportSearchResp
|
|
|
// @router /search [get]
|
|
|
func (this *ReportController) Search() {
|
|
|
br := new(models.BaseResponse).Init()
|