wangchuanjin hai 1 ano
pai
achega
3e69d1f142
Modificáronse 1 ficheiros con 54 adicións e 45 borrados
  1. 54 45
      p/struct.go

+ 54 - 45
p/struct.go

@@ -104,69 +104,78 @@ type PushSet struct {
 }
 
 func (p *PushSet) Reset() {
-	if p.SubSet == nil {
-		return
-	}
 	//
-	if p.SubSet.RateMode < 1 || p.SubSet.RateMode > 4 {
-		p.SubSet.RateMode = 2
-		if len(p.SubSet.Times) == 0 {
-			p.SubSet.Times = append(p.SubSet.Times, "09:00", "14:00")
+	if p.SubSet != nil {
+		if p.SubSet.RateMode < 1 || p.SubSet.RateMode > 4 {
+			p.SubSet.RateMode = 2
+			if len(p.SubSet.Times) == 0 {
+				p.SubSet.Times = append(p.SubSet.Times, "09:00", "14:00")
+			}
+		} else if p.SubSet.RateMode == 2 && len(p.SubSet.Times) == 0 {
+			p.SubSet.Times = append(p.SubSet.Times, "09:00")
 		}
-	} else if p.SubSet.RateMode == 2 && len(p.SubSet.Times) == 0 {
-		p.SubSet.Times = append(p.SubSet.Times, "09:00")
+		sort.Strings(p.SubSet.Times)
 	}
-	sort.Strings(p.SubSet.Times)
 	//
-	if p.EntInfo.RateMode < 1 || p.EntInfo.RateMode > 4 {
-		p.EntInfo.RateMode = 1
-		if len(p.EntInfo.Times) == 0 {
-			p.EntInfo.Times = append(p.EntInfo.Times, "09:00", "14:00")
+	if p.EntInfo != nil {
+		if p.EntInfo.RateMode < 1 || p.EntInfo.RateMode > 4 {
+			p.EntInfo.RateMode = 1
+			if len(p.EntInfo.Times) == 0 {
+				p.EntInfo.Times = append(p.EntInfo.Times, "09:00", "14:00")
+			}
+		} else if p.EntInfo.RateMode == 2 && len(p.EntInfo.Times) == 0 {
+			p.EntInfo.Times = append(p.EntInfo.Times, "09:00")
 		}
-	} else if p.EntInfo.RateMode == 2 && len(p.EntInfo.Times) == 0 {
-		p.EntInfo.Times = append(p.EntInfo.Times, "09:00")
+		sort.Strings(p.EntInfo.Times)
 	}
-	sort.Strings(p.EntInfo.Times)
 	//
-	if p.NewprojectForecast.RateMode < 1 || p.NewprojectForecast.RateMode > 4 {
-		p.NewprojectForecast.RateMode = 1
-		if len(p.NewprojectForecast.Times) == 0 {
-			p.NewprojectForecast.Times = append(p.NewprojectForecast.Times, "09:00", "14:00")
+	if p.NewprojectForecast != nil {
+		if p.NewprojectForecast.RateMode < 1 || p.NewprojectForecast.RateMode > 4 {
+			p.NewprojectForecast.RateMode = 1
+			if len(p.NewprojectForecast.Times) == 0 {
+				p.NewprojectForecast.Times = append(p.NewprojectForecast.Times, "09:00", "14:00")
+			}
+		} else if p.NewprojectForecast.RateMode == 2 && len(p.NewprojectForecast.Times) == 0 {
+			p.NewprojectForecast.Times = append(p.NewprojectForecast.Times, "09:00")
 		}
-	} else if p.NewprojectForecast.RateMode == 2 && len(p.NewprojectForecast.Times) == 0 {
-		p.NewprojectForecast.Times = append(p.NewprojectForecast.Times, "09:00")
+		sort.Strings(p.NewprojectForecast.Times)
 	}
-	sort.Strings(p.NewprojectForecast.Times)
 	//
-	if p.FollowProject.RateMode < 1 || p.FollowProject.RateMode > 4 {
-		p.FollowProject.RateMode = 1
-		if len(p.FollowProject.Times) == 0 {
-			p.FollowProject.Times = append(p.FollowProject.Times, "09:00", "14:00")
+	if p.FollowProject != nil {
+		if p.FollowProject.RateMode < 1 || p.FollowProject.RateMode > 4 {
+			p.FollowProject.RateMode = 1
+			if len(p.FollowProject.Times) == 0 {
+				p.FollowProject.Times = append(p.FollowProject.Times, "09:00", "14:00")
+			}
+		} else if p.FollowProject.RateMode == 2 && len(p.FollowProject.Times) == 0 {
+			p.FollowProject.Times = append(p.FollowProject.Times, "09:00")
 		}
-	} else if p.FollowProject.RateMode == 2 && len(p.FollowProject.Times) == 0 {
-		p.FollowProject.Times = append(p.FollowProject.Times, "09:00")
+		sort.Strings(p.FollowProject.Times)
 	}
-	sort.Strings(p.FollowProject.Times)
 	//
-	if p.FollowEnt.RateMode < 1 || p.FollowEnt.RateMode > 4 {
-		p.FollowEnt.RateMode = 1
-		if len(p.FollowEnt.Times) == 0 {
-			p.FollowEnt.Times = append(p.FollowEnt.Times, "09:00", "14:00")
+	if p.FollowEnt != nil {
+		if p.FollowEnt.RateMode < 1 || p.FollowEnt.RateMode > 4 {
+			p.FollowEnt.RateMode = 1
+			if len(p.FollowEnt.Times) == 0 {
+				p.FollowEnt.Times = append(p.FollowEnt.Times, "09:00", "14:00")
+			}
+		} else if p.FollowEnt.RateMode == 2 && len(p.FollowEnt.Times) == 0 {
+			p.FollowEnt.Times = append(p.FollowEnt.Times, "09:00")
 		}
-	} else if p.FollowEnt.RateMode == 2 && len(p.FollowEnt.Times) == 0 {
-		p.FollowEnt.Times = append(p.FollowEnt.Times, "09:00")
+		sort.Strings(p.FollowEnt.Times)
 	}
-	sort.Strings(p.FollowEnt.Times)
 	//
-	if p.OwnerMonitor.RateMode < 1 || p.OwnerMonitor.RateMode > 4 {
-		p.OwnerMonitor.RateMode = 1
-		if len(p.OwnerMonitor.Times) == 0 {
-			p.OwnerMonitor.Times = append(p.OwnerMonitor.Times, "09:00", "14:00")
+	if p.OwnerMonitor != nil {
+		if p.OwnerMonitor.RateMode < 1 || p.OwnerMonitor.RateMode > 4 {
+			p.OwnerMonitor.RateMode = 1
+			if len(p.OwnerMonitor.Times) == 0 {
+				p.OwnerMonitor.Times = append(p.OwnerMonitor.Times, "09:00", "14:00")
+			}
+		} else if p.OwnerMonitor.RateMode == 2 && len(p.OwnerMonitor.Times) == 0 {
+			p.OwnerMonitor.Times = append(p.OwnerMonitor.Times, "09:00")
 		}
-	} else if p.OwnerMonitor.RateMode == 2 && len(p.OwnerMonitor.Times) == 0 {
-		p.OwnerMonitor.Times = append(p.OwnerMonitor.Times, "09:00")
+		sort.Strings(p.OwnerMonitor.Times)
 	}
-	sort.Strings(p.OwnerMonitor.Times)
 }
 
 type PushSetChild struct {