|
@@ -180,8 +180,12 @@ func (this *ReportController) ListReport() {
|
|
|
pvMap := make(map[int]int)
|
|
|
uvMap := make(map[int]int)
|
|
|
reportIdArr := make([]int, 0)
|
|
|
- syncReportIdArr := make([]string, 0) // 同步过来的报告IDs
|
|
|
- oldAndNewReportIdMap := make(map[int]int) // 旧报告和新报告的id对应关系
|
|
|
+ syncReportIdArr := make([]string, 0) // 同步过来的报告IDs
|
|
|
+ oldAndNewReportIdMap := make(map[int]int) // 旧报告和新报告的id对应关系
|
|
|
+ classifyIdList := make([]int, 0) // 关联的指标分类id
|
|
|
+ classifyIdMap := make(map[int]bool) // 分类id map
|
|
|
+ classifyMap := make(map[int]*models.Classify) // 分类map
|
|
|
+
|
|
|
for i := 0; i < listLen; i++ {
|
|
|
reportIdArr = append(reportIdArr, list[i].Id)
|
|
|
if list[i].OldReportId > 0 && list[i].ReportLayout == 1 {
|
|
@@ -190,6 +194,22 @@ func (this *ReportController) ListReport() {
|
|
|
}
|
|
|
pvMap[list[i].Id] = list[i].Pv
|
|
|
uvMap[list[i].Id] = list[i].Uv
|
|
|
+
|
|
|
+ if list[i].ClassifyIdFirst > 0 {
|
|
|
+ if _, ok := classifyIdMap[list[i].ClassifyIdFirst]; !ok {
|
|
|
+ classifyIdList = append(classifyIdList, list[i].ClassifyIdFirst)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if list[i].ClassifyIdSecond > 0 {
|
|
|
+ if _, ok := classifyIdMap[list[i].ClassifyIdSecond]; !ok {
|
|
|
+ classifyIdList = append(classifyIdList, list[i].ClassifyIdSecond)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if list[i].ClassifyIdThird > 0 {
|
|
|
+ if _, ok := classifyIdMap[list[i].ClassifyIdThird]; !ok {
|
|
|
+ classifyIdList = append(classifyIdList, list[i].ClassifyIdThird)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 当下报告的pv,uv
|
|
@@ -208,6 +228,18 @@ func (this *ReportController) ListReport() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if len(classifyIdList) > 0 {
|
|
|
+ classifyList, e := models.GetClassifyListByIdList(classifyIdList)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取报告分类失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range classifyList {
|
|
|
+ classifyMap[v.Id] = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//reportIds := strings.Join(reportIdArr, ",")
|
|
|
//syncReportIds := strings.Join(syncReportIdArr, ",")
|
|
|
|
|
@@ -254,6 +286,26 @@ func (this *ReportController) ListReport() {
|
|
|
list[i].ChapterVideoList = chapterList
|
|
|
list[i].Pv = pvMap[list[i].Id]
|
|
|
list[i].Uv = uvMap[list[i].Id]
|
|
|
+
|
|
|
+ if list[i].ClassifyIdThird > 0 {
|
|
|
+ if classify, ok := classifyMap[list[i].ClassifyIdThird]; ok {
|
|
|
+ if classify.Enabled == 1 {
|
|
|
+ list[i].ClassifyEnabled = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if list[i].ClassifyIdSecond > 0 {
|
|
|
+ if classify, ok := classifyMap[list[i].ClassifyIdSecond]; ok {
|
|
|
+ if classify.Enabled == 1 {
|
|
|
+ list[i].ClassifyEnabled = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if list[i].ClassifyIdFirst > 0 {
|
|
|
+ if classify, ok := classifyMap[list[i].ClassifyIdFirst]; ok {
|
|
|
+ if classify.Enabled == 1 {
|
|
|
+ list[i].ClassifyEnabled = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 多人协作的协作报告,需要判断是否可编辑
|
|
@@ -866,6 +918,7 @@ func (this *ReportController) SaveReportContent() {
|
|
|
// @Param ClassifyIdFirst query int true "一级分类id"
|
|
|
// @Param ClassifyIdSecond query int true "二级分类id"
|
|
|
// @Param ClassifyIdThird query int true "三级分类id"
|
|
|
+// @Param State query string true "报告状态,多状态用英文,隔开"
|
|
|
// @Success 200 {object} models.ReportListResp
|
|
|
// @router /list/authorized [get]
|
|
|
func (this *ReportController) AuthorizedListReport() {
|
|
@@ -880,6 +933,7 @@ func (this *ReportController) AuthorizedListReport() {
|
|
|
classifyIdFirst, _ := this.GetInt("ClassifyIdFirst", 0)
|
|
|
classifyIdSecond, _ := this.GetInt("ClassifyIdSecond", 0)
|
|
|
classifyIdThird, _ := this.GetInt("ClassifyIdThird", 0)
|
|
|
+ stateStr := this.GetString("State")
|
|
|
|
|
|
var startSize int
|
|
|
if pageSize <= 0 {
|
|
@@ -891,18 +945,18 @@ func (this *ReportController) AuthorizedListReport() {
|
|
|
startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
var list []*models.ReportList
|
|
|
|
|
|
- // 没有输入信息,那就不展示
|
|
|
- if keyword == `` && classifyIdFirst <= 0 {
|
|
|
- page := paging.GetPaging(currentIndex, pageSize, 0)
|
|
|
- resp := new(models.ReportListResp)
|
|
|
- resp.Paging = page
|
|
|
- resp.List = list
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
- br.Msg = "获取成功"
|
|
|
- br.Data = resp
|
|
|
- return
|
|
|
- }
|
|
|
+ //// 没有输入信息,那就不展示
|
|
|
+ //if keyword == `` && classifyIdFirst <= 0 {
|
|
|
+ // page := paging.GetPaging(currentIndex, pageSize, 0)
|
|
|
+ // resp := new(models.ReportListResp)
|
|
|
+ // resp.Paging = page
|
|
|
+ // resp.List = list
|
|
|
+ // br.Ret = 200
|
|
|
+ // br.Success = true
|
|
|
+ // br.Msg = "获取成功"
|
|
|
+ // br.Data = resp
|
|
|
+ // return
|
|
|
+ //}
|
|
|
|
|
|
// 当前用户有权限的报告id列表
|
|
|
grantReportIdList := make([]int, 0)
|
|
@@ -940,6 +994,12 @@ func (this *ReportController) AuthorizedListReport() {
|
|
|
pars = utils.GetLikeKeywordPars(pars, keyword, 1)
|
|
|
}
|
|
|
|
|
|
+ if stateStr != `` {
|
|
|
+ stateStrList := strings.Split(stateStr, ",")
|
|
|
+ condition += ` AND a.state in (` + utils.GetOrmInReplace(len(stateStrList)) + `) `
|
|
|
+ pars = append(pars, stateStrList)
|
|
|
+ }
|
|
|
+
|
|
|
var err error
|
|
|
var total int
|
|
|
|
|
@@ -959,6 +1019,24 @@ func (this *ReportController) AuthorizedListReport() {
|
|
|
condition += orCondition
|
|
|
}
|
|
|
|
|
|
+ // 获取所有启用的分类
|
|
|
+ classifyList, err := models.GetAllEnabledClassify()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ classifyIdNum := len(classifyList)
|
|
|
+ if classifyIdNum > 0 {
|
|
|
+ classifyIdList := make([]int, 0)
|
|
|
+ for _, v := range classifyList {
|
|
|
+ classifyIdList = append(classifyIdList, v.Id)
|
|
|
+ }
|
|
|
+
|
|
|
+ condition += ` AND a.classify_id_first in (` + utils.GetOrmInReplace(classifyIdNum) + `) AND a.classify_id_second in (` + utils.GetOrmInReplace(classifyIdNum) + `) AND a.classify_id_third in (` + utils.GetOrmInReplace(classifyIdNum) + `) `
|
|
|
+ pars = append(pars, classifyIdList, classifyIdList, classifyIdList)
|
|
|
+ }
|
|
|
+
|
|
|
total, err = models.GetReportListCountByAuthorized(condition, pars)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|