Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
bb3d1f69
Commit
bb3d1f69
authored
Oct 28, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
屏蔽手机号
parent
7df9158d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
2 deletions
+53
-2
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+1
-1
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+4
-1
OtherUtil.java
...ice/src/main/java/com/tanpu/community/util/OtherUtil.java
+48
-0
No files found.
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
bb3d1f69
...
...
@@ -96,7 +96,7 @@ public class RankService {
LocalDateTime
start
=
LocalDateTime
.
now
();
//7天内所有主题进行热度值排序
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryRecentdays
(
3
0
);
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryRecentdays
(
6
0
);
if
(
CollectionUtils
.
isEmpty
(
themeEntities
))
{
return
;
}
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
bb3d1f69
...
...
@@ -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
;
}
...
...
community-service/src/main/java/com/tanpu/community/util/OtherUtil.java
0 → 100644
View file @
bb3d1f69
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。"
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment