|
@@ -267,6 +267,23 @@ func (this *EnglishReportController) Detail() {
|
|
|
}
|
|
|
item.Content = html.UnescapeString(item.Content)
|
|
|
item.ContentSub = html.UnescapeString(item.ContentSub)
|
|
|
+ classifyNameMap := make(map[int]*models.EnglishClassifyFullName)
|
|
|
+ if item.ClassifyIdSecond > 0 {
|
|
|
+ nameList, tErr := models.GetEnglishClassifyFullNameByIds([]int{item.ClassifyIdSecond})
|
|
|
+ if tErr != nil {
|
|
|
+ br.Msg = "获取分类名称失败"
|
|
|
+ br.ErrMsg = "获取分类名称失败, ERR:" + tErr.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range nameList {
|
|
|
+ classifyNameMap[v.Id] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ if n, ok := classifyNameMap[item.ClassifyIdSecond]; ok {
|
|
|
+ item.ClassifyNameRoot = n.RootName
|
|
|
+ item.ClassifyIdRoot = n.RootId
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
conf := new(models.EnglishReportEmailConf)
|
|
@@ -351,8 +368,9 @@ func (this *EnglishReportController) ListReport() {
|
|
|
startDate := this.GetString("StartDate")
|
|
|
endDate := this.GetString("EndDate")
|
|
|
frequency := this.GetString("Frequency")
|
|
|
- classifyNameFirst := this.GetString("ClassifyNameFirst")
|
|
|
- classifyNameSecond := this.GetString("ClassifyNameSecond")
|
|
|
+ classifyIdFirst, _ := this.GetInt("ClassifyIdFirst")
|
|
|
+ classifyIdSecond, _ := this.GetInt("ClassifyIdSecond")
|
|
|
+ classifyIdRoot, _ := this.GetInt("ClassifyIdRoot")
|
|
|
state, _ := this.GetInt("State")
|
|
|
keyWord := this.GetString("KeyWord")
|
|
|
companyType := this.GetString("CompanyType")
|
|
@@ -395,19 +413,48 @@ func (this *EnglishReportController) ListReport() {
|
|
|
condition += ` AND frequency = ? `
|
|
|
pars = append(pars, frequency)
|
|
|
}
|
|
|
- if classifyNameFirst != "" {
|
|
|
- condition += ` AND classify_name_first = ? `
|
|
|
- pars = append(pars, classifyNameFirst)
|
|
|
+ if classifyIdFirst != 0 {
|
|
|
+ condition += ` AND classify_id_first = ? `
|
|
|
+ pars = append(pars, classifyIdFirst)
|
|
|
}
|
|
|
|
|
|
- if classifyNameSecond != "" {
|
|
|
- condition += ` AND classify_name_second = ? `
|
|
|
- pars = append(pars, classifyNameSecond)
|
|
|
+ if classifyIdSecond != 0 {
|
|
|
+ condition += ` AND classify_id_second = ? `
|
|
|
+ pars = append(pars, classifyIdSecond)
|
|
|
}
|
|
|
if state > 0 {
|
|
|
condition += ` AND state = ? `
|
|
|
pars = append(pars, state)
|
|
|
}
|
|
|
+
|
|
|
+ if classifyIdRoot > 0 && classifyIdFirst == 0 && classifyIdSecond == 0 {
|
|
|
+
|
|
|
+ childClassify, err := models.GetEnglishSecondClassifyList([]int{classifyIdRoot})
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "查询子分类出错"
|
|
|
+ br.ErrMsg = "查询子分类出错, Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var childClassifyIds []int
|
|
|
+ if len(childClassify) > 0 {
|
|
|
+ for _, v := range childClassify {
|
|
|
+ childClassifyIds = append(childClassifyIds, v.Id)
|
|
|
+ }
|
|
|
+ condition += ` AND classify_id_first IN (` + utils.GetOrmInReplace(len(childClassifyIds)) + `)`
|
|
|
+ pars = append(pars, childClassifyIds)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, 0)
|
|
|
+ resp := new(models.EnglishReportListResp)
|
|
|
+ resp.Paging = page
|
|
|
+ resp.List = make([]*models.EnglishReportList, 0)
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if emailState == 1 {
|
|
|
failIds, e := models.GetHasFailEmailLogReportIds()
|
|
@@ -486,7 +533,23 @@ func (this *EnglishReportController) ListReport() {
|
|
|
for i := range failList {
|
|
|
failMap[failList[i].ReportId] = true
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ var classifyIdSecondSlice []int
|
|
|
+ for _, item := range list {
|
|
|
+ classifyIdSecondSlice = append(classifyIdSecondSlice, item.ClassifyIdSecond)
|
|
|
+ }
|
|
|
+ classifyNameMap := make(map[int]*models.EnglishClassifyFullName)
|
|
|
+ if len(classifyIdSecondSlice) > 0 {
|
|
|
+ nameList, err := models.GetEnglishClassifyFullNameByIds(classifyIdSecondSlice)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取分类名称失败"
|
|
|
+ br.ErrMsg = "获取分类名称失败, ERR:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range nameList {
|
|
|
+ classifyNameMap[v.Id] = v
|
|
|
+ }
|
|
|
+ }
|
|
|
for _, item := range list {
|
|
|
if item.State == 2 {
|
|
|
item.ShareUrl = "https://share.hzinsights.com/reportEn?code=" + item.ReportCode
|
|
@@ -523,6 +586,16 @@ func (this *EnglishReportController) ListReport() {
|
|
|
} else {
|
|
|
item.Editor = markStatus.Editor
|
|
|
}
|
|
|
+
|
|
|
+ if n, ok := classifyNameMap[item.ClassifyIdSecond]; ok {
|
|
|
+ if n.RootId == 0 {
|
|
|
+ item.FullClassifyName = strings.Join([]string{n.ParentName, n.ClassifyName}, "/")
|
|
|
+ } else {
|
|
|
+ item.FullClassifyName = strings.Join([]string{n.RootName, n.ParentName, n.ClassifyName}, "/")
|
|
|
+ }
|
|
|
+ item.ClassifyIdRoot = n.RootId
|
|
|
+ item.ClassifyNameRoot = n.RootName
|
|
|
+ }
|
|
|
}
|
|
|
page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
resp := new(models.EnglishReportListResp)
|
|
@@ -534,6 +607,7 @@ func (this *EnglishReportController) ListReport() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -551,7 +625,6 @@ func (this *EnglishReportController) ListClassify() {
|
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
keyWord := this.GetString("KeyWord")
|
|
|
- classifyType, _ := this.GetInt("ClassifyType", 0)
|
|
|
|
|
|
var startSize int
|
|
|
if pageSize <= 0 {
|
|
@@ -566,13 +639,21 @@ func (this *EnglishReportController) ListClassify() {
|
|
|
page := paging.GetPaging(currentIndex, pageSize, 0)
|
|
|
resp := new(models.EnglishClassifyListResp)
|
|
|
|
|
|
- list, err := models.GetEnglishClassifyList(startSize, pageSize, keyWord, classifyType)
|
|
|
+
|
|
|
+ rootList, err := models.GetEnglishClassifyRootId(startSize, pageSize, keyWord)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- total, err := models.GetEnglishClassifyListCount(keyWord, classifyType)
|
|
|
+ var ids []int
|
|
|
+ var rootIds []int
|
|
|
+ rootMap := make(map[int]struct{}, 0)
|
|
|
+ for _, v := range rootList {
|
|
|
+ rootIds = append(rootIds, v.Id)
|
|
|
+ rootMap[v.Id] = struct{}{}
|
|
|
+ }
|
|
|
+ total, err := models.GetEnglishClassifyListCount(keyWord)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
@@ -588,37 +669,100 @@ func (this *EnglishReportController) ListClassify() {
|
|
|
br.Msg = "获取成功"
|
|
|
return
|
|
|
}
|
|
|
- var parentIds []int
|
|
|
- for _, v := range list {
|
|
|
- parentIds = append(parentIds, v.Id)
|
|
|
- }
|
|
|
+ page = paging.GetPaging(currentIndex, pageSize, total)
|
|
|
|
|
|
- childMap := make(map[int][]*models.EnglishClassify)
|
|
|
- tmpList, err := models.GetEnglishClassifyChildByParentIds(parentIds, keyWord, classifyType)
|
|
|
+
|
|
|
+ idList, err := models.GetEnglishClassifyListByRootId(rootIds, keyWord)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取二级分类失败"
|
|
|
- br.ErrMsg = "获取二级分类失败,Err:" + err.Error()
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ secondListMap := make(map[int][]*models.EnglishClassifyList)
|
|
|
+ thirdListMap := make(map[int][]*models.EnglishClassifyList)
|
|
|
+ var thirdIds []int
|
|
|
+ var sortChildList models.RSChildClassifyList
|
|
|
+
|
|
|
+ permissionMap := make(map[int][]int)
|
|
|
|
|
|
- for _, v := range tmpList {
|
|
|
- childMap[v.ParentId] = append(childMap[v.ParentId], v)
|
|
|
- }
|
|
|
- for _, v := range list {
|
|
|
- if child, ok := childMap[v.Id]; ok {
|
|
|
- v.Child = child
|
|
|
+ if len(idList) > 0 {
|
|
|
+ childIdMap := make(map[int]struct{}, 0)
|
|
|
+ for _, v := range idList {
|
|
|
+ if _, ok := childIdMap[v.ParentId]; !ok {
|
|
|
+ ids = append(ids, v.ParentId)
|
|
|
+ }
|
|
|
+ if _, ok := childIdMap[v.Id]; !ok {
|
|
|
+ ids = append(ids, v.Id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tmpList, err := models.GetEnglishClassifyChildByIds(ids)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取二级分类失败"
|
|
|
+ br.ErrMsg = "获取二级分类失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range tmpList {
|
|
|
+ if _, ok := rootMap[v.ParentId]; !ok {
|
|
|
+ thirdIds = append(thirdIds, v.Id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ {
|
|
|
+ classifyIds := thirdIds
|
|
|
+ if len(classifyIds) > 0 {
|
|
|
+ cond := fmt.Sprintf(` AND %s IN (%s)`, models.EnClassifyPermissionColumns.EnClassifyId, utils.GetOrmInReplace(len(classifyIds)))
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ pars = append(pars, classifyIds)
|
|
|
+ ob := new(models.EnClassifyPermission)
|
|
|
+ items, e := ob.GetItemsByCondition(cond, pars, []string{}, "")
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取客户权限列表失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range items {
|
|
|
+ if permissionMap[v.EnClassifyId] == nil {
|
|
|
+ permissionMap[v.EnClassifyId] = make([]int, 0)
|
|
|
+ }
|
|
|
+ permissionMap[v.EnClassifyId] = append(permissionMap[v.EnClassifyId], v.EnPermissionId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range tmpList {
|
|
|
+ if _, ok := rootMap[v.ParentId]; !ok {
|
|
|
+ if p, ok1 := permissionMap[v.Id]; ok1 {
|
|
|
+ v.EnPermissions = p
|
|
|
+ }
|
|
|
+ thirdListMap[v.ParentId] = append(thirdListMap[v.ParentId], v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for _, v := range tmpList {
|
|
|
+ if _, ok := rootMap[v.ParentId]; ok {
|
|
|
+ if child, ok1 := thirdListMap[v.Id]; ok1 {
|
|
|
+ sortChildList = child
|
|
|
+ sort.Sort(sortChildList)
|
|
|
+ v.Child = sortChildList
|
|
|
+ }
|
|
|
+ secondListMap[v.ParentId] = append(secondListMap[v.ParentId], v)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
var sortList models.RSClassifyList
|
|
|
- sortList = list
|
|
|
+ for _, v := range rootList {
|
|
|
+ if child, ok := secondListMap[v.Id]; ok {
|
|
|
+ sortChildList = child
|
|
|
+ sort.Sort(sortChildList)
|
|
|
+ v.Child = sortChildList
|
|
|
+ }
|
|
|
+ sortList = append(sortList, v)
|
|
|
+ }
|
|
|
+
|
|
|
sort.Sort(sortList)
|
|
|
|
|
|
- for _, item := range sortList {
|
|
|
- var sortChildList models.RSChildClassifyList
|
|
|
- sortChildList = item.Child
|
|
|
- sort.Sort(sortChildList)
|
|
|
- item.Child = sortChildList
|
|
|
- }
|
|
|
resp.List = sortList
|
|
|
resp.Paging = page
|
|
|
|
|
@@ -668,32 +812,30 @@ func (this *EnglishReportController) DelClassify() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if classifyInfo.ClassifyType == 0 {
|
|
|
- reportCount, e := models.GetEnglishReportCounts(classifyId, classifyInfo.ParentId)
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取信息失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
+ reportCount, e := models.GetEnglishReportCounts(classifyId, classifyInfo.ParentId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- if reportCount > 0 {
|
|
|
- br.Msg = "该分类有关联报告,不允许删除"
|
|
|
- br.Ret = 403
|
|
|
- return
|
|
|
- }
|
|
|
- } else {
|
|
|
- videoCount, e := models.GetEnglishVideoCounts(classifyId, classifyInfo.ParentId)
|
|
|
- if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取信息失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
+ if reportCount > 0 {
|
|
|
+ br.Msg = "该分类有关联报告,不允许删除"
|
|
|
+ br.Ret = 403
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- if videoCount > 0 {
|
|
|
- br.Msg = "该分类有关联的路演视频,不允许删除"
|
|
|
- br.Ret = 403
|
|
|
- return
|
|
|
- }
|
|
|
+ videoCount, e := models.GetEnglishVideoCounts(classifyId, classifyInfo.ParentId)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if videoCount > 0 {
|
|
|
+ br.Msg = "该分类有关联的路演视频,不允许删除"
|
|
|
+ br.Ret = 403
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
if err = models.DeleteEnglishClassify(classifyId); err != nil {
|
|
@@ -1070,7 +1212,25 @@ func (this *EnglishReportController) ClassifyIdDetail() {
|
|
|
if item != nil {
|
|
|
item.Content = html.UnescapeString(item.Content)
|
|
|
item.ContentSub = html.UnescapeString(item.ContentSub)
|
|
|
+ classifyNameMap := make(map[int]*models.EnglishClassifyFullName)
|
|
|
+ if item.ClassifyIdSecond > 0 {
|
|
|
+ nameList, tErr := models.GetEnglishClassifyFullNameByIds([]int{item.ClassifyIdSecond})
|
|
|
+ if tErr != nil {
|
|
|
+ br.Msg = "获取分类名称失败"
|
|
|
+ br.ErrMsg = "获取分类名称失败, ERR:" + tErr.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range nameList {
|
|
|
+ classifyNameMap[v.Id] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ if n, ok := classifyNameMap[item.ClassifyIdSecond]; ok {
|
|
|
+ item.ClassifyNameRoot = n.RootName
|
|
|
+ item.ClassifyIdRoot = n.RootId
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|