xingzai %!s(int64=2) %!d(string=hai) anos
pai
achega
00520a27d6

+ 71 - 8
controllers/chart.go

@@ -90,7 +90,7 @@ func (this *ChartController) Collection() {
 // @Title 图表详情
 // @Description 我的收藏接口
 // @Param   ChartId   query   int  true       "图表ID"
-// @Success 200 {object} models.HomeChartListItem
+// @Success 200 {object} models.CygxChartDetail
 // @router /detail [get]
 func (this *ChartController) Detail() {
 	br := new(models.BaseResponse).Init()
@@ -162,11 +162,16 @@ func (this *ChartController) ChartCollect() {
 	}
 	resp := new(models.ArticleCollectResp)
 	if count <= 0 {
-		item := new(models.CygxArticleCollect)
-		item.ArticleId = req.ChartId
+		item := new(models.CygxChartCollect)
+		item.ChartId = req.ChartId
 		item.UserId = uid
+		item.RealName = user.RealName
 		item.CreateTime = time.Now()
-		_, err = models.AddCygxArticleCollect(item)
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		_, err = models.AddCygxChartCollect(item)
 		if err != nil {
 			br.Msg = "收藏失败"
 			br.ErrMsg = "收藏失败,Err:" + err.Error()
@@ -175,7 +180,7 @@ func (this *ChartController) ChartCollect() {
 		br.Msg = "收藏成功"
 		resp.Status = 1
 	} else {
-		err = models.RemoveArticleCollect(uid, req.ChartId)
+		err = models.RemoveChartCollect(uid, req.ChartId)
 		if err != nil {
 			br.Msg = "取消收藏失败"
 			br.ErrMsg = "取消收藏失败,Err:" + err.Error()
@@ -184,13 +189,71 @@ func (this *ChartController) ChartCollect() {
 		br.Msg = "已取消收藏"
 		resp.Status = 2
 	}
-	collectTotal, err := models.GetArticleCollectUsersCount(req.ChartId)
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}
+
+// @Title 置顶、取消置顶
+// @Description  置顶、取消置顶
+// @Param	request	body models.ChartCollectReq true "type json string"
+// @Success 200 {object} models.FontsCollectResp
+// @router /top [post]
+func (this *ChartController) ChartTop() {
+	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.ChartCollectReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
 	if err != nil {
-		br.Msg = "获取数据失败"
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	count, err := models.GetChartTopCountByUserId(uid, req.ChartId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
-	resp.CollectCount = collectTotal
+	resp := new(models.ArticleCollectResp)
+	if count <= 0 {
+		item := new(models.CygxChartTop)
+		item.ChartId = req.ChartId
+		item.UserId = uid
+		item.RealName = user.RealName
+		item.CreateTime = time.Now()
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		_, err = models.AddCygxChartTop(item)
+		if err != nil {
+			br.Msg = "置顶失败"
+			br.ErrMsg = "收置顶失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "收藏成功"
+		resp.Status = 1
+	} else {
+		err = models.RemoveChartTop(uid, req.ChartId)
+		if err != nil {
+			br.Msg = "取消置顶失败"
+			br.ErrMsg = "取消置顶失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "已取消置顶"
+		resp.Status = 2
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Data = resp

+ 143 - 0
controllers/search.go

@@ -326,3 +326,146 @@ func (this *BaseSearchController) SearchListPublic() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 搜索接口
+// @Description 搜索接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Param   OrderColumn   query   int  true       "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
+// @Param   ListType   query   int  true       "列表类型,1最新,2 纪要 ,3图表 默认1"
+// @Success 200 {object} models.SearchItem
+// @router /artAndChart/list [get]
+func (this *SearchController) ListHomeArtAndChart() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	//pageSize, _ := this.GetInt("PageSize")
+	//currentIndex, _ := this.GetInt("CurrentIndex")
+	//listType, _ := this.GetInt("ListType")
+	//var startSize int
+	//if pageSize <= 0 {
+	//	pageSize = utils.PageSize20
+	//}
+	//if currentIndex <= 0 {
+	//	currentIndex = 1
+	//}
+	//startSize = paging.StartIndex(currentIndex, pageSize)
+	//keyWord := this.GetString("KeyWord")
+	//orderColumn := this.GetString("OrderColumn")
+	//if keyWord == "" {
+	//	br.Msg = "请输入搜索词"
+	//	br.ErrMsg = "请输入搜索词"
+	//	return
+	//}
+	//user := this.User
+	//if user == nil {
+	//	br.Msg = "请重新登录"
+	//	br.Ret = 408
+	//	return
+	//}
+	//
+	////研选的五张图片
+	//detailResearch, errConfig := models.GetConfigByCode("category_research_img_url")
+	//if errConfig != nil {
+	//	br.Msg = "获取数据失败"
+	//	br.ErrMsg = "获取数据研选分类图片失败,Err:" + errConfig.Error()
+	//	return
+	//}
+	//researchList := strings.Split(detailResearch.ConfigValue, "{|}")
+	////对应分类的所图片
+	//detailCategoryUrl, errConfig := models.GetConfigByCode("category_map_img_url")
+	//if errConfig != nil {
+	//	br.Msg = "获取数据失败"
+	//	br.ErrMsg = "行业配置信息失败,Err:" + errConfig.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
+	//}
+	//if orderColumn == "" {
+	//	orderColumn = "Matching"
+	//}
+	//indexName := utils.IndexName
+	//
+	//var total, chartTotal int
+	//resp := new(models.HomeArtAndChartListResp)
+	//page := paging.GetPaging(currentIndex, pageSize, total)
+	//resp.HaveResearch = true
+	//var chartList []*models.HomeChartListResp
+	//var err error
+	//if listType == 1 {
+	//	if currentIndex <= 2 {
+	//		chartList, err = models.GetChartList(condition, pars, startSize, pageSize)
+	//		if err != nil {
+	//			br.Msg = "获取信息失败"
+	//			br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+	//			return
+	//		}
+	//	}
+	//}
+
+	//var result []*models.SearchItem
+	//var total int64
+	//var err error
+	//if orderColumn == "PublishDate" {
+	//	tmpResult, tmpTotal, tmpErr := services.EsMultiMatchFunctionScoreQueryTimeSort(indexName, keyWord, startSize, 100, user.UserId)
+	//	result = tmpResult
+	//	total = tmpTotal
+	//	err = tmpErr
+	//} else {
+	//	tmpResult, tmpTotal, tmpErr := services.EsMultiMatchFunctionScoreQuerySort(indexName, keyWord, startSize, pageSize, user.UserId, orderColumn)
+	//	result = tmpResult
+	//	total = tmpTotal
+	//	err = tmpErr
+	//}
+	//if err != nil {
+	//	br.Msg = "检索失败"
+	//	br.ErrMsg = "检索失败,Err:" + err.Error()
+	//	return
+	//}
+	//if len(result) == 0 {
+	//	result = make([]*models.SearchItem, 0)
+	//}
+	//detail, errKey := models.GetNewSearchKeyWordByThisUser(user.UserId, keyWord)
+	//if errKey != nil && errKey.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取信息失败,Err:" + errKey.Error()
+	//	return
+	//}
+	////同一个用户一分钟之内搜索的词不重复记录
+	//if detail == nil || time.Now().After(detail.CreateTime.Add(+time.Minute*1)) {
+	//	//fmt.Println("一分钟之内没有搜索")
+	//	keyWordItem := new(models.CygxSearchKeyWord)
+	//	keyWordItem.UserId = user.UserId
+	//	keyWordItem.KeyWord = keyWord
+	//	keyWordItem.CreateTime = time.Now()
+	//	go models.AddSearchKeyWord(keyWordItem)
+	//}
+	//for k, v := range result {
+	//	//如果是研选系列的任意取五张图片的中的一张
+	//	if v.CategoryId == "0" {
+	//		knum := v.ArticleId % 5
+	//		result[k].ImgUrlPc = researchList[knum]
+	//	} else {
+	//		result[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+	//	}
+	//}
+	////resp := new(models.SearchResp)
+	////page := paging.GetPaging(currentIndex, pageSize, int(total))
+	////resp.Paging = page
+	////resp.List = result
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	//br.Data = resp
+}

+ 1 - 1
models/activity.go

@@ -189,7 +189,7 @@ func GetActivityListAll(condition string, pars []interface{}, uid, startSize, pa
 //列表
 func GetActivityListByDateTime(startDate, endDate string) (items []*CygxActivityList, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_activity WHERE activity_time > '` + startDate + `' AND activity_time < '` + endDate + `' `
+	sql := `SELECT * FROM cygx_activity WHERE  activity_time > '` + startDate + `' AND activity_time < '` + endDate + `' `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 1 - 7
models/chart.go

@@ -182,7 +182,7 @@ func GetChartCount(condition string, pars []interface{}) (count int, err error)
 
 func GetChartDetailById(chartId, uid int) (item *CygxChartDetail, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * ,( SELECT COUNT( 1 ) FROM cygx_chart_collent AS c WHERE c.chart_id = a.chart_id AND c.user_id = ? ) AS collection_num
+	sql := `SELECT * ,( SELECT COUNT( 1 ) FROM cygx_chart_collect AS c WHERE c.chart_id = a.chart_id AND c.user_id = ? ) AS collection_num
 		FROM
 			cygx_chart  as a 
 		WHERE
@@ -190,9 +190,3 @@ func GetChartDetailById(chartId, uid int) (item *CygxChartDetail, err error) {
 	err = o.Raw(sql, uid, chartId).QueryRow(&item)
 	return
 }
-
-func GetChartCountByUserId(userId, articleId int) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM cygx_chart_collent WHERE user_id=? AND chart_id=? `
-	err = orm.NewOrm().Raw(sql, userId, articleId).QueryRow(&count)
-	return
-}

+ 47 - 25
models/chart_collect.go

@@ -6,10 +6,16 @@ import (
 )
 
 type CygxChartCollect struct {
-	Id         int `orm:"column(id);pk"`
-	ChartId    int
-	UserId     int
-	CreateTime time.Time
+	Id          int       `orm:"column(id);pk"`
+	ChartId     int       `description:"图表ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName  string    `description:"所属销售"`
 }
 
 //添加收藏信息
@@ -26,35 +32,51 @@ type ChartCollectResp struct {
 
 func RemoveChartCollect(userId, ChartId int) (err error) {
 	o := orm.NewOrm()
-	sql := `DELETE FROM cygx_Chart_collect WHERE user_id=? AND Chart_id=? `
+	sql := `DELETE FROM cygx_chart_collect WHERE user_id=? AND chart_id=? `
 	_, err = o.Raw(sql, userId, ChartId).Exec()
 	return
 }
 
-func GetChartCollectUsersCount(ChartId int) (count int, err error) {
-	sql := `SELECT COUNT(user_id) AS count FROM cygx_Chart_collect WHERE Chart_id=? `
-	err = orm.NewOrm().Raw(sql, ChartId).QueryRow(&count)
+func GetChartCountByUserId(userId, chartID int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_chart_collect WHERE user_id=? AND chart_id=? `
+	err = orm.NewOrm().Raw(sql, userId, chartID).QueryRow(&count)
 	return
 }
 
-func GetChartCollectCount(userId, ChartId int) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM cygx_Chart_collect WHERE user_id=? AND Chart_id=? `
-	err = orm.NewOrm().Raw(sql, userId, ChartId).QueryRow(&count)
+type CygxChartTop struct {
+	Id          int       `orm:"column(id);pk"`
+	ChartId     int       `description:"图表ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName  string    `description:"所属销售"`
+}
+
+//添加置顶信息
+func AddCygxChartTop(item *CygxChartTop) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type ChartTopresp struct {
+	Status       int `description:"1:收藏,2:取消收藏"`
+	CollectCount int `description:"收藏总数"`
+}
+
+func RemoveChartTop(userId, ChartId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_chart_top WHERE user_id=? AND chart_id=? `
+	_, err = o.Raw(sql, userId, ChartId).Exec()
 	return
 }
 
-type ChartCollectList struct {
-	Id              int `orm:"column(id);pk"`
-	ChartId         int
-	UserId          int
-	CreateTime      time.Time
-	Title           string `description:"标题"`
-	TitleEn         string `description:"英文标题 "`
-	UpdateFrequency string `description:"更新周期"`
-	CreateDate      string `description:"创建时间"`
-	PublishDate     string `description:"发布时间"`
-	Body            string `description:"内容"`
-	Abstract        string `description:"摘要"`
-	CategoryName    string `description:"一级分类"`
-	SubCategoryName string `description:"二级分类"`
+func GetChartTopCountByUserId(userId, chartID int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_chart_top WHERE user_id=? AND chart_id=? `
+	err = orm.NewOrm().Raw(sql, userId, chartID).QueryRow(&count)
+	return
 }

+ 2 - 0
models/db.go

@@ -100,6 +100,8 @@ func init() {
 		new(CygxActivitySpecialSignup),
 		new(CygxUserFollowSpecial),
 		new(CygxChart),
+		new(CygxChartCollect),
+		new(CygxChartTop),
 	)
 	// 记录ORM查询日志
 	//orm.Debug = true

+ 18 - 0
routers/commentsRouter_controllers.go

@@ -367,6 +367,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartController"],
+        beego.ControllerComments{
+            Method: "ChartTop",
+            Router: "/top",
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartPermissionAuthController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartPermissionAuthController"],
         beego.ControllerComments{
             Method: "Detail",
@@ -727,6 +736,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"],
+        beego.ControllerComments{
+            Method: "ListHomeArtAndChart",
+            Router: "/artAndChart/list",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"],
         beego.ControllerComments{
             Method: "SearchList",

+ 3 - 2
services/task.go

@@ -39,6 +39,9 @@ func Task() {
 
 		dotongbuShangHaiSendEmail := task.NewTask("dotongbuShangHaiSendEmail", "0 00 4 * * *", DotongbuShangHaiSendEmail) //发送上海策略品台同步结果名单的邮件附件
 		task.AddTask("发送上海策略品台同步结果名单的邮件附件", dotongbuShangHaiSendEmail)
+
+		getChartListByApi := task.NewTask("getChartListByApi", "0 */30 * * * *", GetChartListByApi) //同步图表
+		task.AddTask("getChartListByApi", getChartListByApi)
 	}
 
 	if utils.IsTask {
@@ -62,8 +65,6 @@ func Task() {
 		sendEmailFileForAskMsg := task.NewTask("sendEmailFileForAskMsg", "0 */5 8-22 * * *", SendEmailFileForAskMsg) //非研选系列专家电话会,根据主持人姓名,会前15分钟将问题列表发送给至该主持人对应邮箱
 		task.AddTask("sendEmailFileForAskMsg", sendEmailFileForAskMsg)
 
-		getChartListByApi := task.NewTask("getChartListByApi", "0 */30 * * * *", GetChartListByApi) //同步纪要库内容到Es
-		task.AddTask("getChartListByApi", getChartListByApi)
 	}
 
 	//ActivityAttendanceDetail()