Commit 3abee3c4 authored by fangxinjiang's avatar fangxinjiang

手机号码校验 50个校验

parent acdbd36c
......@@ -173,5 +173,15 @@ public class TCheckMobileController {
public CheckBatchVo checkMobileBatch(@RequestBody List<String> list) {
return tCheckMobileService.checkMobileBatch(list);
}
/**
* @Author fxj
* @Description 批量手机号校验
* @Date 18:20 2023/3/1
**/
@Operation(description = "批量手机号校验")
@SysLog("批量手机号校验" )
@PostMapping("/checkMobileBatch" )
public CheckBatchVo checkMobileBatchs(@RequestBody List<String> list) {
return tCheckMobileService.checkMobileBatch(list);
}
}
......@@ -178,9 +178,35 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
}
}
List<String> noCurlist = new ArrayList<>();
Boolean cur;
Map<String, Boolean> backMap = new HashMap<>();
List<String> tempList = new ArrayList<>();
// 因手机号码最多50个所以这里 要特殊处理下
if (Common.isNotNull(list)){
//计数器
int count =1;
for (String phone:list){
tempList.add(phone);
if (count == 50){
checkMobiles(tempList, vo, noMap, noCurlist, backMap);
tempList.clear();
// 重置
count =1;
}else {
count ++;
}
}
}
checkMobiles(tempList, vo, noMap, noCurlist, backMap);
return vo;
}
private void checkMobiles(List<String> list,
CheckBatchVo vo,
Map<String, Boolean> noMap,
List<String> noCurlist,
Map<String, Boolean> backMap) {
StringBuilder phones = new StringBuilder();
Boolean cur;
for (String check : list) {
cur = noMap.get(check);
if (cur != null) {
......@@ -213,10 +239,9 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
if (!saveList.isEmpty()) {
this.saveBatch(saveList);
}
saveList.clear();
}
}
vo.setCheckMap(backMap);
return vo;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment