Authored by LUOXC

refactor

@@ -95,11 +95,17 @@ public class BaseNoticeFacade { @@ -95,11 +95,17 @@ public class BaseNoticeFacade {
95 95
96 public void send() { 96 public void send() {
97 executorService.execute(() -> { 97 executorService.execute(() -> {
98 - final Logger log = getLogger();  
99 final String logPrefix = getReplacedContent("{} send uid {}", this.logPrefix, this.uid); 98 final String logPrefix = getReplacedContent("{} send uid {}", this.logPrefix, this.uid);
100 - log.warn("{}, inBoxContent {} smsContent {}", logPrefix, inBoxContent, smsContent); 99 + log.info("{}, start", logPrefix);
  100 + sendInbox(logPrefix);
  101 + sendPush(logPrefix);
  102 + sendSms(logPrefix);
  103 + log.info("{}, end", logPrefix);
  104 + });
  105 + }
101 106
102 - // 发送站内信 107 + private void sendInbox(String logPrefix) {
  108 + final Logger log = getLogger();
103 InboxReqVO inBoxContent = getInBoxContentWhenExceptionAnd(e -> { 109 InboxReqVO inBoxContent = getInBoxContentWhenExceptionAnd(e -> {
104 log.warn("{}, send in box fail, get content fail", logPrefix, e); 110 log.warn("{}, send in box fail, get content fail", logPrefix, e);
105 return null; 111 return null;
@@ -108,13 +114,27 @@ public class BaseNoticeFacade { @@ -108,13 +114,27 @@ public class BaseNoticeFacade {
108 try { 114 try {
109 inBoxContent.setUid(uid); 115 inBoxContent.setUid(uid);
110 InBoxResponse resp = inBoxSDK.addInbox(inBoxContent); 116 InBoxResponse resp = inBoxSDK.addInbox(inBoxContent);
111 - log.info("{}, send in box success content {} response {}", logPrefix, inBoxContent, JSON.toJSON(resp)); 117 + log.info("{}, send in box success content {} response {}", logPrefix, JSON.toJSON(inBoxContent), JSON.toJSON(resp));
112 } catch (Exception e) { 118 } catch (Exception e) {
113 - log.warn("{}, send in box fail content {}", logPrefix, inBoxContent, e); 119 + log.warn("{}, send in box fail content {}", logPrefix, JSON.toJSON(inBoxContent), e);
  120 + }
  121 + }
  122 + }
  123 +
  124 + private InboxReqVO getInBoxContentWhenExceptionAnd(Function<Exception, InboxReqVO> exceptionFunction) {
  125 + if (Objects.nonNull(inBoxContentSupplier)) {
  126 + try {
  127 + return inBoxContentSupplier.get();
  128 + } catch (Exception e) {
  129 + return exceptionFunction.apply(e);
  130 + }
  131 + } else {
  132 + return this.inBoxContent;
114 } 133 }
115 } 134 }
116 135
117 - // 发送PUSH 136 + private void sendPush(String logPrefix) {
  137 + final Logger log = getLogger();
118 if (Objects.nonNull(pushSupplier)) { 138 if (Objects.nonNull(pushSupplier)) {
119 try { 139 try {
120 SendMessageRspBo resp = pushSupplier.get(); 140 SendMessageRspBo resp = pushSupplier.get();
@@ -123,8 +143,10 @@ public class BaseNoticeFacade { @@ -123,8 +143,10 @@ public class BaseNoticeFacade {
123 log.warn("{}, send push fail", logPrefix, e); 143 log.warn("{}, send push fail", logPrefix, e);
124 } 144 }
125 } 145 }
  146 + }
126 147
127 - // 发送短信 148 + private void sendSms(String logPrefix) {
  149 + final Logger log = getLogger();
128 String smsContent = getSmsContentWhenExceptionAnd(e -> { 150 String smsContent = getSmsContentWhenExceptionAnd(e -> {
129 log.warn("{}, send sms fail, get content fail", logPrefix, e); 151 log.warn("{}, send sms fail, get content fail", logPrefix, e);
130 return null; 152 return null;
@@ -143,21 +165,6 @@ public class BaseNoticeFacade { @@ -143,21 +165,6 @@ public class BaseNoticeFacade {
143 log.warn("{}, send sms fail content {}", logPrefix, smsContent, e); 165 log.warn("{}, send sms fail content {}", logPrefix, smsContent, e);
144 } 166 }
145 } 167 }
146 -  
147 - // END  
148 - });  
149 - }  
150 -  
151 - private InboxReqVO getInBoxContentWhenExceptionAnd(Function<Exception, InboxReqVO> exceptionFunction) {  
152 - if (Objects.nonNull(inBoxContentSupplier)) {  
153 - try {  
154 - return inBoxContentSupplier.get();  
155 - } catch (Exception e) {  
156 - return exceptionFunction.apply(e);  
157 - }  
158 - } else {  
159 - return this.inBoxContent;  
160 - }  
161 } 168 }
162 169
163 private String getSmsContentWhenExceptionAnd(Function<Exception, String> exceptionFunction) { 170 private String getSmsContentWhenExceptionAnd(Function<Exception, String> exceptionFunction) {