Compare commits
No commits in common. "0ffa5fbe983c3aac35a2566dcd4e88fcdc2e0a79" and "97e480a873b5b63d6ee4f2d0ee6012ca80f7a412" have entirely different histories.
0ffa5fbe98
...
97e480a873
|
|
@ -20,18 +20,14 @@ public class CallerController {
|
|||
public ServerResponseEntity receiveCall(@RequestHeader("accessToken") String accessToken,
|
||||
@RequestBody @Valid CallInfo callInfo) {
|
||||
logger.info("CallInfoO: {}",callInfo.toString());
|
||||
if(accessToken == null){
|
||||
if(accessToken == null || callInfo == null){
|
||||
return ServerResponseEntity.fail("accessToken cannot be empty.");
|
||||
}
|
||||
if (callInfo == null || isNullOrEmptyOrLiteralNull(callInfo.getPhoneNumber()) ||
|
||||
isNullOrEmptyOrLiteralNull(callInfo.getCallTime())) {
|
||||
logger.info("CallInfo has invalid fields.");
|
||||
if(callInfo.getPhoneNumber().equals("null") || callInfo.getCallTime().equals("null")){
|
||||
logger.info("CallInfo has null String.");
|
||||
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,10 +25,12 @@ 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,12 +24,16 @@ public class SMSInfo {
|
|||
* @return 如果所有字段都非空,则返回 true,否则返回 false。
|
||||
*/
|
||||
public boolean validateFields() {
|
||||
return isNotBlankAndNotLiteralNull(smsNumber) &&
|
||||
isNotBlankAndNotLiteralNull(smsAcceptanceTime) &&
|
||||
isNotBlankAndNotLiteralNull(smsContent);
|
||||
return StringUtils.isNotBlank(smsNumber) &&
|
||||
StringUtils.isNotBlank(smsAcceptanceTime) &&
|
||||
StringUtils.isNotBlank(smsContent);
|
||||
}
|
||||
|
||||
private boolean isNotBlankAndNotLiteralNull(String value) {
|
||||
return StringUtils.isNotBlank(value) && !"null".equals(value);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
active: prod
|
||||
Loading…
Reference in New Issue