|
@@ -7,6 +7,7 @@ import (
|
|
"eta/eta_hub/utils"
|
|
"eta/eta_hub/utils"
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
|
+ "sort"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
@@ -50,14 +51,25 @@ func (this *EnglishReportController) List() {
|
|
keyword = strings.TrimSpace(keyword)
|
|
keyword = strings.TrimSpace(keyword)
|
|
if keyword != "" {
|
|
if keyword != "" {
|
|
kw := fmt.Sprint("%", keyword, "%")
|
|
kw := fmt.Sprint("%", keyword, "%")
|
|
- condition += ` AND title LIKE ? `
|
|
|
|
- pars = append(pars, kw)
|
|
|
|
|
|
+ condition += ` AND (title LIKE ? OR author LIKE ? OR admin_real_name LIKE ?) `
|
|
|
|
+ pars = append(pars, kw, kw, kw)
|
|
}
|
|
}
|
|
state, _ := this.GetInt("State")
|
|
state, _ := this.GetInt("State")
|
|
if state > 0 {
|
|
if state > 0 {
|
|
condition += ` AND state = ? `
|
|
condition += ` AND state = ? `
|
|
pars = append(pars, state)
|
|
pars = append(pars, state)
|
|
}
|
|
}
|
|
|
|
+ admindId, _ := this.GetInt("AdminId")
|
|
|
|
+ if admindId > 0 {
|
|
|
|
+ condition += ` AND admin_id = ? `
|
|
|
|
+ pars = append(pars, admindId)
|
|
|
|
+ }
|
|
|
|
+ classifyId, _ := this.GetInt("ClassifyId")
|
|
|
|
+ if classifyId > 0 {
|
|
|
|
+ condition += ` AND (classify_id_first = ? OR classify_id_second = ?) `
|
|
|
|
+ pars = append(pars, classifyId, classifyId)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
reportOb := new(models.EnglishReport)
|
|
reportOb := new(models.EnglishReport)
|
|
total, e := reportOb.GetCountByCondition(condition, pars)
|
|
total, e := reportOb.GetCountByCondition(condition, pars)
|
|
@@ -240,3 +252,168 @@ func (this *EnglishReportController) Approve() {
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
br.Msg = "审批成功"
|
|
br.Msg = "审批成功"
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// ListClassify
|
|
|
|
+// @Title 获取分类列表
|
|
|
|
+// @Description 获取分类列表
|
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
|
+// @Param KeyWord query string true "检索关键词"
|
|
|
|
+// @Param CompanyType query string false "产品类型,枚举值:'ficc','权益';不传默认返回全部"
|
|
|
|
+// @Success 200 {object} models.EnglishClassifyListResp
|
|
|
|
+// @router /classify/list [get]
|
|
|
|
+func (this *EnglishReportController) ListClassify() {
|
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
|
+ defer func() {
|
|
|
|
+ this.Data["json"] = br
|
|
|
|
+ this.ServeJSON()
|
|
|
|
+ }()
|
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
|
+
|
|
|
|
+ var startSize int
|
|
|
|
+ if pageSize <= 0 {
|
|
|
|
+ pageSize = utils.PageSize20
|
|
|
|
+ }
|
|
|
|
+ if currentIndex <= 0 {
|
|
|
|
+ currentIndex = 1
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
|
+
|
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, 0)
|
|
|
|
+ resp := new(models.EnglishClassifyListResp)
|
|
|
|
+
|
|
|
|
+ // 处理一级分类分页的情况
|
|
|
|
+ rootList, err := models.GetEnglishClassifyRootId(startSize, pageSize, keyWord)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ 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()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if total == 0 {
|
|
|
|
+ resp.List = make([]*models.EnglishClassifyList, 0)
|
|
|
|
+ resp.Paging = page
|
|
|
|
+
|
|
|
|
+ br.Data = resp
|
|
|
|
+ br.Ret = 200
|
|
|
|
+ br.Msg = "获取成功"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ page = paging.GetPaging(currentIndex, pageSize, total)
|
|
|
|
+
|
|
|
|
+ //获取相关的分类ID
|
|
|
|
+ idList, err := models.GetEnglishClassifyListByRootId(rootIds, keyWord)
|
|
|
|
+ if err != nil {
|
|
|
|
+ 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)
|
|
|
|
+
|
|
|
|
+ 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)
|
|
|
|
+ childIdMap[v.ParentId] = struct{}{}
|
|
|
|
+ }
|
|
|
|
+ if _, ok := childIdMap[v.Id]; !ok {
|
|
|
|
+ ids = append(ids, v.Id)
|
|
|
|
+ childIdMap[v.Id] = struct{}{}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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
|
|
|
|
+ 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)
|
|
|
|
+
|
|
|
|
+ resp.List = sortList
|
|
|
|
+ resp.Paging = page
|
|
|
|
+
|
|
|
|
+ br.Data = resp
|
|
|
|
+ br.Ret = 200
|
|
|
|
+ br.Msg = "获取成功"
|
|
|
|
+}
|