Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
foc_manage
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
首航-临时账号
foc_manage
Commits
2d3a429c
Commit
2d3a429c
authored
Dec 15, 2020
by
java-李谡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
账号IP黑名单管理
parent
c0032799
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
759 additions
and
17 deletions
+759
-17
accountBlacklist.jsp
WebContent/WEB-INF/views/modules/contact/accountBlacklist.jsp
+74
-0
ipBlacklist.jsp
WebContent/WEB-INF/views/modules/contact/ipBlacklist.jsp
+66
-0
soundRecordingList.jsp
WebContent/WEB-INF/views/modules/contact/soundRecordingList.jsp
+0
-1
jdbc.properties
resources/jdbc.properties
+3
-3
IpBlacklistDao.xml
resources/mappings/modules/sys/IpBlacklistDao.xml
+18
-0
UserDao.xml
resources/mappings/modules/sys/UserDao.xml
+16
-4
redis.properties
resources/redis.properties
+19
-0
spring-context.xml
resources/spring-context.xml
+23
-5
RedisUtils.java
src/com/ejweb/core/utils/RedisUtils.java
+202
-0
IpBlacklistDao.java
src/com/ejweb/modules/sys/dao/IpBlacklistDao.java
+34
-0
UserDao.java
src/com/ejweb/modules/sys/dao/UserDao.java
+24
-4
SysLoginBlacklist.java
src/com/ejweb/modules/sys/entity/SysLoginBlacklist.java
+43
-0
AccountBlacklistService.java
src/com/ejweb/modules/sys/service/AccountBlacklistService.java
+62
-0
IpBlacklistService.java
src/com/ejweb/modules/sys/service/IpBlacklistService.java
+45
-0
AccountBlacklistController.java
src/com/ejweb/modules/sys/web/AccountBlacklistController.java
+70
-0
IpBlacklistController.java
src/com/ejweb/modules/sys/web/IpBlacklistController.java
+60
-0
UserController.java
src/com/ejweb/modules/sys/web/UserController.java
+0
-0
No files found.
WebContent/WEB-INF/views/modules/contact/accountBlacklist.jsp
0 → 100644
View file @
2d3a429c
<
%@
taglib
prefix=
"s"
uri=
"http://java.sun.com/jsp/jstl/fmt"
%
>
<
%@
page
contentType=
"text/html;charset=UTF-8"
%
>
<
%@
include
file=
"/WEB-INF/views/include/taglib.jsp"
%
>
<html>
<head>
<title>
账号黑名单
</title>
<meta
name=
"decorator"
content=
"default"
/>
<script
type=
"text/javascript"
>
function
page
(
n
,
s
)
{
if
(
n
)
$
(
"#pageNo"
).
val
(
n
);
if
(
s
)
$
(
"#pageSize"
).
val
(
s
);
$
(
"#searchForm"
).
attr
(
"action"
,
"${ctx}/sys/accountBlacklist/list"
);
$
(
"#searchForm"
).
submit
();
return
false
;
}
</script>
</head>
<body>
<ul
class=
"nav nav-tabs"
>
<li><a
href=
"${ctx}/sys/accountBlacklist/list"
>
账号黑名单
</a></li>
</ul>
<form:form
id=
"searchForm"
modelAttribute=
"user"
action=
"${ctx}/sys/accountBlacklist/list"
method=
"post"
class=
"breadcrumb form-search "
>
<input
id=
"pageNo"
name=
"pageNo"
type=
"hidden"
value=
"${page.pageNo}"
/>
<input
id=
"pageSize"
name=
"pageSize"
type=
"hidden"
value=
"${page.pageSize}"
/>
<sys:tableSort
id=
"orderBy"
name=
"orderBy"
value=
"${page.orderBy}"
callback=
"page();"
/>
<ul
class=
"ul-form"
>
<li>
<label>
登录账号:
</label>
<form:input
path=
"loginName"
htmlEscape=
"false"
maxlength=
"100"
class=
"input-medium"
/>
</li>
<li
class=
"btns"
>
<input
id=
"btnSubmit"
class=
"btn btn-primary"
type=
"submit"
value=
"查询"
onclick=
"return page();"
/>
</li>
<li
class=
"clearfix"
></li>
</ul>
</form:form>
<sys:message
content=
"${message}"
/>
<table
id=
"contentTable"
class=
"table table-striped table-bordered table-condensed"
>
<thead>
<tr>
<th>
编号
</th>
<th>
登录名
</th>
<th>
联系人名称
</th>
<th>
工号
</th>
<th>
公司名称
</th>
<th>
部门名称
</th>
<th>
手机号码
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<c:forEach
items=
"${page.list}"
var=
"user"
varStatus=
"vs"
>
<tr>
<td>
${page.pageSize*(page.pageNo-1)+vs.index+1}
</td>
<td>
${user.loginName }
</td>
<td>
${user.name }
</td>
<td>
${user.no }
</td>
<td>
${user.company.name }
</td>
<td>
${user.office.name }
</td>
<td>
${user.mobile }
</td>
<td>
<a
href=
"${ctx}/sys/accountBlacklist/remove?account=${user.loginName}"
onclick=
"return confirmx('确认要将账号<b>[${user.loginName}]</b>从封禁列表中移除吗?', this.href)"
>
移除
</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<div
class=
"pagination"
>
${page}
</div>
</body>
</html>
\ No newline at end of file
WebContent/WEB-INF/views/modules/contact/ipBlacklist.jsp
0 → 100644
View file @
2d3a429c
<
%@
taglib
prefix=
"s"
uri=
"http://java.sun.com/jsp/jstl/fmt"
%
>
<
%@
page
contentType=
"text/html;charset=UTF-8"
%
>
<
%@
include
file=
"/WEB-INF/views/include/taglib.jsp"
%
>
<html>
<head>
<title>
IP黑名单
</title>
<meta
name=
"decorator"
content=
"default"
/>
<script
type=
"text/javascript"
>
function
page
(
n
,
s
)
{
if
(
n
)
$
(
"#pageNo"
).
val
(
n
);
if
(
s
)
$
(
"#pageSize"
).
val
(
s
);
$
(
"#searchForm"
).
attr
(
"action"
,
"${ctx}/sys/ipBlacklist/list"
);
$
(
"#searchForm"
).
submit
();
return
false
;
}
</script>
</head>
<body>
<ul
class=
"nav nav-tabs"
>
<li><a
href=
"${ctx}/sys/ipBlacklist/list"
>
IP黑名单
</a></li>
</ul>
<form:form
id=
"searchForm"
modelAttribute=
"sysLoginBlacklist"
action=
"${ctx}/sys/ipBlacklist/list"
method=
"post"
class=
"breadcrumb form-search "
>
<input
id=
"pageNo"
name=
"pageNo"
type=
"hidden"
value=
"${page.pageNo}"
/>
<input
id=
"pageSize"
name=
"pageSize"
type=
"hidden"
value=
"${page.pageSize}"
/>
<sys:tableSort
id=
"orderBy"
name=
"orderBy"
value=
"${page.orderBy}"
callback=
"page();"
/>
<ul
class=
"ul-form"
>
<li>
<label>
IP地址:
</label>
<form:input
path=
"blackIp"
htmlEscape=
"false"
maxlength=
"100"
class=
"input-medium"
/>
</li>
<li
class=
"btns"
>
<input
id=
"btnSubmit"
class=
"btn btn-primary"
type=
"submit"
value=
"查询"
onclick=
"return page();"
/>
</li>
<li
class=
"clearfix"
></li>
</ul>
</form:form>
<sys:message
content=
"${message}"
/>
<table
id=
"contentTable"
class=
"table table-striped table-bordered table-condensed"
>
<thead>
<tr>
<th>
编号
</th>
<th>
IP地址
</th>
<th>
封禁时间
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<c:forEach
items=
"${page.list}"
var=
"ip"
varStatus=
"vs"
>
<tr>
<td>
${page.pageSize*(page.pageNo-1)+vs.index+1}
</td>
<td>
${ip.blackIp }
</td>
<td>
${ip.createTime }
</td>
<td>
<a
href=
"${ctx}/sys/ipBlacklist/remove?blackIp=${ip.blackIp}"
onclick=
"return confirmx('确认要将Ip地址<b>[${ip.blackIp}]</b>从封禁列表中移除吗?', this.href)"
>
移除
</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<div
class=
"pagination"
>
${page}
</div>
</body>
</html>
\ No newline at end of file
WebContent/WEB-INF/views/modules/contact/soundRecordingList.jsp
View file @
2d3a429c
...
@@ -73,7 +73,6 @@
...
@@ -73,7 +73,6 @@
<th>
结束时间
</th>
<th>
结束时间
</th>
<th>
通话时长
</th>
<th>
通话时长
</th>
<th>
通话结果
</th>
<th>
通话结果
</th>
<th></th>
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
...
...
resources/jdbc.properties
View file @
2d3a429c
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
db.table.prefix
=
foc_
db.table.prefix
=
foc_
jdbc.type
=
mysql
jdbc.type
=
mysql
jdbc.driver.class
=
com.mysql.jdbc.Driver
jdbc.driver.class
=
com.mysql.jdbc.Driver
jdbc.url
=
jdbc:mysql://
106.75.105.96
:5508/jd_foc?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
jdbc.url
=
jdbc:mysql://
81.69.44.115
:5508/jd_foc?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
jdbc.username
=
jd_foc
jdbc.username
=
sms_develop
jdbc.password
=
FOC@sh2018
jdbc.password
=
Develop2018!@#
#\u521d\u59cb\u5316\u8fde\u63a5
#\u521d\u59cb\u5316\u8fde\u63a5
jdbc.initialSize
=
0
jdbc.initialSize
=
0
#\u8fde\u63a5\u6c60\u7684\u6700\u5927\u6d3b\u52a8\u4e2a\u6570
#\u8fde\u63a5\u6c60\u7684\u6700\u5927\u6d3b\u52a8\u4e2a\u6570
...
...
resources/mappings/modules/sys/IpBlacklistDao.xml
0 → 100644
View file @
2d3a429c
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.ejweb.modules.sys.dao.IpBlacklistDao"
>
<select
id=
"findByIp"
resultType=
"com.ejweb.modules.sys.entity.SysLoginBlacklist"
>
select id,black_ip,create_time from sys_login_blacklist
where black_ip=#{ip}
</select>
<select
id=
"findList"
resultType=
"com.ejweb.modules.sys.entity.SysLoginBlacklist"
>
select id,black_ip,create_time from sys_login_blacklist
</select>
<delete
id=
"deleteByIp"
parameterType=
"string"
>
delete from sys_login_blacklist where black_ip=#{ip}
</delete>
</mapper>
\ No newline at end of file
resources/mappings/modules/sys/UserDao.xml
View file @
2d3a429c
...
@@ -114,20 +114,32 @@
...
@@ -114,20 +114,32 @@
<!-- 根据登录名查询用户 -->
<!-- 根据登录名查询用户 -->
<select
id=
"getByLoginName"
resultType=
"User"
parameterType=
"User"
>
<select
id=
"getByLoginName"
resultType=
"User"
parameterType=
"User"
>
SELECT
SELECT
<include
refid=
"userColumns"
/>
<!-- , ro.office_id AS "roleList.officeList.id" -->
<include
refid=
"userColumns"
/>
<!-- , ro.office_id AS "roleList.officeList.id" -->
FROM sys_user a
FROM sys_user a
<include
refid=
"userJoins"
/>
<!-- LEFT JOIN sys_office2role ro
<include
refid=
"userJoins"
/>
<!-- LEFT JOIN sys_office2role ro
ON ro.role_id = r.id -->
ON ro.role_id = r.id -->
WHERE a.login_name = #{loginName} AND a.del_flag = #{DEL_FLAG_NORMAL}
WHERE a.login_name = #{loginName} AND a.del_flag = #{DEL_FLAG_NORMAL}
</select>
</select>
<select
id=
"getByLoginNames"
resultType=
"com.ejweb.modules.sys.entity.User"
>
SELECT
<include
refid=
"userColumns"
/>
FROM sys_user a
<include
refid=
"userJoins"
/>
WHERE a.del_flag = 0
and a.login_name in
<foreach
collection=
"usernames"
item=
"username"
separator=
","
open=
"("
close=
")"
>
#{username}
</foreach>
</select>
<!-- 分页查询用户信息 -->
<!-- 分页查询用户信息 -->
<select
id=
"findList"
resultType=
"User"
>
<select
id=
"findList"
resultType=
"User"
>
SELECT
SELECT
<include
refid=
"userColumns"
/>
<include
refid=
"userColumns"
/>
,up.duty_name
,up.duty_name
FROM sys_user a
FROM sys_user a
<include
refid=
"userJoins"
/>
<include
refid=
"userJoins"
/>
LEFT JOIN sys_user_profiles up
LEFT JOIN sys_user_profiles up
ON a.id = up.user_id
ON a.id = up.user_id
<if
test=
"role != null and role.id != null and role.id != ''"
>
<if
test=
"role != null and role.id != null and role.id != ''"
>
...
...
resources/redis.properties
0 → 100644
View file @
2d3a429c
#
#redis.host=106.75.105.96
#
redis.host
=
81.69.44.115
redis.port
=
7211
redis.auth
=
bbdtek!@#2018
redis.timeout
=
10000
redis.maxTotal
=
100
redis.maxIdle
=
20
redis.maxWaitMillis
=
10000
redis.testOnBorrow
=
true
redis.testOnReturn
=
true
redis.dbIndex
=
3
redis.ipWithinSeconds
=
60
redis.ipLimitTimes
=
10
redis.usernameWithinSeconds
=
60
redis.usernameLimitTimes
=
6
redis.blackUsernameTime
=
60
\ No newline at end of file
resources/spring-context.xml
View file @
2d3a429c
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
<list>
<list>
<value>
classpath:jdbc.properties
</value>
<value>
classpath:jdbc.properties
</value>
<value>
classpath:ejweb.properties
</value>
<value>
classpath:ejweb.properties
</value>
<value>
classpath:redis.properties
</value>
<value>
classpath:mybatis-refresh.properties
</value>
<value>
classpath:mybatis-refresh.properties
</value>
</list>
</list>
</property>
</property>
...
@@ -134,15 +135,31 @@
...
@@ -134,15 +135,31 @@
<property
name=
"validationQuery"
value=
"${jdbc.validationQuery}"
/>
<property
name=
"validationQuery"
value=
"${jdbc.validationQuery}"
/>
<property
name=
"testWhileIdle"
value=
"true"
/>
<property
name=
"testWhileIdle"
value=
"true"
/>
<property
name=
"testOnBorrow"
value=
"false"
/>
<property
name=
"testOnBorrow"
value=
"false"
/>
<property
name=
"testOnReturn"
value=
"false"
/>
<property
name=
"testOnReturn"
value=
"false"
/>
<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
<property
name=
"poolPreparedStatements"
value=
"true"
/>
<property
name=
"poolPreparedStatements"
value=
"true"
/>
<property
name=
"maxPoolPreparedStatementPerConnectionSize"
value=
"20"
/>
<property
name=
"maxPoolPreparedStatementPerConnectionSize"
value=
"20"
/>
<!-- 配置监控统计拦截的filters,去掉后监控界面sql无法统计 -->
<!-- 配置监控统计拦截的filters,去掉后监控界面sql无法统计 -->
<property
name=
"filters"
value=
"stat"
/>
<property
name=
"filters"
value=
"stat"
/>
</bean>
<!--设置jedisPool链接池的配置-->
<bean
id=
"jedisPoolConfig"
class=
"redis.clients.jedis.JedisPoolConfig"
>
<property
name=
"maxTotal"
value=
"${redis.maxTotal}"
/>
<property
name=
"maxIdle"
value=
"${redis.maxIdle}"
/>
<property
name=
"maxWaitMillis"
value=
"${redis.maxWaitMillis}"
/>
<property
name=
"testOnBorrow"
value=
"${redis.testOnBorrow}"
/>
<property
name=
"testOnReturn"
value=
"${redis.testOnReturn}"
/>
</bean>
<bean
id=
"jedisPool"
class=
"redis.clients.jedis.JedisPool"
>
<constructor-arg
name=
"poolConfig"
ref=
"jedisPoolConfig"
/>
<constructor-arg
name=
"host"
value=
"${redis.host}"
/>
<constructor-arg
name=
"port"
value=
"${redis.port}"
/>
<constructor-arg
name=
"timeout"
value=
"${redis.timeout}"
/>
<constructor-arg
name=
"password"
value=
"${redis.auth}"
/>
</bean>
</bean>
</beans>
</beans>
\ No newline at end of file
src/com/ejweb/core/utils/RedisUtils.java
0 → 100644
View file @
2d3a429c
package
com
.
ejweb
.
core
.
utils
;
import
com.alibaba.fastjson.JSON
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
redis.clients.jedis.Jedis
;
import
redis.clients.jedis.JedisPool
;
import
java.util.Set
;
/**
* @author lisu
*/
@Component
public
class
RedisUtils
{
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
@Autowired
private
JedisPool
jedisPool
;
/**
* 通过key获取储存在redis中的value
* 并释放连接
*
* @param key
* @param indexDb 选择redis库 0-15
* @return 成功返回value 失败返回null
*/
public
String
get
(
String
key
,
int
indexDb
)
{
Jedis
jedis
=
null
;
String
value
=
null
;
try
{
jedis
=
jedisPool
.
getResource
();
jedis
.
select
(
indexDb
);
value
=
jedis
.
get
(
key
);
log
.
info
(
value
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
finally
{
returnResource
(
jedisPool
,
jedis
);
}
return
value
;
}
/**
* 获取所有key
*
* @param pattern
* @param indexDb
* @return
*/
public
Set
<
String
>
keys
(
String
pattern
,
int
indexDb
)
{
Jedis
jedis
=
null
;
Set
<
String
>
value
=
null
;
try
{
jedis
=
jedisPool
.
getResource
();
jedis
.
select
(
indexDb
);
value
=
jedis
.
keys
(
pattern
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
finally
{
returnResource
(
jedisPool
,
jedis
);
}
return
value
;
}
public
Long
del
(
String
key
,
int
indexDb
)
{
Jedis
jedis
=
null
;
Long
value
=
null
;
try
{
jedis
=
jedisPool
.
getResource
();
jedis
.
select
(
indexDb
);
value
=
jedis
.
del
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
finally
{
returnResource
(
jedisPool
,
jedis
);
}
return
value
;
}
/**
* 通过key 对value进行加值+1操作,当value不是int类型时会返回错误,当key不存在是则value为1
*
* @param key
* @return 加值后的结果
*/
public
Long
incr
(
String
key
,
int
indexDb
)
{
Jedis
jedis
=
null
;
Long
res
=
null
;
try
{
jedis
=
jedisPool
.
getResource
();
jedis
.
select
(
indexDb
);
res
=
jedis
.
incr
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
finally
{
returnResource
(
jedisPool
,
jedis
);
}
return
res
;
}
/**
* 通过key 对value进行加值+1操作,当value不是int类型时会返回错误,当key不存在是则value为1
* 自增不取消过期时间
*
* @param key
* @return 加值后的结果
*/
public
Long
incrNotResetExpireTime
(
String
key
,
int
indexDb
)
{
Jedis
jedis
=
null
;
Long
res
=
null
;
try
{
jedis
=
jedisPool
.
getResource
();
jedis
.
select
(
indexDb
);
Integer
expireTime
=
jedis
.
ttl
(
key
).
intValue
();
res
=
jedis
.
incr
(
key
);
// jedis.expireAt(key, expireTime);
res
=
jedis
.
expire
(
key
,
expireTime
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
finally
{
returnResource
(
jedisPool
,
jedis
);
}
return
res
;
}
public
String
set
(
String
key
,
Object
value
,
int
indexDb
)
{
Jedis
jedis
=
null
;
try
{
jedis
=
jedisPool
.
getResource
();
jedis
.
select
(
indexDb
);
JSON
.
toJSONString
(
value
);
return
jedis
.
set
(
key
,
JSON
.
toJSONString
(
value
));
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
return
"0"
;
}
finally
{
returnResource
(
jedisPool
,
jedis
);
}
}
/**
* 设置过期时间
*
* @param key
* @param unixTime 过期时间的时间戳(秒)
* @return
*/
public
Long
expireAt
(
String
key
,
long
unixTime
,
int
indexDb
)
{
Jedis
jedis
=
null
;
Long
res
=
null
;
try
{
jedis
=
jedisPool
.
getResource
();
jedis
.
select
(
indexDb
);
res
=
jedis
.
expireAt
(
key
,
unixTime
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
finally
{
returnResource
(
jedisPool
,
jedis
);
}
return
res
;
}
/**
* 设置过期时间
*
* @param key
* @param seconds 过期时间(秒)
* @return
*/
public
Long
expire
(
String
key
,
int
seconds
,
int
indexDb
)
{
Jedis
jedis
=
null
;
Long
res
=
null
;
try
{
jedis
=
jedisPool
.
getResource
();
jedis
.
select
(
indexDb
);
res
=
jedis
.
expire
(
key
,
seconds
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
finally
{
returnResource
(
jedisPool
,
jedis
);
}
return
res
;
}
/**
* 返还到连接池
*
* @param jedisPool
* @param jedis
*/
public
static
void
returnResource
(
JedisPool
jedisPool
,
Jedis
jedis
)
{
if
(
jedis
!=
null
)
{
jedisPool
.
returnResource
(
jedis
);
}
}
}
\ No newline at end of file
src/com/ejweb/modules/sys/dao/IpBlacklistDao.java
0 → 100644
View file @
2d3a429c
package
com
.
ejweb
.
modules
.
sys
.
dao
;
import
com.ejweb.core.persistence.CrudDao
;
import
com.ejweb.modules.sys.entity.SysLoginBlacklist
;
import
java.util.List
;
/**
* @author LEGION
*/
public
interface
IpBlacklistDao
extends
CrudDao
<
SysLoginBlacklist
>
{
/**
* 根据IP查询黑名单
*
* @param ip ip地址
* @return
*/
SysLoginBlacklist
findByIp
(
String
ip
);
/**
* 根据IP查询黑名单
*
* @param
* @return
*/
List
<
SysLoginBlacklist
>
findList
();
/**
* 删除黑名单
*
* @param ip
*/
void
deleteByIp
(
String
ip
);
}
src/com/ejweb/modules/sys/dao/UserDao.java
View file @
2d3a429c
...
@@ -3,13 +3,15 @@
...
@@ -3,13 +3,15 @@
*/
*/
package
com
.
ejweb
.
modules
.
sys
.
dao
;
package
com
.
ejweb
.
modules
.
sys
.
dao
;
import
java.util.List
;
import
com.ejweb.core.persistence.CrudDao
;
import
com.ejweb.core.persistence.CrudDao
;
import
com.ejweb.modules.sys.entity.User
;
import
com.ejweb.modules.sys.entity.User
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
/**
* 用户DAO接口
* 用户DAO接口
*
* @author ThinkGem
* @author ThinkGem
* @version 2014-05-16
* @version 2014-05-16
*/
*/
...
@@ -17,13 +19,23 @@ public interface UserDao extends CrudDao<User> {
...
@@ -17,13 +19,23 @@ public interface UserDao extends CrudDao<User> {
/**
/**
* 根据登录名称查询用户
* 根据登录名称查询用户
* @param loginName
*
* @param user
* @return
*/
User
getByLoginName
(
User
user
);
/**
* 根据登录名称查询用户
*
* @param usernames 登录名集合
* @return
* @return
*/
*/
public
User
getByLoginName
(
User
user
);
List
<
User
>
getByLoginNames
(
@Param
(
"usernames"
)
List
<
String
>
usernames
);
/**
/**
* 通过OfficeId获取用户列表,仅返回用户id和name(树查询用户时用)
* 通过OfficeId获取用户列表,仅返回用户id和name(树查询用户时用)
*
* @param user
* @param user
* @return
* @return
*/
*/
...
@@ -31,12 +43,14 @@ public interface UserDao extends CrudDao<User> {
...
@@ -31,12 +43,14 @@ public interface UserDao extends CrudDao<User> {
/**
/**
* 查询全部用户数目
* 查询全部用户数目
*
* @return
* @return
*/
*/
public
long
findAllCount
(
User
user
);
public
long
findAllCount
(
User
user
);
/**
/**
* 更新用户密码
* 更新用户密码
*
* @param user
* @param user
* @return
* @return
*/
*/
...
@@ -44,6 +58,7 @@ public interface UserDao extends CrudDao<User> {
...
@@ -44,6 +58,7 @@ public interface UserDao extends CrudDao<User> {
/**
/**
* 更新登录信息,如:登录IP、登录时间
* 更新登录信息,如:登录IP、登录时间
*
* @param user
* @param user
* @return
* @return
*/
*/
...
@@ -51,6 +66,7 @@ public interface UserDao extends CrudDao<User> {
...
@@ -51,6 +66,7 @@ public interface UserDao extends CrudDao<User> {
/**
/**
* 删除用户角色关联数据
* 删除用户角色关联数据
*
* @param user
* @param user
* @return
* @return
*/
*/
...
@@ -58,6 +74,7 @@ public interface UserDao extends CrudDao<User> {
...
@@ -58,6 +74,7 @@ public interface UserDao extends CrudDao<User> {
/**
/**
* 插入用户角色关联数据
* 插入用户角色关联数据
*
* @param user
* @param user
* @return
* @return
*/
*/
...
@@ -65,6 +82,7 @@ public interface UserDao extends CrudDao<User> {
...
@@ -65,6 +82,7 @@ public interface UserDao extends CrudDao<User> {
/**
/**
* 更新用户信息
* 更新用户信息
*
* @param user
* @param user
* @return
* @return
*/
*/
...
@@ -72,6 +90,7 @@ public interface UserDao extends CrudDao<User> {
...
@@ -72,6 +90,7 @@ public interface UserDao extends CrudDao<User> {
/**
/**
* 通过user.no判断是否有相同的雇员
* 通过user.no判断是否有相同的雇员
*
* @param user
* @param user
* @return
* @return
*/
*/
...
@@ -79,6 +98,7 @@ public interface UserDao extends CrudDao<User> {
...
@@ -79,6 +98,7 @@ public interface UserDao extends CrudDao<User> {
/**
/**
* hrm更新user数据
* hrm更新user数据
*
* @param user
* @param user
*/
*/
public
void
updateUserByHrm
(
User
user
);
public
void
updateUserByHrm
(
User
user
);
...
...
src/com/ejweb/modules/sys/entity/SysLoginBlacklist.java
0 → 100644
View file @
2d3a429c
package
com
.
ejweb
.
modules
.
sys
.
entity
;
import
com.ejweb.core.persistence.DataEntity
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
java.util.Date
;
/**
* @author LEGION
*/
public
class
SysLoginBlacklist
extends
DataEntity
<
SysLoginBlacklist
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
id
;
private
String
blackIp
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
String
createTime
;
@Override
public
String
getId
()
{
return
id
;
}
@Override
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getBlackIp
()
{
return
blackIp
;
}
public
void
setBlackIp
(
String
blackIp
)
{
this
.
blackIp
=
blackIp
;
}
public
String
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
String
createTime
)
{
this
.
createTime
=
createTime
;
}
}
src/com/ejweb/modules/sys/service/AccountBlacklistService.java
0 → 100644
View file @
2d3a429c
package
com
.
ejweb
.
modules
.
sys
.
service
;
import
com.ejweb.core.persistence.Page
;
import
com.ejweb.core.utils.RedisUtils
;
import
com.ejweb.core.utils.StringUtils
;
import
com.ejweb.modules.sys.dao.UserDao
;
import
com.ejweb.modules.sys.entity.User
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
/**
* 用户账号封禁服务类
*
* @author LEGION
*/
@Service
public
class
AccountBlacklistService
{
@Autowired
private
UserDao
userDao
;
@Autowired
private
RedisUtils
redisUtils
;
@Value
(
"${redis.dbIndex}"
)
private
int
indexDb
;
public
Page
<
User
>
getPage
(
Page
<
User
>
page
,
User
user
)
{
List
<
User
>
list
=
new
ArrayList
<>();
if
(!
StringUtils
.
isEmpty
(
user
.
getLoginName
()))
{
String
blackName
=
redisUtils
.
get
(
"black_username:"
+
user
.
getLoginName
(),
indexDb
);
if
(!
StringUtils
.
isEmpty
(
blackName
))
{
user
=
userDao
.
getByLoginName
(
user
);
if
(
Objects
.
nonNull
(
user
))
{
list
.
add
(
user
);
}
}
}
else
{
Set
<
String
>
stringSet
=
redisUtils
.
keys
(
"black_username:*"
,
indexDb
);
List
<
String
>
usernames
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
stringSet
))
{
for
(
String
username
:
stringSet
)
{
String
str
=
username
.
substring
(
username
.
indexOf
(
":"
)
+
1
);
usernames
.
add
(
str
);
}
list
=
userDao
.
getByLoginNames
(
usernames
);
}
}
page
.
setList
(
list
);
return
page
;
}
public
void
deleteAccountBlacklist
(
String
account
)
{
String
key
=
"black_username:"
+
account
;
redisUtils
.
del
(
key
,
indexDb
);
redisUtils
.
del
(
account
,
indexDb
);
}
}
src/com/ejweb/modules/sys/service/IpBlacklistService.java
0 → 100644
View file @
2d3a429c
package
com
.
ejweb
.
modules
.
sys
.
service
;
import
com.ejweb.core.persistence.Page
;
import
com.ejweb.core.utils.StringUtils
;
import
com.ejweb.modules.sys.dao.IpBlacklistDao
;
import
com.ejweb.modules.sys.entity.SysLoginBlacklist
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
/**
* @author LEGION
*/
@Service
public
class
IpBlacklistService
{
@Autowired
private
IpBlacklistDao
ipBlacklistDao
;
public
SysLoginBlacklist
getByIp
(
String
ip
)
{
SysLoginBlacklist
ipBlacklist
=
ipBlacklistDao
.
findByIp
(
ip
);
return
ipBlacklist
;
}
public
Page
<
SysLoginBlacklist
>
getPage
(
Page
<
SysLoginBlacklist
>
page
,
SysLoginBlacklist
ipBlacklist
)
{
List
<
SysLoginBlacklist
>
list
=
new
ArrayList
<>();
ipBlacklist
.
setPage
(
page
);
if
(!
StringUtils
.
isEmpty
(
ipBlacklist
.
getBlackIp
()))
{
ipBlacklist
=
ipBlacklistDao
.
findByIp
(
ipBlacklist
.
getBlackIp
());
if
(
Objects
.
nonNull
(
ipBlacklist
))
{
list
.
add
(
ipBlacklist
);
}
}
else
{
list
=
ipBlacklistDao
.
findList
(
ipBlacklist
);
}
page
.
setList
(
list
);
return
page
;
}
public
void
delete
(
String
ip
)
{
ipBlacklistDao
.
deleteByIp
(
ip
);
}
}
src/com/ejweb/modules/sys/web/AccountBlacklistController.java
0 → 100644
View file @
2d3a429c
package
com
.
ejweb
.
modules
.
sys
.
web
;
import
com.ejweb.core.base.BaseController
;
import
com.ejweb.core.persistence.Page
;
import
com.ejweb.core.utils.RedisUtils
;
import
com.ejweb.core.utils.StringUtils
;
import
com.ejweb.modules.sys.entity.User
;
import
com.ejweb.modules.sys.service.AccountBlacklistService
;
import
com.ejweb.modules.sys.service.SystemService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
* 账号及IP封禁控制类
*
* @author LEGION
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/accountBlacklist"
)
public
class
AccountBlacklistController
extends
BaseController
{
@Autowired
private
AccountBlacklistService
accountBlacklistService
;
@Autowired
private
SystemService
systemService
;
@ModelAttribute
public
User
get
(
@RequestParam
(
required
=
false
)
String
loginName
)
{
if
(
StringUtils
.
isNotBlank
(
loginName
))
{
return
systemService
.
getUserByLoginName
(
loginName
);
}
else
{
return
new
User
();
}
}
/**
* 查询封禁账号列表
*
* @param user 用户实体
* @return
*/
@RequestMapping
(
value
=
"list"
)
public
String
accountBlacklist
(
Model
model
,
User
user
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Page
<
User
>
page
=
accountBlacklistService
.
getPage
(
new
Page
<>(
request
,
response
),
user
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/contact/accountBlacklist"
;
}
/**
* 删除封禁账号(解禁)
*
* @param account 登录账号
* @return
*/
@RequestMapping
(
value
=
"remove"
)
public
String
removeAccountBlacklist
(
@RequestParam
()
String
account
)
{
accountBlacklistService
.
deleteAccountBlacklist
(
account
);
return
"redirect:"
+
adminPath
+
"/sys/accountBlacklist/list?repage"
;
}
}
src/com/ejweb/modules/sys/web/IpBlacklistController.java
0 → 100644
View file @
2d3a429c
package
com
.
ejweb
.
modules
.
sys
.
web
;
import
com.ejweb.core.base.BaseController
;
import
com.ejweb.core.persistence.Page
;
import
com.ejweb.core.utils.StringUtils
;
import
com.ejweb.modules.sys.entity.SysLoginBlacklist
;
import
com.ejweb.modules.sys.service.IpBlacklistService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
* @author LEGION
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/ipBlacklist"
)
public
class
IpBlacklistController
extends
BaseController
{
@Autowired
private
IpBlacklistService
ipBlacklistService
;
@ModelAttribute
public
SysLoginBlacklist
get
(
@RequestParam
(
required
=
false
)
String
ip
)
{
if
(
StringUtils
.
isNotBlank
(
ip
))
{
return
ipBlacklistService
.
getByIp
(
ip
);
}
else
{
return
new
SysLoginBlacklist
();
}
}
/**
* 查询封禁IP列表
*
* @param ipBlacklist 用户实体
* @return
*/
@RequestMapping
(
value
=
"list"
)
public
String
IPlist
(
Model
model
,
SysLoginBlacklist
ipBlacklist
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Page
<
SysLoginBlacklist
>
page
=
ipBlacklistService
.
getPage
(
new
Page
<>(
request
,
response
),
ipBlacklist
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/contact/ipBlacklist"
;
}
/**
* 删除封禁IP(解禁)
*
* @param blackIp
* @return
*/
@RequestMapping
(
value
=
"remove"
)
public
String
removeIp
(
@RequestParam
()
String
blackIp
)
{
ipBlacklistService
.
delete
(
blackIp
);
return
"redirect:"
+
adminPath
+
"/sys/ipBlacklist/list"
;
}
}
src/com/ejweb/modules/sys/web/UserController.java
View file @
2d3a429c
This diff is collapsed.
Click to expand it.
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