zhangchuanxing hace 4 meses
padre
commit
0d98eeb814

+ 232 - 0
controllers/report.go

@@ -2236,3 +2236,235 @@ func (this *MobileReportController) TacticsList() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 周期行业报告分类列表接口
+// @Description 周期获取行业报告分类列表接口
+// @Success 200 {object} models.TradeReportMappingResp
+// @router /zhouqi_tradeList [get]
+func (this *MobileReportController) ZouqiTradeList() {
+	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
+	}
+	listCategory, err := models.GetCygxZhouqiArticleMapFirst()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+
+	resp := new(models.TradeReportMappingResp)
+	var list []*models.TradeReportMapping
+	if len(listCategory) == 0 {
+		list = make([]*models.TradeReportMapping, 0)
+	} else {
+		for _, v := range listCategory {
+			item := new(models.TradeReportMapping)
+			item.CategoryId = v.CategoryId
+			item.MatchTypeName = v.MatchTypeName
+			item.UpdateTime = v.ArticleUpdateTime
+			item.ListArticle = make([]*models.HomeArticle, 0)
+			list = append(list, item)
+		}
+	}
+	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   CategoryId   query   int  true       "分类ID"
+// @Success 200 {object} models.TacticsListResp
+// @router /tactics/zhouqi_list [get]
+func (this *MobileReportController) ZhouqiTacticsList() {
+	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
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	categoryId, _ := this.GetInt("CategoryId")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	var total int
+	var err error
+	resp := new(models.TacticsListResp)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	list := make([]*models.ArticleListResp, 0)
+	listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
+		return
+	}
+	var matchTypeName = []string{}
+	for _, v := range listCategory {
+		matchTypeName = append(matchTypeName, v.MatchTypeName)
+	}
+
+	var condition string
+	//var pars []interface{}
+	condition = " AND field_name  IN  ('" + strings.Join(matchTypeName, "','") + "')"
+
+	list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.Msg = "GetHomeList,Err:" + err.Error()
+		return
+	}
+
+	listPublic, err := services.HandleArticleCategoryImg(list, user)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
+		return
+	}
+
+	var articleIds []int
+	var productInteriorIs []int
+
+	for _, v := range listPublic {
+		if v.Resource == 1 {
+			articleIds = append(articleIds, v.ArticleId)
+		}
+		if v.Resource == 2 {
+			productInteriorIs = append(productInteriorIs, v.ArticleId)
+		}
+	}
+
+	articleMapPv := services.GetArticleHistoryByArticleId(articleIds)                       //文章Pv
+	articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)                  //用户收藏的文章
+	articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
+
+	productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
+	listResp := make([]*models.HomeArticle, 0)
+	for _, v := range listPublic {
+		item := new(models.HomeArticle)
+		item.ArticleId = v.ArticleId
+		item.ReportId = v.ReportId
+		item.Title = v.Title
+		item.Annotation = v.Annotation
+		item.Abstract = v.Abstract
+		item.ImgUrlPc = v.ImgUrlPc
+		item.PublishDate = v.PublishDate
+		item.Resource = v.Resource
+		if v.Resource == 1 {
+			item.Pv = articleMapPv[v.ArticleId]
+			item.IsCollect = articleCollectMap[v.ArticleId]
+			item.CollectNum = articleCollectNumMap[v.ArticleId]
+		}
+		if v.Resource == 2 {
+			item.Pv = productInteriorMapPv[v.ArticleId]
+		}
+
+		if v.ReportId > 0 {
+			item.Resource = 3
+		}
+		listResp = append(listResp, item)
+	}
+	if len(listResp) == 0 {
+		listResp = make([]*models.HomeArticle, 0)
+	}
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = listResp
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 周期行业关注/取消关注
+// @Description 周期行业关注/取消关注 接口
+// @Param	request	body models.CygxCategoryFllowRep true "type json string"
+// @Success 200
+// @router /category/zhouqi_fllow [post]
+func (this *ReportController) CategoryZhouqiFllow() {
+	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
+	var req models.CygxCategoryFllowRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	categoryId := req.CategoryId
+	count, err := models.GetCountCategoryFllowZhouqi(categoryId, user.Mobile)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.CygxIndustryFllowResp)
+	if count == 0 {
+		item := new(models.CygxXzsChooseCategoryZhouqi)
+		item.CategoryId = categoryId
+		item.UserId = uid
+		item.Email = user.Email
+		item.Mobile = user.Mobile
+		item.RealName = user.RealName
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		_, err = models.AddCygxCategoryFllowZhouqi(item)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + err.Error()
+			return
+		}
+		resp.Status = 1
+		br.Msg = "关注成功"
+	} else {
+		err = models.RemoveCygxCategoryFllowZhouqi(user.Mobile, categoryId)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "取消关注失败,Err:" + err.Error()
+			return
+		}
+		resp.Status = 2
+		br.Msg = "已取消关注"
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}

