소스 검색

feat:增加nil判断

wangchuanjin 2 년 전
부모
커밋
9ecbb7c32b
1개의 변경된 파일63개의 추가작업 그리고 21개의 파일을 삭제
  1. 63 21
      p/struct.go

+ 63 - 21
p/struct.go

@@ -246,22 +246,50 @@ func (u *UserInfo) GetPushSet(obj map[string]interface{}) {
 //解析用户的推送设置
 func (u *UserInfo) PushSetFilter() {
 	if u.Subscribe == 0 || u.S_m_openid == "" {
-		u.PushSet.SubSet.WxPush = -1
-		u.PushSet.WeekReport.WxPush = -1
-		u.PushSet.MonthReport.WxPush = -1
-		u.PushSet.NewprojectForecast.WxPush = -1
-		u.PushSet.EntInfo.WxPush = -1
-		u.PushSet.FollowProject.WxPush = -1
-		u.PushSet.FollowEnt.WxPush = -1
+		if u.PushSet.SubSet != nil {
+			u.PushSet.SubSet.WxPush = -1
+		}
+		if u.PushSet.WeekReport != nil {
+			u.PushSet.WeekReport.WxPush = -1
+		}
+		if u.PushSet.MonthReport != nil {
+			u.PushSet.MonthReport.WxPush = -1
+		}
+		if u.PushSet.NewprojectForecast != nil {
+			u.PushSet.NewprojectForecast.WxPush = -1
+		}
+		if u.PushSet.EntInfo != nil {
+			u.PushSet.EntInfo.WxPush = -1
+		}
+		if u.PushSet.FollowProject != nil {
+			u.PushSet.FollowProject.WxPush = -1
+		}
+		if u.PushSet.FollowEnt != nil {
+			u.PushSet.FollowEnt.WxPush = -1
+		}
 	}
 	if u.Jpushid == "" && u.Opushid == "" {
-		u.PushSet.SubSet.AppPush = -1
-		u.PushSet.WeekReport.AppPush = -1
-		u.PushSet.MonthReport.AppPush = -1
-		u.PushSet.NewprojectForecast.AppPush = -1
-		u.PushSet.EntInfo.AppPush = -1
-		u.PushSet.FollowProject.AppPush = -1
-		u.PushSet.FollowEnt.AppPush = -1
+		if u.PushSet.SubSet != nil {
+			u.PushSet.SubSet.AppPush = -1
+		}
+		if u.PushSet.WeekReport != nil {
+			u.PushSet.WeekReport.AppPush = -1
+		}
+		if u.PushSet.MonthReport != nil {
+			u.PushSet.MonthReport.AppPush = -1
+		}
+		if u.PushSet.NewprojectForecast != nil {
+			u.PushSet.NewprojectForecast.AppPush = -1
+		}
+		if u.PushSet.EntInfo != nil {
+			u.PushSet.EntInfo.AppPush = -1
+		}
+		if u.PushSet.FollowProject != nil {
+			u.PushSet.FollowProject.AppPush = -1
+		}
+		if u.PushSet.FollowEnt != nil {
+			u.PushSet.FollowEnt.AppPush = -1
+		}
 	}
 	mailPush := true
 	if (u.S_m_openid == "" || (u.S_m_openid != "" && u.Subscribe == 0)) && u.Phone == "" && u.A_m_openid == "" {
@@ -272,13 +300,27 @@ func (u *UserInfo) PushSetFilter() {
 		mailPush = false
 	}
 	if !mailPush {
-		u.PushSet.SubSet.MailPush = -1
-		u.PushSet.WeekReport.MailPush = -1
-		u.PushSet.MonthReport.MailPush = -1
-		u.PushSet.NewprojectForecast.MailPush = -1
-		u.PushSet.EntInfo.MailPush = -1
-		u.PushSet.FollowProject.MailPush = -1
-		u.PushSet.FollowEnt.MailPush = -1
+		if u.PushSet.SubSet != nil {
+			u.PushSet.SubSet.MailPush = -1
+		}
+		if u.PushSet.WeekReport != nil {
+			u.PushSet.WeekReport.MailPush = -1
+		}
+		if u.PushSet.MonthReport != nil {
+			u.PushSet.MonthReport.MailPush = -1
+		}
+		if u.PushSet.NewprojectForecast != nil {
+			u.PushSet.NewprojectForecast.MailPush = -1
+		}
+		if u.PushSet.EntInfo != nil {
+			u.PushSet.EntInfo.MailPush = -1
+		}
+		if u.PushSet.FollowProject != nil {
+			u.PushSet.FollowProject.MailPush = -1
+		}
+		if u.PushSet.FollowEnt != nil {
+			u.PushSet.FollowEnt.MailPush = -1
+		}
 	}
 }