瀏覽代碼

4.0研选社区初步完成

xingzai 2 年之前
父節點
當前提交
ac33455ef3

+ 164 - 121
controllers/report.go

@@ -797,6 +797,7 @@ func (this *ReportController) CategoryFllow() {
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   KeyWord   query   string  true       "搜索关键词"
+// @Param   ArticleType   query   int  true       "文章类型,1弘则报告、2研选 "
 // @Success 200 {object} models.ReoprtSearchResp
 // @router /searchReport [get]
 func (this *MobileReportController) SearchReport() {
@@ -813,10 +814,11 @@ func (this *MobileReportController) SearchReport() {
 	}
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
+	articleType, _ := this.GetInt("ArticleType", 1)
 	keyWord := this.GetString("KeyWord")
 	var condition string
-	var conditionSql string
-	//var sqlGroup string
+	var pars []interface{}
+	//var conditionSql string
 	var total int
 	var startSize int
 	if pageSize <= 0 {
@@ -826,105 +828,164 @@ func (this *MobileReportController) SearchReport() {
 		currentIndex = 1
 	}
 	startSize = paging.StartIndex(currentIndex, pageSize)
-	page := paging.GetPaging(currentIndex, pageSize, total)
+
 	resp := new(models.ReoprtSearchResp)
 	//匹配报告标题、
-	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)
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
 	if err != nil {
 		br.Msg = "获取信息失败"
-		br.Msg = "获取总数失败,Err:" + err.Error()
+		br.ErrMsg = "GetYanXuanArticleTypeIds,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 {
+	if articleTypeIds == "" {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
+		br.ErrMsg = "研选分类ID不能为空"
 		return
 	}
-	for k, _ := range listHz {
-		listHz[k].Source = 1
-	}
-	var articleIds string
-	for _, v := range listHz {
-		articleIds += strconv.Itoa(v.ArticleId) + ","
+	//condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
+	if articleType == 1 {
+		condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id NOT IN (` + articleTypeIds + `)  `
+		total, err = models.GetReoprtSearchCountHz(condition)
+	} else {
+		condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id  IN (` + articleTypeIds + `)  `
+		total, err = models.GetReoprtSearchCountYx(condition)
 	}
-	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()
+		br.Msg = "获取信息失败"
+		br.Msg = "获取总数失败,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
-			item.ChartPermissionId = v.ChartPermissionId
-			industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
-		}
+	var list []*models.ArticleListResp
+	//list := new([]models.ArticleResearchResp)
+	if articleType == 1 {
+		list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
+	} else {
+		list, err = models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
 	}
-
-	detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
 	if err != nil {
-		br.Msg = "获取数据失败"
-		br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
-	mapCategoryUrl := make(map[string]string)
-	var categoryId string
-	var imgUrlChart string
-	for _, v := range categoryUrlList {
-		vslice := strings.Split(v, "_")
-		categoryId = vslice[0]
-		imgUrlChart = vslice[len(vslice)-1]
-		mapCategoryUrl[categoryId] = imgUrlChart
+	//return
+	list, err = services.HandleArticleCategoryImg(list)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
+		return
 	}
-
-	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)
+	//处理对应的文章类型标签按钮
+	nameMap, styleMap, err := services.GetArticleTypeMap()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
+		return
+	}
+	for _, v := range list {
+		item := models.ArticleResearchResp{
+			ArticleId:       v.ArticleId,
+			ArticleTypeId:   v.ArticleTypeId,
+			Title:           v.Title,
+			PublishDate:     v.PublishDate,
+			DepartmentId:    v.DepartmentId,
+			NickName:        v.NickName,
+			IsCollect:       v.IsCollect,
+			Pv:              v.Pv,
+			CollectNum:      v.CollectNum,
+			Abstract:        v.Abstract,
+			Annotation:      v.Annotation,
+			ImgUrlPc:        v.ImgUrlPc,
+			ArticleTypeName: nameMap[v.ArticleTypeId],
+			ButtonStyle:     styleMap[v.ArticleTypeId],
+			List:            v.List,
 		}
-		listHz[k].Body = ""
-		listHz[k].Abstract, _ = services.GetReportContentTextSub(v.Abstract)
-		listHz[k].Annotation, _ = services.GetReportContentTextSub(v.Annotation)
-		//行业比较研究、资金流向,显示报告的摘要
-		if listHz[k].CategoryName == "行业比较研究" || listHz[k].CategoryName == "资金流向" {
-			listHz[k].Annotation = listHz[k].Abstract
+		if articleType == 1 {
+			resp.ListHz = append(resp.ListHz, &item)
+		} else {
+			resp.ListYx = append(resp.ListYx, &item)
 		}
-		listHz[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+
 	}
+	//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
+	//		item.ChartPermissionId = v.ChartPermissionId
+	//		industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
+	//	}
+	//}
+	//
+	//detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
+	//if err != nil {
+	//	br.Msg = "获取数据失败"
+	//	br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
+	//	return
+	//}
+	//categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
+	//mapCategoryUrl := make(map[string]string)
+	//var categoryId string
+	//var imgUrlChart string
+	//for _, v := range categoryUrlList {
+	//	vslice := strings.Split(v, "_")
+	//	categoryId = vslice[0]
+	//	imgUrlChart = vslice[len(vslice)-1]
+	//	mapCategoryUrl[categoryId] = imgUrlChart
+	//}
+	//
+	//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)
+	//	}
+	//	listHz[k].Body = ""
+	//	listHz[k].Abstract, _ = services.GetReportContentTextSub(v.Abstract)
+	//	listHz[k].Annotation, _ = services.GetReportContentTextSub(v.Annotation)
+	//	//行业比较研究、资金流向,显示报告的摘要
+	//	if listHz[k].CategoryName == "行业比较研究" || listHz[k].CategoryName == "资金流向" {
+	//		listHz[k].Annotation = listHz[k].Abstract
+	//	}
+	//	listHz[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+	//}
 
 	if keyWord != "" {
 		go services.AddUserSearchLog(user, keyWord, 5)
 	}
-	if len(listHz) == 0 {
-		listHz = make([]*models.ArticleCollectionResp, 0)
+	if len(resp.ListHz) == 0 {
+		resp.ListHz = make([]*models.ArticleResearchResp, 0)
 	}
-
-	page = paging.GetPaging(currentIndex, pageSize, total)
-
+	if len(resp.ListYx) == 0 {
+		resp.ListYx = make([]*models.ArticleResearchResp, 0)
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp.Paging = page
-	resp.ListHz = listHz
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
@@ -963,69 +1024,47 @@ func (this *MobileReportController) SearchResource() {
 	}
 	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)
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
 	if err != nil {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
 		return
 	}
-	//合并产业关联的标的
-	listSubjcet, err := models.GetThemeHeatSubjectList("")
-	if err != nil {
+	if articleTypeIds == "" {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
+		br.ErrMsg = "研选分类ID不能为空"
 		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
-				}
-			}
-		}
+	condition = `  AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `)  AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%'  )  `
+	listHz, err := models.GetSearchResourceList(condition)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
 	}
 
-	mapUPdateTime := make(map[int]string)
-	articleIdArr := make([]int, 0)
-	//获取这些产业下最新更新的文章
-	fmt.Println(industrialIdArr)
-	listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdArr)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	condition = `  AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `)  AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%'  )  `
+	listYx, err := models.GetSearchResourceList(condition)
+	if err != nil {
 		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取信息失败 GetNewArticleDetailByIndustrialIds ,Err:" + err.Error()
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	for _, v := range listUpdateTime {
-		mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
-		articleIdArr = append(articleIdArr, v.ArticleId)
+
+	listYx, err = services.HandleIndustryList(listYx, user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
 	}
-	for k, v := range listHz {
-		listHz[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
+	listHz, err = services.HandleIndustryList(listHz, user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
 	}
-
 	if keyWord != "" {
 		go services.AddUserSearchLog(user, keyWord, 4)
 	}
@@ -1033,7 +1072,11 @@ func (this *MobileReportController) SearchResource() {
 	if len(listHz) == 0 {
 		listHz = make([]*models.IndustrialManagement, 0)
 	}
+	if len(listYx) == 0 {
+		listYx = make([]*models.IndustrialManagement, 0)
+	}
 	resp.ListHz = listHz
+	resp.ListYx = listYx
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 98 - 0
controllers/research.go

@@ -1,6 +1,7 @@
 package controllers
 
 import (
+	"encoding/json"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/services"
@@ -588,3 +589,100 @@ func (this *MobileResearchController) DepartmentIdDetail() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 关注作者/取消关注作者
+// @Description 关注作者/取消关注作者 接口
+// @Param	request	body models.CygxArticleDepartmentId true "type json string"
+// @Success 200
+// @router /fllowDepartment [post]
+func (this *MobileResearchController) FllowDepartment() {
+	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.CygxArticleDepartmentId
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	departmentId := req.DepartmentId
+	var condition string
+	countDepartment, err := models.GetDepartmentCount(departmentId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	if countDepartment == 0 {
+		br.Msg = "作者不存在!"
+		br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
+		return
+	}
+	countUser, err := models.GetArticleDepartmentFollowByUid(uid)
+	count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.CygxArticleDepartmentFollowResp)
+	if countUser == 0 {
+		resp.GoFollow = true
+	}
+	if count == 0 {
+		item := new(models.CygxArticleDepartmentFollow)
+		item.DepartmentId = departmentId
+		item.UserId = uid
+		item.Email = user.Email
+		item.Mobile = user.Mobile
+		item.RealName = user.RealName
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.Type = 1
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		_, err = models.AddArticleDepartmentFollow(item)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + err.Error()
+			return
+		}
+		resp.Status = 1
+	} else {
+		var doType int
+		condition = ` AND type = 1`
+		count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
+		if err != nil {
+			br.Msg = "操作失败!"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		if count == 1 {
+			resp.Status = 2
+			doType = 2
+		} else {
+			resp.Status = 1
+			doType = 1
+		}
+		err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "取消关注失败,Err:" + err.Error()
+			return
+		}
+	}
+	br.Msg = "操作成功"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}

+ 8 - 0
models/article_department.go

@@ -36,6 +36,14 @@ type CygxArticleDepartmentId struct {
 	DepartmentId int `description:"作者ID"`
 }
 
+// 获取作者数量
+func GetDepartmentCount(departmentId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_department WHERE department_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, departmentId).QueryRow(&count)
+	return
+}
+
 func GetArticleDepartmentDateilById(departmentId int) (item *DepartmentResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_article_department WHERE department_id = ? `

+ 80 - 0
models/article_department_follow.go

@@ -0,0 +1,80 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxArticleDepartmentFollow struct {
+	Id           int       `orm:"column(id);pk"`
+	DepartmentId int       `description:"作者ID"`
+	UserId       int       `description:"用户ID"`
+	Mobile       string    `description:"手机号"`
+	Email        string    `description:"邮箱"`
+	CompanyId    int       `description:"公司id"`
+	CompanyName  string    `description:"公司名称"`
+	Type         int       `description:"操作方式,1报名,2取消报名"`
+	CreateTime   time.Time `description:"创建时间"`
+	ModifyTime   time.Time `description:"更新时间"`
+	RealName     string    `description:"用户实际名称"`
+}
+
+type ArticleDepartmentIdRep struct {
+	DepartmentId int `description:"作者ID"`
+}
+
+// 添加
+func AddArticleDepartmentFollow(item *CygxArticleDepartmentFollow) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type CygxArticleDepartmentFollowResp struct {
+	Status   int  `description:"1:关注,2:取消关注"`
+	GoFollow bool `description:"是否去关注"`
+}
+
+func RemoveArticleDepartmentFollow(userId, industrialManagementId, doType int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_article_department_follow WHERE user_id=? AND department_id=? `
+	_, err = o.Raw(sql, userId, industrialManagementId).Exec()
+	return
+}
+
+// 获取数量
+func GetArticleDepartmentFollow(userId, departmentId int, condition string) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_department_follow WHERE user_id=? AND department_id=? ` + condition
+	err = orm.NewOrm().Raw(sql, userId, departmentId).QueryRow(&count)
+	return
+}
+
+// 获取数量
+func GetArticleDepartmentFollowByUid(userId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_department_follow WHERE user_id=? `
+	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
+	return
+}
+
+// 获取列表信息根据手机号分组
+func GetArticleDepartmentFollowByMobileList(condition string) (items []*CygxArticleDepartmentFollow, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_department_follow  WHERE 1 =1  ` + condition + `  GROUP BY user_id  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 修改用户关注作者的相关信息
+func UpdateCygxArticleDepartmentFollow(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	var sql string
+	if wxUser.Mobile != "" {
+		sql = `UPDATE cygx_article_department_follow SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
+		_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
+	} else if wxUser.Email != "" {
+		sql = `UPDATE cygx_article_department_follow SET mobile=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE email=? `
+		_, err = o.Raw(sql, wxUser.Mobile, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Email).Exec()
+	}
+
+	return
+}

+ 1 - 0
models/db.go

@@ -55,6 +55,7 @@ func init() {
 		new(UserTemplateRecord),
 		new(CygxAdvice),
 		new(CygxPageHistoryRecord),
+		new(CygxArticleDepartmentFollow),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 0 - 2
models/industrial_management.go

@@ -187,8 +187,6 @@ func GetNewArticleDetailByIndustrialIds(industrialIdArr []int) (items []*Industr
 			INNER JOIN cygx_article AS a ON mg.article_id = a.article_id 
 		WHERE
 			1 = 1
-			AND a.is_report = 1
-			AND a.is_class = 1
 			AND mg.industrial_management_id IN(` + utils.GetOrmInReplace(len(industrialIdArr)) + `)   
 		GROUP BY
 			mg.industrial_management_id `

+ 67 - 1
models/report.go

@@ -54,12 +54,14 @@ type TacticsListResp struct {
 // 报告搜索start
 type ReoprtSearchResp struct {
 	Paging *paging.PagingItem
-	ListHz []*ArticleCollectionResp `description:"弘则报告"`
+	ListHz []*ArticleResearchResp `description:"弘则报告"`
+	ListYx []*ArticleResearchResp `description:"研选报告"`
 }
 
 // 搜索资源包 start
 type SearchResourceResp struct {
 	ListHz []*IndustrialManagement `description:"弘则"`
+	ListYx []*IndustrialManagement `description:"研选"`
 }
 
 //用户收藏榜start
@@ -93,6 +95,41 @@ func GetReoprtSearchCount(condition string) (count int, err error) {
 	return
 }
 
+func GetReoprtSearchCountYx(condition string) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS count 
+		FROM
+			cygx_article AS a 
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
+			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id 
+		WHERE
+			1 = 1`
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}
+
+func GetReoprtSearchCountHz(condition string) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS count 
+		FROM
+			cygx_article AS a 
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
+		WHERE
+			1 = 1`
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}
+
 // 列表
 func GetReoprtSearchList(condition string, userId, startSize, pageSize int) (items []*ArticleCollectionResp, err error) {
 	o := orm.NewOrm()
@@ -483,6 +520,35 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 	return
 }
 
+func GetArticleResearchListHz(condition string, pars []interface{}, startSize, pageSize, userId int) (items []*ArticleListResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			a.article_id,
+			a.title,
+			a.body,
+			a.annotation,
+			a.abstract,
+			a.publish_date,
+			a.category_id,
+			a.article_type_id,
+			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id  ) AS collect_num, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collect_num_order, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id  AND user_id = ? ) AS my_collect_num
+		FROM
+			cygx_article AS a
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
+		WHERE
+			1 = 1  AND a.publish_status = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY a.article_id ORDER  BY   a.publish_date DESC  LIMIT ?,? `
+	_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 type IndustrialManagementHotListResp struct {
 	Paging *paging.PagingItem `description:"分页数据"`
 	List   []*IndustrialManagementHotResp

+ 9 - 0
routers/commentsRouter.go

@@ -412,6 +412,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"],
+        beego.ControllerComments{
+            Method: "FllowDepartment",
+            Router: `/fllowDepartment`,
+            AllowHTTPMethods: []string{"post"},
+            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: "HotList",