+ 1 - 0
models/db.go

@@ -106,6 +106,7 @@ func init() {
 		new(CygxActivityVideoHistory),
 		new(CygxTimelineLog),
 		new(CygxActivitySpecialPermissionPoints),
+		new(CygxXzsChooseCategoryZhouqi),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 24 - 0
models/report.go

@@ -1273,3 +1273,27 @@ GROUP BY a.article_id ORDER BY publish_date DESC
 	_, err = o.Raw(sql, createtime).QueryRows(&items)
 	return
 }
+
+// 获取行业报告列表
+func GetReportAndproductIndustrylListimgZhouqi(condition string, startSize, pageSize int) (items []*ArticleListResp, total int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			art.article_id,
+			art.report_id,
+			art.body,
+			art.annotation,
+			art.abstract,
+			art.category_id,
+			art.title,
+			art.publish_date,
+			1 AS resource 
+		FROM
+			cygx_article AS art 
+		WHERE
+			art.publish_status = 1  ` + condition
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql).QueryRow(&total)
+	sql += `    ORDER BY publish_date DESC LIMIT ?,? `
+	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 56 - 0
models/xzs_choose_category_zhouqi.go

@@ -0,0 +1,56 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxXzsChooseCategoryZhouqi struct {
+	Id          int       `orm:"column(id);pk"`
+	UserId      int       `description:"用户ID"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	CategoryId  int       `description:"cygx_zhouqi_article_map 表主键"`
+	CreateTime  time.Time `description:"创建时间"`
+	ModifyTime  time.Time `description:"更新时间"`
+}
+
+// 根据手机号获取用户关注的产业
+func GetCygxXzsChooseCategoryZhouqiList(mobile string) (items []*CygxXzsChooseCategoryZhouqi, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_xzs_choose_category_zhouqi WHERE mobile = ?`
+	_, err = o.Raw(sql, mobile).QueryRows(&items)
+	return
+}
+
+// 添加
+func AddCygxCategoryFllowZhouqi(item *CygxXzsChooseCategoryZhouqi) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 删除
+func RemoveCygxCategoryFllowZhouqi(mobile string, CategoryId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_xzs_choose_category_zhouqi WHERE mobile=? AND category_id=? `
+	_, err = o.Raw(sql, mobile, CategoryId).Exec()
+	return
+}
+
+// 获取关注数量
+func GetCountCategoryFllowZhouqi(categoryId int, mobile string) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_xzs_choose_category_zhouqi WHERE mobile=? AND category_id=? `
+	err = orm.NewOrm().Raw(sql, mobile, categoryId).QueryRow(&count)
+	return
+}
+
+type XzsChooseMapZhouqiResp struct {
+	Id                  int    `description:"id"`
+	CategoryId          int    `description:"权益文章对应分类,cygx_article"`
+	CharPpermissionName string `description:"权限名称"`
+	MatchTypeName       string `description:"分类名称"`
+}

+ 44 - 0
models/zhouqi_article_map.go

@@ -0,0 +1,44 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type CygxZhouqiArticleMap struct {
+	CategoryId        int    `description:"产业Id"`
+	MatchTypeName     string `description:"行业名称"`
+	ArticleUpdateTime string `description:"对应文章的更新时间"`
+}
+
+// 获取周期下面的一级分类
+func GetCygxZhouqiArticleMapFirst() (items []*CygxZhouqiArticleMap, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			category_id,
+			match_type_name,
+			article_update_time 
+		FROM
+			cygx_zhouqi_article_map 
+		WHERE
+			hidden = 0 
+			AND parent_id = 0 
+		ORDER BY
+			sort DESC `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 根据父级分类ID获取下面的子分类
+func GetCygxZhouqiArticleMapByParentId(parentId int) (items []*CygxZhouqiArticleMap, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			category_id,
+			match_type_name,
+			article_update_time 
+		FROM
+			cygx_zhouqi_article_map 
+		WHERE
+			parent_id = ?  `
+	_, err = o.Raw(sql, parentId).QueryRows(&items)
+	return
+}

+ 27 - 0
routers/commentsRouter.go

@@ -601,6 +601,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"],
+        beego.ControllerComments{
+            Method: "ZhouqiTacticsList",
+            Router: `/tactics/zhouqi_list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"],
         beego.ControllerComments{
             Method: "Timeline",
@@ -628,6 +637,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"],
+        beego.ControllerComments{
+            Method: "ZouqiTradeList",
+            Router: `/zhouqi_tradeList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"],
         beego.ControllerComments{
             Method: "Billboard",
@@ -817,6 +835,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "CategoryZhouqiFllow",
+            Router: `/category/zhouqi_fllow`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ReportController"],
         beego.ControllerComments{
             Method: "CommentAdd",