Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
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
yaru
fgqyxxlr
Commits
7d5e2eae
Commit
7d5e2eae
authored
May 24, 2018
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户逻辑删除&不允许删除修改管理员
parent
11e4c653
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
70 deletions
+84
-70
sql/ry_20180524.sql
+4
-5
src/main/java/com/ruoyi/framework/shiro/service/LoginService.java
+5
-4
src/main/java/com/ruoyi/project/system/user/controller/UserController.java
+10
-7
src/main/java/com/ruoyi/project/system/user/domain/User.java
+13
-27
src/main/java/com/ruoyi/project/system/user/domain/UserStatus.java
+31
-0
src/main/resources/mybatis/system/UserMapper.xml
+16
-18
src/main/resources/static/ruoyi/system/user/user.js
+5
-9
No files found.
sql/ry_20180524.sql
View file @
7d5e2eae
...
...
@@ -48,23 +48,22 @@ create table sys_user (
avatar
varchar
(
100
)
default
''
comment
'头像路径'
,
password
varchar
(
100
)
default
''
comment
'密码'
,
salt
varchar
(
100
)
default
''
comment
'盐加密'
,
user_type
char
(
1
)
default
'N'
comment
'类型:Y默认用户,N非默认用户'
,
status
int
(
1
)
default
0
comment
'帐号状态:0正常,1禁用'
,
refuse_des
varchar
(
500
)
default
''
comment
'拒绝登录描述'
,
status
int
(
1
)
default
0
comment
'帐号状态(0正常 1禁用 2删除)'
,
login_ip
varchar
(
100
)
default
''
comment
'最后登陆IP'
,
login_date
datetime
comment
'最后登陆时间'
,
create_by
varchar
(
64
)
default
''
comment
'创建者'
,
create_time
datetime
comment
'创建时间'
,
update_by
varchar
(
64
)
default
''
comment
'更新者'
,
update_time
datetime
comment
'更新时间'
,
remark
varchar
(
500
)
default
''
comment
'备注'
,
primary
key
(
user_id
)
)
engine
=
innodb
auto_increment
=
100
default
charset
=
utf8
comment
=
'用户信息表'
;
-- ----------------------------
-- 初始化-用户信息表数据
-- ----------------------------
insert
into
sys_user
values
(
1
,
106
,
'admin'
,
'若依'
,
'ry@163.com'
,
'15888888888'
,
'1'
,
''
,
'29c67a30398638269fe600f73a054934'
,
'111111'
,
'Y'
,
0
,
'正常'
,
'127.0.0.1'
,
'2018-03-16 11-33-00'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00
'
);
insert
into
sys_user
values
(
2
,
108
,
'ry'
,
'若依'
,
'ry@qq.com'
,
'15666666666'
,
'1'
,
''
,
'8e6d98b90472783cc73c17047ddccf36'
,
'222222'
,
'N'
,
0
,
'正常'
,
'127.0.0.1'
,
'2018-03-16 11-33-00'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00
'
);
insert
into
sys_user
values
(
1
,
106
,
'admin'
,
'若依'
,
'ry@163.com'
,
'15888888888'
,
'1'
,
''
,
'29c67a30398638269fe600f73a054934'
,
'111111'
,
0
,
'127.0.0.1'
,
'2018-03-16 11-33-00'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
,
'管理员
'
);
insert
into
sys_user
values
(
2
,
108
,
'ry'
,
'若依'
,
'ry@qq.com'
,
'15666666666'
,
'1'
,
''
,
'8e6d98b90472783cc73c17047ddccf36'
,
'222222'
,
0
,
'127.0.0.1'
,
'2018-03-16 11-33-00'
,
'admin'
,
'2018-03-16 11-33-00'
,
'ry'
,
'2018-03-16 11-33-00'
,
'测试员
'
);
-- ----------------------------
-- 3、岗位信息表
...
...
src/main/java/com/ruoyi/framework/shiro/service/LoginService.java
View file @
7d5e2eae
...
...
@@ -16,6 +16,7 @@ import com.ruoyi.common.utils.ServletUtils;
import
com.ruoyi.common.utils.SystemLogUtils
;
import
com.ruoyi.common.utils.security.ShiroUtils
;
import
com.ruoyi.project.system.user.domain.User
;
import
com.ruoyi.project.system.user.domain.UserStatus
;
import
com.ruoyi.project.system.user.service.IUserService
;
/**
...
...
@@ -78,7 +79,7 @@ public class LoginService
user
=
userService
.
selectUserByEmail
(
username
);
}
if
(
user
==
null
)
if
(
user
==
null
||
UserStatus
.
DELETED
.
getCode
()
==
user
.
getStatus
()
)
{
SystemLogUtils
.
log
(
username
,
CommonConstant
.
LOGIN_FAIL
,
MessageUtils
.
message
(
"user.not.exists"
));
throw
new
UserNotExistsException
();
...
...
@@ -86,10 +87,10 @@ public class LoginService
passwordService
.
validate
(
user
,
password
);
if
(
User
Constants
.
USER_BLOCKED
==
user
.
getStatus
())
if
(
User
Status
.
DISABLE
.
getCode
()
==
user
.
getStatus
())
{
SystemLogUtils
.
log
(
username
,
CommonConstant
.
LOGIN_FAIL
,
MessageUtils
.
message
(
"user.blocked"
,
user
.
getRe
fuseDes
()));
throw
new
UserBlockedException
(
user
.
getRe
fuseDes
());
SystemLogUtils
.
log
(
username
,
CommonConstant
.
LOGIN_FAIL
,
MessageUtils
.
message
(
"user.blocked"
,
user
.
getRe
mark
()));
throw
new
UserBlockedException
(
user
.
getRe
mark
());
}
SystemLogUtils
.
log
(
username
,
CommonConstant
.
LOGIN_SUCCESS
,
MessageUtils
.
message
(
"user.login.success"
));
recordLoginInfo
(
user
);
...
...
src/main/java/com/ruoyi/project/system/user/controller/UserController.java
View file @
7d5e2eae
...
...
@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.framework.aspectj.lang.annotation.Log
;
import
com.ruoyi.framework.web.controller.BaseController
;
import
com.ruoyi.framework.web.domain.Message
;
...
...
@@ -21,6 +23,7 @@ import com.ruoyi.project.system.post.service.IPostService;
import
com.ruoyi.project.system.role.domain.Role
;
import
com.ruoyi.project.system.role.service.IRoleService
;
import
com.ruoyi.project.system.user.domain.User
;
import
com.ruoyi.project.system.user.domain.UserStatus
;
import
com.ruoyi.project.system.user.service.IUserService
;
/**
...
...
@@ -129,11 +132,12 @@ public class UserController extends BaseController
{
return
Message
.
error
(
"用户不存在"
);
}
if
(
userService
.
deleteUserById
(
userId
)
>
0
)
else
if
(
User
.
isAdmin
(
userId
)
)
{
return
Message
.
success
(
);
return
Message
.
error
(
"不允许删除超级管理员用户"
);
}
return
Message
.
error
();
user
.
setStatus
(
UserStatus
.
DELETED
.
getCode
());
return
userService
.
updateUser
(
user
)
>
0
?
Message
.
success
()
:
Message
.
error
();
}
@RequiresPermissions
(
"system:user:batchRemove"
)
...
...
@@ -161,11 +165,11 @@ public class UserController extends BaseController
@ResponseBody
public
Message
save
(
User
user
)
{
if
(
userService
.
saveUser
(
user
)
>
0
)
if
(
StringUtils
.
isNotNull
(
user
.
getUserId
())
&&
User
.
isAdmin
(
user
.
getUserId
())
)
{
return
Message
.
success
(
);
return
Message
.
error
(
"不允许修改超级管理员用户"
);
}
return
Message
.
error
();
return
userService
.
saveUser
(
user
)
>
0
?
Message
.
success
()
:
Message
.
error
();
}
/**
...
...
@@ -183,7 +187,6 @@ public class UserController extends BaseController
return
uniqueFlag
;
}
/**
* 校验手机号码
*/
...
...
src/main/java/com/ruoyi/project/system/user/domain/User.java
View file @
7d5e2eae
...
...
@@ -36,12 +36,8 @@ public class User extends BaseEntity
private
String
password
;
/** 盐加密 */
private
String
salt
;
/** 类型:Y默认用户,N非默认用户 */
private
String
userType
;
/** 帐号状态:0正常,1禁用 */
/** 帐号状态:0正常,1禁用,2删除 */
private
int
status
;
/** 拒绝登录描述 */
private
String
refuseDes
;
/** 最后登陆IP */
private
String
loginIp
;
/** 最后登陆时间 */
...
...
@@ -63,6 +59,16 @@ public class User extends BaseEntity
this
.
userId
=
userId
;
}
public
boolean
isAdmin
()
{
return
isAdmin
(
this
.
userId
);
}
public
static
boolean
isAdmin
(
Long
userId
)
{
return
userId
!=
null
&&
1L
==
userId
;
}
public
Long
getDeptId
()
{
return
deptId
;
...
...
@@ -174,16 +180,6 @@ public class User extends BaseEntity
setSalt
(
hex
);
}
public
String
getUserType
()
{
return
userType
;
}
public
void
setUserType
(
String
userType
)
{
this
.
userType
=
userType
;
}
public
int
getStatus
()
{
return
status
;
...
...
@@ -194,16 +190,6 @@ public class User extends BaseEntity
this
.
status
=
status
;
}
public
String
getRefuseDes
()
{
return
refuseDes
;
}
public
void
setRefuseDes
(
String
refuseDes
)
{
this
.
refuseDes
=
refuseDes
;
}
public
String
getLoginIp
()
{
return
loginIp
;
...
...
@@ -259,8 +245,8 @@ public class User extends BaseEntity
{
return
"User [userId="
+
userId
+
", deptId="
+
deptId
+
", parentId="
+
parentId
+
", loginName="
+
loginName
+
", userName="
+
userName
+
", email="
+
email
+
", phonenumber="
+
phonenumber
+
", sex="
+
sex
+
", avatar="
+
avatar
+
", password="
+
password
+
", salt="
+
salt
+
",
userType="
+
userType
+
",
status="
+
status
+
", refuseDes="
+
refuseDes
+
", dept="
+
dept
+
", roleIds="
+
", avatar="
+
avatar
+
", password="
+
password
+
", salt="
+
salt
+
",
status="
+
status
+
",
loginIp="
+
loginIp
+
", loginDate="
+
loginDate
+
", dept="
+
dept
+
", roleIds="
+
Arrays
.
toString
(
roleIds
)
+
", postIds="
+
Arrays
.
toString
(
postIds
)
+
"]"
;
}
...
...
src/main/java/com/ruoyi/project/system/user/domain/UserStatus.java
0 → 100644
View file @
7d5e2eae
package
com
.
ruoyi
.
project
.
system
.
user
.
domain
;
/**
* 用户状态
*
* @author ruoyi
*
*/
public
enum
UserStatus
{
OK
(
0
,
"正常"
),
DISABLE
(
1
,
"禁用"
),
DELETED
(
2
,
"删除"
);
private
final
int
code
;
private
final
String
info
;
UserStatus
(
int
code
,
String
info
)
{
this
.
code
=
code
;
this
.
info
=
info
;
}
public
int
getCode
()
{
return
code
;
}
public
String
getInfo
()
{
return
info
;
}
}
src/main/resources/mybatis/system/UserMapper.xml
View file @
7d5e2eae
...
...
@@ -15,15 +15,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"avatar"
column=
"avatar"
/>
<result
property=
"password"
column=
"password"
/>
<result
property=
"salt"
column=
"salt"
/>
<result
property=
"userType"
column=
"user_type"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"refuseDes"
column=
"refuse_des"
/>
<result
property=
"loginIp"
column=
"login_ip"
/>
<result
property=
"loginDate"
column=
"login_date"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"remark"
column=
"remark"
/>
<association
property=
"dept"
column=
"dept_id"
javaType=
"Dept"
resultMap=
"deptResult"
/>
</resultMap>
...
...
@@ -36,19 +35,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<select
id=
"selectUserList"
parameterType=
"User"
resultMap=
"UserResult"
>
select user_id, dept_id, login_name, user_name, email, phonenumber, password, sex, avatar, salt, user_type, status, refuse_des, create_by, create_time from sys_user
<where>
<if
test=
"searchValue != null and searchValue != ''"
>
AND login_name like concat(concat('%', #{searchValue}), '%')
</if>
<if
test=
"deptId != null and parentId != null and parentId != 0"
>
AND dept_id IN (SELECT dept_id FROM sys_dept WHERE dept_id = #{deptId} OR parent_id = #{deptId})
</if>
</where>
select user_id, dept_id, login_name, user_name, email, phonenumber, password, sex, avatar, salt, status, create_by, create_time, remark from sys_user
where status in (0,1)
<if
test=
"searchValue != null and searchValue != ''"
>
AND login_name like concat(concat('%', #{searchValue}), '%')
</if>
<if
test=
"deptId != null and parentId != null and parentId != 0"
>
AND dept_id IN (SELECT dept_id FROM sys_dept WHERE dept_id = #{deptId} OR parent_id = #{deptId})
</if>
</select>
<select
id=
"selectUserByLoginName"
parameterType=
"String"
resultMap=
"UserResult"
>
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.
refuse_des, u.login_ip, u.login_date, u.create_time
,
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.
login_ip, u.login_date, u.create_time, u.remark
,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
...
...
@@ -57,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select
id=
"selectUserByPhoneNumber"
parameterType=
"String"
resultMap=
"UserResult"
>
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.
refuse_des, u.login_ip, u.login_date, u.create_time
,
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.
login_ip, u.login_date, u.create_time, u.remark
,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
...
...
@@ -66,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select
id=
"selectUserByEmail"
parameterType=
"String"
resultMap=
"UserResult"
>
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.
refuse_des, u.login_ip, u.login_date, u.create_time
,
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.
login_ip, u.login_date, u.create_time, u.remark
,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
...
...
@@ -87,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select
id=
"selectUserById"
parameterType=
"Long"
resultMap=
"UserResult"
>
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.
refuse_des, u.login_ip, u.login_date, u.create_time
,
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.
login_ip, u.login_date, u.create_time, u.remark
,
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
...
...
@@ -119,10 +117,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"password != null and password != ''"
>
password = #{password},
</if>
<if
test=
"salt != null and salt != ''"
>
salt = #{salt},
</if>
<if
test=
"status !=null"
>
status = #{status},
</if>
<if
test=
"refuseDes != null and refuseDes != ''"
>
refuse_des = #{refuseDes},
</if>
<if
test=
"loginIp != null and loginIp != ''"
>
login_ip = #{loginIp},
</if>
<if
test=
"loginDate != null"
>
login_date = #{loginDate},
</if>
<if
test=
"updateBy != null and updateBy != ''"
>
update_by = #{updateBy},
</if>
<if
test=
"remark != null and remark != ''"
>
remark = #{remark},
</if>
update_time = sysdate()
</set>
where 1=1
...
...
@@ -141,8 +139,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"password != null and password != ''"
>
password,
</if>
<if
test=
"salt != null and salt != ''"
>
salt,
</if>
<if
test=
"status !=null and status != ''"
>
status,
</if>
<if
test=
"refuseDes != null and refuseDes != ''"
>
refuse_des,
</if>
<if
test=
"createBy != null and createBy != ''"
>
create_by,
</if>
<if
test=
"remark != null and remark != ''"
>
remark,
</if>
create_time
)values(
<if
test=
"userId != null and userId != ''"
>
#{userId},
</if>
...
...
@@ -155,8 +153,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"password != null and password != ''"
>
#{password},
</if>
<if
test=
"salt != null and salt != ''"
>
#{salt},
</if>
<if
test=
"status !=null and status != ''"
>
#{status},
</if>
<if
test=
"refuseDes != null and refuseDes != ''"
>
#{refuseDes},
</if>
<if
test=
"createBy != null and createBy != ''"
>
#{createBy},
</if>
<if
test=
"remark != null and remark != ''"
>
#{remark},
</if>
sysdate()
)
</insert>
...
...
src/main/resources/static/ruoyi/system/user/user.js
View file @
7d5e2eae
...
...
@@ -51,15 +51,11 @@ function queryUserList() {
title
:
'操作'
,
align
:
'center'
,
formatter
:
function
(
value
,
row
,
index
)
{
if
(
row
.
userType
==
"N"
)
{
var
actions
=
[];
actions
.
push
(
'<a class="btn btn-success btn-xs '
+
editFlag
+
'" href="#" onclick="edit(
\'
'
+
row
.
userId
+
'
\'
)"><i class="fa fa-edit"></i>编辑</a> '
);
actions
.
push
(
'<a class="btn btn-danger btn-xs '
+
removeFlag
+
'" href="#" onclick="remove(
\'
'
+
row
.
userId
+
'
\'
)"><i class="fa fa-remove"></i>删除</a> '
);
actions
.
push
(
'<a class="btn btn-info btn-xs '
+
resetPwdFlag
+
'" href="#" onclick="resetPwd(
\'
'
+
row
.
userId
+
'
\'
)"><i class="fa fa-key"></i>重置</a>'
);
return
actions
.
join
(
''
);
}
else
{
return
""
;
}
var
actions
=
[];
actions
.
push
(
'<a class="btn btn-success btn-xs '
+
editFlag
+
'" href="#" onclick="edit(
\'
'
+
row
.
userId
+
'
\'
)"><i class="fa fa-edit"></i>编辑</a> '
);
actions
.
push
(
'<a class="btn btn-danger btn-xs '
+
removeFlag
+
'" href="#" onclick="remove(
\'
'
+
row
.
userId
+
'
\'
)"><i class="fa fa-remove"></i>删除</a> '
);
actions
.
push
(
'<a class="btn btn-info btn-xs '
+
resetPwdFlag
+
'" href="#" onclick="resetPwd(
\'
'
+
row
.
userId
+
'
\'
)"><i class="fa fa-key"></i>重置</a>'
);
return
actions
.
join
(
''
);
}
}];
var
url
=
prefix
+
"/list"
;
...
...
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