Commit bb3d1f69 authored by 刘基明's avatar 刘基明

屏蔽手机号

parent 7df9158d
......@@ -96,7 +96,7 @@ public class RankService {
LocalDateTime start = LocalDateTime.now();
//7天内所有主题进行热度值排序
List<ThemeEntity> themeEntities = themeService.queryRecentdays(30);
List<ThemeEntity> themeEntities = themeService.queryRecentdays(60);
if (CollectionUtils.isEmpty(themeEntities)) {
return;
}
......
......@@ -15,6 +15,7 @@ import com.tanpu.community.api.enums.ThemeTypeEnum;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.dao.entity.community.TimesCountEntity;
import com.tanpu.community.dao.mapper.community.ThemeMapper;
import com.tanpu.community.util.OtherUtil;
import com.tanpu.community.util.TimeUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -141,7 +142,9 @@ public class ThemeService {
.in(ThemeEntity::getThemeId, themeIds)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
return themeMapper.selectList(queryWrapper);
List<ThemeEntity> themeEntities = themeMapper.selectList(queryWrapper);
themeEntities.forEach(o->o.setContent(OtherUtil.blockPhoneAndEmail(o.getContent())));
return themeEntities;
}
......
package com.tanpu.community.util;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
public class OtherUtil {
private final static String numberPattern = "^[0-9]*[1-9][0-9]*$";
private final static String phonePattern = "(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}";
private final static String emailPattern = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.com";
public static String getRequestUrl(HttpServletRequest request) {
String s = request.getRequestURL().toString();
String querystr = request.getQueryString();
if (StringUtils.isNotEmpty(querystr)) {
s = s + "?" + querystr;
}
return s;
}
public static String blockPhoneAndEmail(String line) {
// 屏蔽手机号
line = line.replaceAll(phonePattern,"**********");
// 屏蔽邮箱
line = line.replaceAll(emailPattern,"*@*.com");
return line;
}
/**
* 脱敏手机号
*
* @param mobile
* @return
*/
public static String formatMobile(String mobile) {
if (StringUtils.isNotBlank(mobile)) {
mobile = mobile.replaceAll("(\\w{3})\\w*(\\w{4})", "$1****$2");
}
return mobile;
}
public static void main(String[] args) {
System.out.println(OtherUtil.blockPhoneAndEmail("我的手机号是18621088081!,邮箱是123@qq.com。"));
}
}
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