|
@@ -97,7 +97,13 @@ func (this *MobileReportController) TradeList() {
|
|
|
var pars []interface{}
|
|
|
condition = " AND a.category_id_two = " + strconv.Itoa(v.CategoryId)
|
|
|
if ChartPermissionId != utils.CE_LUE_ID {
|
|
|
- listArticle, err := models.GetHomeList(condition, pars, 0, 6)
|
|
|
+ var pageSize int
|
|
|
+ if ChartPermissionId == utils.KE_JI_ID {
|
|
|
+ pageSize = 12
|
|
|
+ } else {
|
|
|
+ pageSize = 6
|
|
|
+ }
|
|
|
+ listArticle, err := models.GetHomeList(condition, pars, 0, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.Msg = "GetHomeList,Err:" + err.Error()
|
|
@@ -577,3 +583,204 @@ func (this *ReportController) CategoryFllow() {
|
|
|
br.Success = true
|
|
|
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.ReoprtSearchResp
|
|
|
+// @router /searchReport [get]
|
|
|
+func (this *MobileReportController) SearchReport() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
+ br.Msg = "请重新登录"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
+ var condition string
|
|
|
+ var conditionSql string
|
|
|
+ //var sqlGroup string
|
|
|
+ var total int
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = paging.StartIndex(currentIndex, pageSize)
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ //匹配报告标题、
|
|
|
+ condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
|
|
|
+
|
|
|
+ conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
|
|
|
+ total, err := models.GetReoprtSearchCount(conditionSql)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.Msg = "获取总数失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //listHz, err := models.GetReoprtSearchList(` AND a.article_id < `+strconv.Itoa(utils.SummaryArticleId)+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId, startSize, pageSize)
|
|
|
+ listHz, err := models.GetReoprtSearchList(conditionSql, user.UserId, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for k, _ := range listHz {
|
|
|
+ listHz[k].Source = 1
|
|
|
+ }
|
|
|
+ var articleIds string
|
|
|
+ for _, v := range listHz {
|
|
|
+ articleIds += strconv.Itoa(v.ArticleId) + ","
|
|
|
+ }
|
|
|
+ articleIds = strings.TrimRight(articleIds, ",")
|
|
|
+ silcearticleIds := strings.Split(articleIds, ",")
|
|
|
+ //获取文章关联的产业
|
|
|
+ var pars []interface{}
|
|
|
+ pars = make([]interface{}, 0)
|
|
|
+ articleIdList := make([]string, 0)
|
|
|
+ for _, v := range silcearticleIds {
|
|
|
+ articleIdList = append(articleIdList, v)
|
|
|
+ }
|
|
|
+ condition = ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
|
|
|
+ pars = append(pars, articleIdList)
|
|
|
+ industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ industrialMap := make(map[int][]*models.IndustrialManagementResp)
|
|
|
+ if len(industrialList) > 0 {
|
|
|
+ for _, v := range industrialList {
|
|
|
+ item := new(models.IndustrialManagementResp)
|
|
|
+ //item.ArticleId = v.ArticleId
|
|
|
+ item.IndustrialManagementId = v.IndustrialManagementId
|
|
|
+ item.IndustryName = v.IndustryName
|
|
|
+ industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for k, v := range listHz {
|
|
|
+ if len(industrialMap[v.ArticleId]) > 0 {
|
|
|
+ listHz[k].List = industrialMap[v.ArticleId]
|
|
|
+ } else {
|
|
|
+ listHz[k].List = make([]*models.IndustrialManagementResp, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if keyWord != "" {
|
|
|
+ go services.AddUserSearchLog(user, keyWord, 5)
|
|
|
+ }
|
|
|
+ if len(listHz) == 0 {
|
|
|
+ listHz = make([]*models.ArticleCollectionResp, 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ page = paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp := new(models.ReoprtSearchResp)
|
|
|
+ resp.Paging = page
|
|
|
+ resp.ListHz = listHz
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 资源包搜索
|
|
|
+// @Description 资源包搜索接口
|
|
|
+// @Param KeyWord query string true "搜索关键词"
|
|
|
+// @Success 200 {object} models.SearchResourceResp
|
|
|
+// @router /searchResource [get]
|
|
|
+func (this *MobileReportController) SearchResource() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
+ br.Msg = "请重新登录"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
+ fllowList, err := models.GetUserFllowIndustrialList(uid)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fllowMap := make(map[int]int)
|
|
|
+ if len(fllowList) > 0 {
|
|
|
+ for _, v := range fllowList {
|
|
|
+ fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
+ var condition string
|
|
|
+ var conditionOr string
|
|
|
+ conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
|
|
|
+ condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
|
|
|
+
|
|
|
+ listHz, err := models.GetSearchResourceList(condition)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //合并产业关联的标的
|
|
|
+ listSubjcet, err := models.GetThemeHeatSubjectList("")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ industrialIdArr := make([]int, 0)
|
|
|
+ for k, v := range listHz {
|
|
|
+ listHz[k].Source = 1
|
|
|
+ if fllowMap[v.IndustrialManagementId] > 0 {
|
|
|
+ listHz[k].IsFollow = true
|
|
|
+ }
|
|
|
+ industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(industrialIdArr) > 0 {
|
|
|
+ //合并产业关联的标的
|
|
|
+ listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mapIndustrial := make(map[string]int)
|
|
|
+ for _, v := range listSubjcet {
|
|
|
+ for k2, v2 := range listHz {
|
|
|
+ if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
|
|
|
+ listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
|
|
|
+ mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if keyWord != "" {
|
|
|
+ go services.AddUserSearchLog(user, keyWord, 4)
|
|
|
+ }
|
|
|
+ resp := new(models.SearchResourceResp)
|
|
|
+ if len(listHz) == 0 {
|
|
|
+ listHz = make([]*models.IndustrialManagement, 0)
|
|
|
+ }
|
|
|
+ resp.ListHz = listHz
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|