xingzai 2 anos atrás
pai
commit
92a6f728fc
3 arquivos alterados com 43 adições e 2 exclusões
  1. 38 0
      services/elastic.go
  2. 2 2
      services/task.go
  3. 3 0
      utils/config.go

+ 38 - 0
services/elastic.go

@@ -34,6 +34,44 @@ func NewClient() (client *elastic.Client, err error) {
 	return
 }
 
+//创建文章阅读记录的Es索引
+func CreateIndexNameArticleHistory() {
+	indexName := utils.IndexNameArticleHistory
+	mappingJson := `{
+ "mappings": {
+   "dynamic": true,
+   "properties": {
+     "ArticleId": {
+       "type": "short"
+     },
+	 "CompanyName": {
+		"type": "keyword"
+	 },
+     "Mobile": {
+		"type": "keyword"
+	 },
+     "Email": {
+		"type": "keyword"
+	 },
+	"Title": {
+       "type": "keyword"
+     },
+     "CreateTime":{
+        "type": "date",
+        "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
+      },
+     "PermissionName": {
+       "type": "keyword"
+     },
+     "StopTime": {
+       "type": "short"
+     }
+   }
+ }
+}`
+	EsCreateIndex(indexName, mappingJson)
+}
+
 //indexName:索引名称
 //mappingJson:表结构
 func EsCreateIndex(indexName, mappingJson string) (err error) {

+ 2 - 2
services/task.go

@@ -76,14 +76,14 @@ func Task() {
 		getArticleListByApi := task.NewTask("getArticleListByApi", "0 */60 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章
 		task.AddTask("getArticleListByApi", getArticleListByApi)
 	}
-
+	CreateIndexNameArticleHistory()
 	//DoCompany()
 	//ActivityAttendanceDetail()
 	//SynchronizationArthistory()//同步原有的阅读记录
 	//GetAddpArticle() //同步日度点评数据
 	//SendEmailAllUserWithRAI()     //发送当前所有权益用户到沈大爷的邮箱
 	//SendEmailAllUserWithCompany() //发送这些公司下的用户到沈大爷的邮箱
-	task.StartTask()
+	//task.StartTask()
 	//StatisticalReport()//导出报表
 	fmt.Println("end")
 }

+ 3 - 0
utils/config.go

@@ -54,6 +54,7 @@ var (
 
 var (
 	IndexName                 string
+	IndexNameArticleHistory   string //文章阅读记录Es索引
 	OnlineTime                string
 	SummaryArticleId          int
 	YanxSummaryPermissionId   int    //研选纪要分类ID
@@ -134,6 +135,7 @@ func init() {
 		WxPublicAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
 		WxPublicId = "gh_b67e0049fb8c"
 		IndexName = "cygx_article_v0622"
+		IndexNameArticleHistory = "cygx_article_history_v07_08"
 
 		//接收附件邮箱
 		EmailTechnology = "mlluo@hzinsights.com;jxu@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jhwang@hzinsights.com"    //科技行业专家邮箱
@@ -166,6 +168,7 @@ func init() {
 		WxPublicAppSecret = "f4d52e34021eee262dce9682b31f8861"
 		WxPublicId = "gh_5dc508325c6f"
 		IndexName = "cygx_article_v1"
+		IndexNameArticleHistory = "cygx_article_history_v1"
 
 		//接收附件邮箱
 		EmailTechnology = "jhwang@hzinsights.com;cxzhang@hzinsights.com"  //科技行业专家邮箱