Explorar o código

fix:超前项目推送增加开关限制

duxin hai 8 meses
pai
achega
b1a240f3f4
Modificáronse 3 ficheiros con 12 adicións e 10 borrados
  1. 4 6
      entity/mananger/customManager.go
  2. 6 3
      services/action.go
  3. 2 1
      vars/config.go

+ 4 - 6
entity/mananger/customManager.go

@@ -80,10 +80,6 @@ func (this *CustomManager) GetData(userId, keyWords string, isNew bool) map[stri
 
 // ScheduledTasks 定时任务
 func (this *CustomManager) ScheduledTasks() {
-	if !vars.Config.IsEnable {
-		log.Println("定时任务开关未开启")
-		return
-	}
 	// 定时圈用户
 	if this.Conf.UpdateCron != "" {
 		c := cron.New(cron.WithSeconds())
@@ -94,7 +90,7 @@ func (this *CustomManager) ScheduledTasks() {
 		c.Start()
 	}
 	// 查询时间段限时
-	if this.Conf.SearchLimit.Switch.Start != "" && this.Conf.SearchLimit.Switch.Stop != "" {
+	if vars.Config.Custom.IsEnable && this.Conf.SearchLimit.Switch.Start != "" && this.Conf.SearchLimit.Switch.Stop != "" {
 		//开始
 		startJob := cron.New(cron.WithSeconds())
 		if _, err := startJob.AddFunc(this.Conf.SearchLimit.Switch.Start, func() {
@@ -117,7 +113,9 @@ func (this *CustomManager) ScheduledTasks() {
 		endJob.Start()
 	}
 	// 首次运行启动查询
-	go this.DoSearch()
+	if vars.Config.Custom.IsEnable {
+		go this.DoSearch()
+	}
 	// 首次运行圈选用户
 	this.UpdateUserGroupJob()
 }

+ 6 - 3
services/action.go

@@ -28,18 +28,21 @@ func (this *LeadGeneration) GetDate() {
 		keyWords := this.GetString("keyWords")
 		t, _ := this.GetInt("dType")
 		rData := map[string]interface{}{}
-		if vars.Config.IsEnable {
-			if t != 0 || keyWords != "" {
-				//获取超前项目
+		if t != 0 || keyWords != "" {
+			//获取超前项目
+			if vars.Config.Ahead.IsEnable {
 				if aheadData := mananger.JyAheadManager.GetData(userId, keyWords, isNewUser, t); aheadData != nil && len(aheadData) > 0 {
 					rData["ahead"] = aheadData
 				}
+			}
+			if vars.Config.Custom.IsEnable {
 				//获取定制化报告数据
 				if customData := mananger.JyCustomManager.GetData(userId, keyWords, isNewUser); customData != nil && len(customData) > 0 {
 					rData["custom"] = customData
 				}
 			}
 		}
+
 		return rData, nil
 	}()
 	if errMsg != nil {

+ 2 - 1
vars/config.go

@@ -8,7 +8,6 @@ var Config *config
 
 type config struct {
 	WebPort            string       `json:"webPort"`            //服务端口
-	IsEnable           bool         `json:"isEnable"`           //开关
 	Ahead              AheadConfig  `json:"ahead"`              //超前项目配置
 	Custom             CustomConfig `json:"custom"`             //定制化报告配置
 	TestUid            []string     `json:"testUid"`            //测试用户id
@@ -17,6 +16,7 @@ type config struct {
 }
 
 type AheadConfig struct {
+	IsEnable       bool    `json:"isEnable"`       //开关
 	Prop           float64 `json:"prop"`           //新增用户百分比
 	DailyTimes     int     `json:"dailyTimes"`     //每日展示次数
 	SaveClickTimes int     `json:"saveClickTimes"` //保留用户的点击量
@@ -25,6 +25,7 @@ type AheadConfig struct {
 }
 
 type CustomConfig struct {
+	IsEnable    bool   `json:"isEnable"`   //开关
 	Open        bool   `json:"open"`       //是否运行查询
 	UpdateCron  string `json:"updateCron"` //更新周活用户
 	SearchLimit struct {