Compare commits
3 Commits
a2ac8c8920
...
0ffa5fbe98
| Author | SHA1 | Date |
|---|---|---|
|
|
0ffa5fbe98 | |
|
|
533c1efb63 | |
|
|
529e7c7aa9 |
|
|
@ -20,14 +20,18 @@ public class CallerController {
|
|||
public ServerResponseEntity receiveCall(@RequestHeader("accessToken") String accessToken,
|
||||
@RequestBody @Valid CallInfo callInfo) {
|
||||
logger.info("CallInfoO: {}",callInfo.toString());
|
||||
if(accessToken == null || callInfo == null){
|
||||
if(accessToken == null){
|
||||
return ServerResponseEntity.fail("accessToken cannot be empty.");
|
||||
}
|
||||
if(callInfo.getPhoneNumber().equals("null") || callInfo.getCallTime().equals("null")){
|
||||
logger.info("CallInfo has null String.");
|
||||
if (callInfo == null || isNullOrEmptyOrLiteralNull(callInfo.getPhoneNumber()) ||
|
||||
isNullOrEmptyOrLiteralNull(callInfo.getCallTime())) {
|
||||
logger.info("CallInfo has invalid fields.");
|
||||
return ServerResponseEntity.fail("json body value error.");
|
||||
}
|
||||
return callService.getPhoneNumber(accessToken,callInfo);
|
||||
}
|
||||
private boolean isNullOrEmptyOrLiteralNull(String value) {
|
||||
return value == null || value.isEmpty() || "null".equals(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,10 @@ public class SMSController {
|
|||
if(accessToken == null){
|
||||
return ServerResponseEntity.fail("accessToken cannot be empty.");
|
||||
}
|
||||
if (smsInfo.isNullString()){
|
||||
return ServerResponseEntity.fail("json body value error.");
|
||||
}
|
||||
if (smsInfo == null || !smsInfo.validateFields()) {
|
||||
return ServerResponseEntity.fail("SMS info fields must not be blank.");
|
||||
}
|
||||
|
||||
return smsService.getSMSInfo(accessToken,smsInfo);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,16 +24,12 @@ public class SMSInfo {
|
|||
* @return 如果所有字段都非空,则返回 true,否则返回 false。
|
||||
*/
|
||||
public boolean validateFields() {
|
||||
return StringUtils.isNotBlank(smsNumber) &&
|
||||
StringUtils.isNotBlank(smsAcceptanceTime) &&
|
||||
StringUtils.isNotBlank(smsContent);
|
||||
return isNotBlankAndNotLiteralNull(smsNumber) &&
|
||||
isNotBlankAndNotLiteralNull(smsAcceptanceTime) &&
|
||||
isNotBlankAndNotLiteralNull(smsContent);
|
||||
}
|
||||
public boolean isNullString(){
|
||||
String nullString = "null";
|
||||
if (this.smsNumber.equals(nullString) || this.smsContent.equals(nullString) || this.smsAcceptanceTime.equals(nullString)){
|
||||
logger.info("SMSInfo has null String.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
private boolean isNotBlankAndNotLiteralNull(String value) {
|
||||
return StringUtils.isNotBlank(value) && !"null".equals(value);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue