Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zhny
Project
Project
Details
Activity
Releases
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
王夏晖
zhny
Commits
322c2240
Commit
322c2240
authored
May 17, 2018
by
gaoliwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改新增用户部分接口
parent
c3510a46
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
126 additions
and
11 deletions
+126
-11
LoginController.java
...soft/business/system/user/controller/LoginController.java
+31
-1
UserController.java
...isoft/business/system/user/controller/UserController.java
+22
-2
UserRepository.java
.../org/rcisoft/business/system/user/dao/UserRepository.java
+6
-0
UserService.java
...org/rcisoft/business/system/user/service/UserService.java
+21
-1
UserServiceImpl.java
...ft/business/system/user/service/impl/UserServiceImpl.java
+40
-7
UserMapper.xml
src/main/resources/mapper/sys/system/user/UserMapper.xml
+6
-0
No files found.
src/main/java/org/rcisoft/business/system/user/controller/LoginController.java
View file @
322c2240
...
@@ -5,8 +5,12 @@ import io.swagger.annotations.ApiImplicitParams;
...
@@ -5,8 +5,12 @@ import io.swagger.annotations.ApiImplicitParams;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.rcisoft.business.system.user.entity.SysUser
;
import
org.rcisoft.business.system.user.entity.SysUser
;
import
org.rcisoft.business.system.user.service.UserService
;
import
org.rcisoft.business.system.user.service.UserService
;
import
org.rcisoft.core.constant.MessageConstant
;
import
org.rcisoft.core.controller.PaginationController
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.util.ResultGenerator
;
import
org.rcisoft.core.util.ResultGenerator
;
import
org.rcisoft.core.util.UserUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
...
@@ -16,6 +20,8 @@ import org.springframework.web.servlet.support.JstlUtils;
...
@@ -16,6 +20,8 @@ import org.springframework.web.servlet.support.JstlUtils;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* @Author: GaoLiWei
* @Author: GaoLiWei
...
@@ -23,7 +29,7 @@ import javax.servlet.http.HttpServletResponse;
...
@@ -23,7 +29,7 @@ import javax.servlet.http.HttpServletResponse;
*/
*/
@Controller
@Controller
@RequestMapping
(
"/login"
)
@RequestMapping
(
"/login"
)
public
class
LoginController
{
public
class
LoginController
extends
PaginationController
<
SysUser
>
{
@Autowired
@Autowired
private
UserService
userService
;
private
UserService
userService
;
...
@@ -44,6 +50,30 @@ public class LoginController {
...
@@ -44,6 +50,30 @@ public class LoginController {
return
result
;
return
result
;
}
}
@ApiOperation
(
value
=
"修改密码"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"newPassWord"
,
value
=
"新密码"
,
required
=
true
,
dataType
=
"varchar"
,
paramType
=
"body"
),
@ApiImplicitParam
(
name
=
"oldPassWord"
,
value
=
"旧密码"
,
required
=
true
,
dataType
=
"varchar"
,
paramType
=
"body"
)})
@PutMapping
(
value
=
"/updatePassWord"
)
@ResponseBody
public
Result
updatePassWord
(
@RequestBody
String
newPassWord
,
@RequestBody
String
oldPassWord
){
String
userId
=
UserUtil
.
getUserInfoProp
(
getToken
(),
UserUtil
.
USER_ID
);
int
flag
=
userService
.
updatePassWord
(
newPassWord
,
oldPassWord
,
userId
);
return
Result
.
builder
(
new
PersistModel
(
flag
));
}
@ApiOperation
(
value
=
"重置密码"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"needUserId"
,
value
=
"需要修改密码的用户的ID"
,
required
=
true
,
dataType
=
"varchar"
,
paramType
=
"body"
)})
@ResponseBody
@PutMapping
(
value
=
"/resetPassWord"
)
public
Result
resetPassWord
(
@RequestBody
String
needUserId
){
String
userId
=
UserUtil
.
getUserInfoProp
(
getToken
(),
UserUtil
.
USER_ID
);
int
flag
=
userService
.
resetPassWord
(
userId
,
needUserId
);
return
Result
.
builder
(
new
PersistModel
(
flag
));
}
...
...
src/main/java/org/rcisoft/business/system/user/controller/UserController.java
View file @
322c2240
...
@@ -16,6 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -16,6 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* @Author: GaoLiWei
* @Author: GaoLiWei
* @Date: Created in 10:422018/5/2
* @Date: Created in 10:422018/5/2
...
@@ -60,12 +63,14 @@ public class UserController extends PaginationController<SysUser> {
...
@@ -60,12 +63,14 @@ public class UserController extends PaginationController<SysUser> {
@PutMapping
(
value
=
"updateUser"
)
@PutMapping
(
value
=
"updateUser"
)
@ResponseBody
@ResponseBody
public
Result
updateUser
(
@RequestBody
UserDto
userDto
){
public
Result
updateUser
(
@RequestBody
UserDto
userDto
){
String
userId
=
UserUtil
.
getUserInfoProp
(
getToken
(),
UserUtil
.
USER_ID
);
SysUser
sysUser
=
userDto
.
getSysUser
();
SysUser
sysUser
=
userDto
.
getSysUser
();
sysUser
.
setUserId
(
userId
);
SysAdmins
sysAdmins
=
userDto
.
getSysAdmins
();
SysAdmins
sysAdmins
=
userDto
.
getSysAdmins
();
SysOwner
sysOwner
=
userDto
.
getSysOwner
();
SysOwner
sysOwner
=
userDto
.
getSysOwner
();
SysPrincipal
sysPrincipal
=
userDto
.
getSysPrincipal
();
SysPrincipal
sysPrincipal
=
userDto
.
getSysPrincipal
();
String
data
=
userService
.
updateUser
(
sysUser
,
sysAdmins
,
sysOwner
,
sysPrincipal
);
int
flag
=
userService
.
updateUser
(
sysUser
,
sysAdmins
,
sysOwner
,
sysPrincipal
);
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
data
);
return
Result
.
builder
(
new
PersistModel
(
flag
)
);
}
}
@ApiOperation
(
value
=
"通过用户ID查找用户信息"
)
@ApiOperation
(
value
=
"通过用户ID查找用户信息"
)
...
@@ -104,6 +109,21 @@ public class UserController extends PaginationController<SysUser> {
...
@@ -104,6 +109,21 @@ public class UserController extends PaginationController<SysUser> {
}
}
@ApiOperation
(
value
=
"查看某个用户信息"
)
@ResponseBody
@GetMapping
(
value
=
"/getUserInfo"
)
public
Result
getUserInfo
(){
String
userId
=
UserUtil
.
getUserInfoProp
(
getToken
(),
UserUtil
.
USER_ID
);
List
<
Map
<
String
,
Object
>>
userInfo
=
userService
.
getUserInfo
(
userId
);
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
userInfo
);
}
@ApiOperation
(
value
=
"查詢所有菜單"
)
@ApiOperation
(
value
=
"查詢所有菜單"
)
@ResponseBody
@ResponseBody
...
...
src/main/java/org/rcisoft/business/system/user/dao/UserRepository.java
View file @
322c2240
...
@@ -22,6 +22,12 @@ public interface UserRepository extends BaseMapper<SysUser>{
...
@@ -22,6 +22,12 @@ public interface UserRepository extends BaseMapper<SysUser>{
*/
*/
List
<
SysUser
>
listByUserName
(
@Param
(
"userName"
)
String
userName
);
List
<
SysUser
>
listByUserName
(
@Param
(
"userName"
)
String
userName
);
/** 根据用户ID查看用户信息
* @param userId
* @return
*/
List
<
Map
<
String
,
Object
>>
getUserInfo
(
@Param
(
"userId"
)
String
userId
);
/**
/**
* 查询所有用户
* 查询所有用户
...
...
src/main/java/org/rcisoft/business/system/user/service/UserService.java
View file @
322c2240
...
@@ -38,7 +38,7 @@ public interface UserService {
...
@@ -38,7 +38,7 @@ public interface UserService {
* @param sysPrincipal
* @param sysPrincipal
* @return
* @return
*/
*/
String
updateUser
(
SysUser
sysUser
,
SysAdmins
sysAdmins
,
SysOwner
sysOwner
,
SysPrincipal
sysPrincipal
);
int
updateUser
(
SysUser
sysUser
,
SysAdmins
sysAdmins
,
SysOwner
sysOwner
,
SysPrincipal
sysPrincipal
);
/** 根据userId删除用户
/** 根据userId删除用户
* @param userId
* @param userId
...
@@ -65,6 +65,26 @@ public interface UserService {
...
@@ -65,6 +65,26 @@ public interface UserService {
*/
*/
int
updateRoleMenu
(
RelRoleMenu
relRoleMenu
);
int
updateRoleMenu
(
RelRoleMenu
relRoleMenu
);
/** 查看某个用户的信息
* @return
*/
List
<
Map
<
String
,
Object
>>
getUserInfo
(
String
userId
);
/** 修改密码
* @param newPassWord
* @param oldPassWord
* @return
*/
int
updatePassWord
(
String
newPassWord
,
String
oldPassWord
,
String
userId
);
/** 重置密码
* @param userId
* @return
*/
int
resetPassWord
(
String
userId
,
String
needUserId
);
List
<
Map
<
String
,
Object
>>
listMenuAll
();
List
<
Map
<
String
,
Object
>>
listMenuAll
();
List
<
Map
<
String
,
Object
>>
listRoleAll
();
List
<
Map
<
String
,
Object
>>
listRoleAll
();
...
...
src/main/java/org/rcisoft/business/system/user/service/impl/UserServiceImpl.java
View file @
322c2240
...
@@ -14,6 +14,7 @@ import org.rcisoft.common.constants.UserTpConstant;
...
@@ -14,6 +14,7 @@ import org.rcisoft.common.constants.UserTpConstant;
import
org.rcisoft.core.aop.PageUtil
;
import
org.rcisoft.core.aop.PageUtil
;
import
org.rcisoft.core.util.IdGen
;
import
org.rcisoft.core.util.IdGen
;
import
org.rcisoft.core.util.JwtUtil
;
import
org.rcisoft.core.util.JwtUtil
;
import
org.rcisoft.core.util.UserUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
...
@@ -140,8 +141,8 @@ public class UserServiceImpl implements UserService {
...
@@ -140,8 +141,8 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
String
updateUser
(
SysUser
sysUser
,
SysAdmins
sysAdmins
,
SysOwner
sysOwner
,
SysPrincipal
sysPrincipal
)
{
public
int
updateUser
(
SysUser
sysUser
,
SysAdmins
sysAdmins
,
SysOwner
sysOwner
,
SysPrincipal
sysPrincipal
)
{
String
result
=
"修改失败"
;
int
flag
=
0
;
String
userId
=
sysUser
.
getUserId
();
String
userId
=
sysUser
.
getUserId
();
String
userTp
=
sysUser
.
getUserTp
();
String
userTp
=
sysUser
.
getUserTp
();
try
{
try
{
...
@@ -150,7 +151,7 @@ public class UserServiceImpl implements UserService {
...
@@ -150,7 +151,7 @@ public class UserServiceImpl implements UserService {
if
(
null
!=
sysAdminsByUserId
){
if
(
null
!=
sysAdminsByUserId
){
sysAdmins
.
setAdminId
(
sysAdminsByUserId
.
getAdminId
());
sysAdmins
.
setAdminId
(
sysAdminsByUserId
.
getAdminId
());
adminRepository
.
updateByPrimaryKeySelective
(
sysAdmins
);
adminRepository
.
updateByPrimaryKeySelective
(
sysAdmins
);
result
=
"修改管理员信息成功"
;
flag
=
1
;
}
}
}
}
if
(
UserTpConstant
.
TP_OWNER
.
equals
(
userTp
))
{
if
(
UserTpConstant
.
TP_OWNER
.
equals
(
userTp
))
{
...
@@ -158,7 +159,7 @@ public class UserServiceImpl implements UserService {
...
@@ -158,7 +159,7 @@ public class UserServiceImpl implements UserService {
if
(
null
!=
sysOwnerByUserId
)
{
if
(
null
!=
sysOwnerByUserId
)
{
sysOwner
.
setOwnId
(
sysOwnerByUserId
.
getOwnId
());
sysOwner
.
setOwnId
(
sysOwnerByUserId
.
getOwnId
());
ownerRepository
.
updateByPrimaryKeySelective
(
sysOwner
);
ownerRepository
.
updateByPrimaryKeySelective
(
sysOwner
);
result
=
"修改业主信息成功"
;
flag
=
1
;
}
}
}
}
if
(
UserTpConstant
.
TP_PRINCIPAL
.
equals
(
userTp
))
{
if
(
UserTpConstant
.
TP_PRINCIPAL
.
equals
(
userTp
))
{
...
@@ -166,14 +167,14 @@ public class UserServiceImpl implements UserService {
...
@@ -166,14 +167,14 @@ public class UserServiceImpl implements UserService {
if
(
null
!=
sysPrincipalByUserId
)
{
if
(
null
!=
sysPrincipalByUserId
)
{
sysPrincipal
.
setPriId
(
sysPrincipalByUserId
.
getPriId
());
sysPrincipal
.
setPriId
(
sysPrincipalByUserId
.
getPriId
());
principalRepository
.
updateByPrimaryKeySelective
(
sysPrincipal
);
principalRepository
.
updateByPrimaryKeySelective
(
sysPrincipal
);
result
=
"修改团队负责人信息成功"
;
flag
=
1
;
}
}
}
}
return
result
;
return
flag
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
"修改失败"
;
return
flag
;
}
}
@Override
@Override
...
@@ -254,6 +255,38 @@ public class UserServiceImpl implements UserService {
...
@@ -254,6 +255,38 @@ public class UserServiceImpl implements UserService {
return
flag
;
return
flag
;
}
}
@Override
public
List
<
Map
<
String
,
Object
>>
getUserInfo
(
String
userId
)
{
return
userRepository
.
getUserInfo
(
userId
);
}
@Override
public
int
updatePassWord
(
String
newPassWord
,
String
oldPassWord
,
String
userId
)
{
int
flag
=
0
;
SysUser
sysUser
=
userRepository
.
selectByPrimaryKey
(
userId
);
String
encodedPassword
=
sysUser
.
getUserPwd
();
boolean
matches
=
passwordEncoder
.
matches
(
oldPassWord
,
encodedPassword
);
if
(
matches
){
sysUser
.
setUserPwd
(
passwordEncoder
.
encode
(
newPassWord
));
int
i
=
userRepository
.
updateByPrimaryKeySelective
(
sysUser
);
flag
=
i
;
}
return
flag
;
}
@Override
public
int
resetPassWord
(
String
userId
,
String
needUserId
)
{
int
flag
=
0
;
SysUser
sysUser
=
userRepository
.
selectByPrimaryKey
(
userId
);
if
(
UserTpConstant
.
TP_SUPER_ADMIN
.
equals
(
sysUser
.
getUserTp
())){
SysUser
needSysUser
=
userRepository
.
selectByPrimaryKey
(
needUserId
);
needSysUser
.
setUserPwd
(
passwordEncoder
.
encode
(
UserPassWordConstant
.
PASSWORD
));
userRepository
.
updateByPrimaryKeySelective
(
needSysUser
);
flag
=
1
;
}
return
flag
;
}
@Override
@Override
public
List
<
Map
<
String
,
Object
>>
listMenuAll
()
{
public
List
<
Map
<
String
,
Object
>>
listMenuAll
()
{
List
<
Map
<
String
,
Object
>>
list
=
relUserRoleRepository
.
listMenuAll
();
List
<
Map
<
String
,
Object
>>
list
=
relUserRoleRepository
.
listMenuAll
();
...
...
src/main/resources/mapper/sys/system/user/UserMapper.xml
View file @
322c2240
...
@@ -7,5 +7,11 @@
...
@@ -7,5 +7,11 @@
SELECT USER_ID AS userId, USER_NM AS userNm, USER_PWD AS userPwd, USER_TP AS userTp FROM sys_user
SELECT USER_ID AS userId, USER_NM AS userNm, USER_PWD AS userPwd, USER_TP AS userTp FROM sys_user
WHERE USER_NM = #{userName}
WHERE USER_NM = #{userName}
</select>
</select>
<select
id=
"getUserInfo"
resultType=
"map"
>
SELECT su.USER_NM,su.USER_TP,sa.*, so.*,sp.* FROM sys_user su LEFT JOIN sys_admins sa ON su.USER_ID = sa.USER_ID
LEFT JOIN sys_owner so ON su.USER_ID = so.USER_ID
LEFT JOIN sys_principal sp ON su.USER_ID = sp.USER_ID
WHERE su.USER_ID=#{userId}
</select>
</mapper>
</mapper>
\ No newline at end of file
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