Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
chnmuseum-party
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liqin
chnmuseum-party
Commits
b0a916b3
Commit
b0a916b3
authored
Mar 25, 2021
by
liqin
💬
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://111.203.232.171:8888/lee/chnmuseum-party
into master
parents
c4901dd1
6906221c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
163 additions
and
79 deletions
+163
-79
TUserMapper.java
...java/cn/wisenergy/chnmuseum/party/mapper/TUserMapper.java
+2
-1
TUser.java
src/main/java/cn/wisenergy/chnmuseum/party/model/TUser.java
+0
-1
TUserService.java
...va/cn/wisenergy/chnmuseum/party/service/TUserService.java
+3
-1
TUserServiceImpl.java
...energy/chnmuseum/party/service/impl/TUserServiceImpl.java
+4
-2
SysLogController.java
...ergy/chnmuseum/party/web/controller/SysLogController.java
+9
-9
TUserController.java
...nergy/chnmuseum/party/web/controller/TUserController.java
+140
-62
TUserMapper.xml
src/main/resources/mapper/TUserMapper.xml
+5
-3
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/mapper/TUserMapper.java
View file @
b0a916b3
...
...
@@ -2,6 +2,7 @@ package cn.wisenergy.chnmuseum.party.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
...
...
@@ -17,7 +18,7 @@ public interface TUserMapper extends BaseMapper<TUser> {
TUser
selectByUsername
(
String
userName
);
List
<
TUser
>
selec
tList
(
String
userName
);
List
<
TUser
>
ge
tList
(
String
userName
);
TUser
getById
(
String
id
);
}
src/main/java/cn/wisenergy/chnmuseum/party/model/TUser.java
View file @
b0a916b3
...
...
@@ -75,7 +75,6 @@ public class TUser implements Serializable {
@ApiModelProperty
(
"所属机构ID"
)
@TableField
(
"org_id"
)
@NotBlank
(
message
=
"所属机构ID不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
orgId
;
@ApiModelProperty
(
"是否永久用户"
)
...
...
src/main/java/cn/wisenergy/chnmuseum/party/service/TUserService.java
View file @
b0a916b3
...
...
@@ -4,6 +4,8 @@ import cn.wisenergy.chnmuseum.party.model.TUser;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
java.util.List
;
/**
* <p>
* 用户 服务接口
...
...
@@ -16,7 +18,7 @@ public interface TUserService extends IService<TUser> {
TUser
selectByUsername
(
String
userName
);
Page
<
TUser
>
selec
tList
(
Page
<
TUser
>
page
,
String
userName
);
Page
<
TUser
>
ge
tList
(
Page
<
TUser
>
page
,
String
userName
);
TUser
selectById
(
String
id
);
}
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/TUserServiceImpl.java
View file @
b0a916b3
...
...
@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
javax.annotation.Resource
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* <pre>
...
...
@@ -39,8 +40,8 @@ public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements
}
@Override
public
Page
<
TUser
>
selec
tList
(
Page
<
TUser
>
page
,
String
userName
)
{
return
page
.
setRecords
(
tUserMapper
.
selec
tList
(
userName
));
public
Page
<
TUser
>
ge
tList
(
Page
<
TUser
>
page
,
String
userName
)
{
return
page
.
setRecords
(
tUserMapper
.
ge
tList
(
userName
));
}
@Override
...
...
@@ -52,4 +53,5 @@ public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements
}
return
user
;
}
}
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/SysLogController.java
View file @
b0a916b3
...
...
@@ -96,7 +96,7 @@ public class SysLogController extends BaseController {
})
@GetMapping
(
value
=
"/querySysLogList"
)
@RequiresPermissions
(
"/sysLog/querySysLogList"
)
public
ResponseEntity
<
Page
<
SysLog
>
>
querySysLogList
(
GenericPageParam
genericPageParam
)
{
public
Map
<
String
,
Object
>
querySysLogList
(
GenericPageParam
genericPageParam
)
{
try
{
LambdaQueryWrapper
<
SysLog
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
// 对名称或编码模糊查询
...
...
@@ -117,11 +117,11 @@ public class SysLogController extends BaseController {
// 设置排序规则
queryWrapper
.
orderByDesc
(
SysLog:
:
getOperationTime
);
Page
<
SysLog
>
page
=
sysLogService
.
page
(
getPage
(),
queryWrapper
);
return
ResponseEntity
.
ok
(
page
);
return
getResult
(
page
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询系统日志列表出错!"
,
e
);
}
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
null
);
return
getFailResult
(
);
}
/**
...
...
@@ -158,14 +158,14 @@ public class SysLogController extends BaseController {
})
@GetMapping
(
value
=
"/OperationLog"
)
@RequiresPermissions
(
"/sysLog/OperationLog"
)
public
ResponseEntity
<
Page
<
TOperationLog
>
>
OperationLog
(
TOperationLog
operationLog
)
{
public
Map
<
String
,
Object
>
OperationLog
(
TOperationLog
operationLog
)
{
try
{
Page
<
TOperationLog
>
page
=
operationLogService
.
pageList
(
getPage
(),
operationLog
);
return
ResponseEntity
.
ok
(
page
);
return
getResult
(
page
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询系统日志列表出错!"
,
e
);
}
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
null
);
return
getFailResult
(
);
}
/**
...
...
@@ -181,14 +181,14 @@ public class SysLogController extends BaseController {
})
@GetMapping
(
value
=
"/runLogList"
)
@RequiresPermissions
(
"/sysLog/runLogList"
)
public
ResponseEntity
<
Page
<
RunLog
>
>
runLogList
(
RunLog
runLog
)
{
public
Map
<
String
,
Object
>
runLogList
(
RunLog
runLog
)
{
try
{
Page
<
RunLog
>
page
=
runLogService
.
pageList
(
getPage
(),
runLog
);
return
ResponseEntity
.
ok
(
page
);
return
getResult
(
page
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询系统日志列表出错!"
,
e
);
}
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
null
);
return
getFailResult
(
);
}
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TUserController.java
View file @
b0a916b3
...
...
@@ -7,6 +7,7 @@ import cn.wisenergy.chnmuseum.party.common.log.MethodLog;
import
cn.wisenergy.chnmuseum.party.common.log.OperModule
;
import
cn.wisenergy.chnmuseum.party.common.log.OperType
;
import
cn.wisenergy.chnmuseum.party.common.util.DateUtil80
;
import
cn.wisenergy.chnmuseum.party.common.util.RandomUtil
;
import
cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam
;
import
cn.wisenergy.chnmuseum.party.core.annotations.OperationLog
;
import
cn.wisenergy.chnmuseum.party.model.Role
;
...
...
@@ -70,61 +71,66 @@ public class TUserController extends BaseController {
//用户登录是否被锁定 一小时 redisKey 前缀
private
String
SHIRO_IS_LOCK
=
"shiro_is_lock_"
;
/**
* 获取用户分页列表
*
* @param
* @return
*/
@ApiOperation
(
value
=
"获取用户分页列表"
)
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"_index"
,
value
=
"分页起始偏移量"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"_size"
,
value
=
"返回条数"
,
paramType
=
"query"
,
dataType
=
"Integer"
)
})
@RequestMapping
(
value
=
"/getPageList"
,
method
=
RequestMethod
.
GET
)
@RequiresPermissions
(
"/user/getPageList"
)
// @MethodLog(operModule = OperModule.USER, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getUserList
(
String
userName
)
{
try
{
Page
<
TUser
>
list
=
userService
.
getList
(
getPage
(),
userName
);
return
getResult
(
list
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询成员列表出错!"
,
e
);
}
return
getFailResult
();
}
/**
* 查询成员列表
*
* @param
userName (用户名称)
* @param
* @return
*/
@ApiOperation
(
value
=
"
查询成员
列表"
)
@ApiOperation
(
value
=
"
获取用户
列表"
)
@RequestMapping
(
value
=
"/getUserList"
,
method
=
RequestMethod
.
GET
)
@RequiresPermissions
(
"/user/getUserList"
)
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
SELECT
)
public
ResponseEntity
<
Page
<
TUser
>>
queryUserList
(
String
userName
)
{
// @MethodLog(operModule = OperModule.USER, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getUserList
(
String
type
,
String
status
,
String
auditStatus
)
{
UpdateWrapper
<
TUser
>
wrapper
=
new
UpdateWrapper
<>();
try
{
userName
=
StringUtils
.
trimToNull
(
userName
);
Page
<
TUser
>
page
=
getPage
();
Page
<
TUser
>
userPage
=
userService
.
selectList
(
page
,
userName
);
return
ResponseEntity
.
ok
(
userPage
);
if
(
StringUtils
.
isNotBlank
(
type
)){
wrapper
.
eq
(
"type"
,
type
);
}
if
(
StringUtils
.
isNotBlank
(
status
)){
wrapper
.
eq
(
"status"
,
status
);
}
if
(
StringUtils
.
isNotBlank
(
auditStatus
)){
wrapper
.
eq
(
"audit_status"
,
auditStatus
);
}
wrapper
.
eq
(
"is_deleted"
,
false
);
wrapper
.
orderByDesc
(
"create_time"
);
List
<
TUser
>
list
=
userService
.
list
(
wrapper
);
return
getResult
(
list
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询成员列表出错!"
,
e
);
}
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
null
);
}
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"_index"
,
value
=
"分页起始偏移量"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"_size"
,
value
=
"返回条数"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"nameOrCode"
,
value
=
"名称或编码"
,
paramType
=
"query"
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"startDate"
,
value
=
"创建时间-开始"
,
paramType
=
"query"
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"endDate"
,
value
=
"创建时间-结束"
,
paramType
=
"query"
,
dataType
=
"String"
)
})
@PostMapping
(
"/getPageList"
)
@RequiresPermissions
(
"/user/getPageList"
)
@ApiOperation
(
value
=
"获取用户分页列表"
,
notes
=
"获取用户分页列表"
)
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
SELECT
)
public
Map
<
String
,
Object
>
getPageList
(
GenericPageParam
genericPageParam
)
{
LambdaQueryWrapper
<
TUser
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
// 对名称或编码模糊查询
if
(
StringUtils
.
isNotBlank
(
genericPageParam
.
getNameOrCode
()))
{
queryWrapper
.
like
(
TUser:
:
getUserName
,
genericPageParam
.
getNameOrCode
());
}
// 根据创建时间区间检索
if
(
genericPageParam
.
getStartDate
()
!=
null
&&
genericPageParam
.
getEndDate
()
!=
null
)
{
queryWrapper
.
ge
(
TUser:
:
getCreateTime
,
genericPageParam
.
getStartDate
().
atTime
(
0
,
0
,
0
))
.
le
(
TUser:
:
getCreateTime
,
genericPageParam
.
getEndDate
().
atTime
(
23
,
59
,
59
));
}
// 设置排序规则
queryWrapper
.
orderByDesc
(
TUser:
:
getCreateTime
);
Page
<
TUser
>
page
=
userService
.
page
(
getPage
(),
queryWrapper
);
return
getResult
(
page
);
return
getFailResult
();
}
@ApiOperation
(
value
=
"获取用户详情"
,
notes
=
"获取用户详情"
)
@GetMapping
(
"/getById"
)
@RequiresPermissions
(
"/user/getById"
)
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
SELECT
)
//
@MethodLog(operModule = OperModule.USER, operType = OperType.SELECT)
public
Map
<
String
,
Object
>
getById
(
String
id
)
{
TUser
tUser
=
userService
.
selectById
(
id
);
List
<
Role
>
list
=
roleService
.
selectRoleByUserId
(
id
);
...
...
@@ -142,21 +148,21 @@ public class TUserController extends BaseController {
Map
<
String
,
Object
>
resultMap
=
new
LinkedHashMap
<
String
,
Object
>();
try
{
if
(
StringUtils
.
isBlank
(
user
.
getUserName
()))
{
resultMap
.
put
(
"
status
"
,
400
);
resultMap
.
put
(
"
resultCode
"
,
400
);
resultMap
.
put
(
"message"
,
"账号不能为空!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
else
{
user
.
setUserName
(
StringUtils
.
trimToNull
(
user
.
getUserName
()));
}
if
(
StringUtils
.
isBlank
(
user
.
getPassword
()))
{
resultMap
.
put
(
"
status
"
,
400
);
resultMap
.
put
(
"
resultCode
"
,
400
);
resultMap
.
put
(
"message"
,
"密码不能为空!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
else
{
user
.
setPassword
(
StringUtils
.
trimToNull
(
user
.
getPassword
()));
}
if
(
StringUtils
.
isBlank
(
user
.
getRealName
()))
{
resultMap
.
put
(
"
status
"
,
400
);
resultMap
.
put
(
"
resultCode
"
,
400
);
resultMap
.
put
(
"message"
,
"姓名不能为空!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
else
{
...
...
@@ -164,12 +170,12 @@ public class TUserController extends BaseController {
}
if
(
user
.
getRoleList
()
==
null
||
user
.
getRoleList
().
size
()
<
1
)
{
resultMap
.
put
(
"
status
"
,
400
);
resultMap
.
put
(
"
resultCode
"
,
400
);
resultMap
.
put
(
"message"
,
"请选择角色!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
if
(
StringUtils
.
isBlank
(
user
.
getOrgId
()))
{
resultMap
.
put
(
"
status
"
,
400
);
resultMap
.
put
(
"
resultCode
"
,
400
);
resultMap
.
put
(
"message"
,
"请选择机构!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
...
...
@@ -181,7 +187,7 @@ public class TUserController extends BaseController {
ew
.
eq
(
"user_name"
,
user
.
getUserName
());
TUser
one
=
this
.
userService
.
getOne
(
ew
);
if
(
one
!=
null
)
{
resultMap
.
put
(
"
status
"
,
400
);
resultMap
.
put
(
"
resultCode
"
,
400
);
resultMap
.
put
(
"message"
,
"账号已存在!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
...
...
@@ -194,6 +200,8 @@ public class TUserController extends BaseController {
user
.
setPasswordHash
(
passwordHash
);
user
.
setCreateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
user
.
setUpdateTime
(
user
.
getCreateTime
());
user
.
setStatus
(
"1"
);
user
.
setAuditStatus
(
"4"
);
user
.
setIsDeleted
(
false
);
boolean
ret
=
this
.
userService
.
save
(
user
);
...
...
@@ -212,17 +220,17 @@ public class TUserController extends BaseController {
if
(!
ret
)
{
// 新增失败, 500
resultMap
.
put
(
"
status
"
,
500
);
resultMap
.
put
(
"
resultCode
"
,
500
);
resultMap
.
put
(
"message"
,
"服务器忙"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
.
body
(
resultMap
);
}
resultMap
.
put
(
"
status
"
,
200
);
resultMap
.
put
(
"
resultCode
"
,
200
);
resultMap
.
put
(
"message"
,
"添加成功"
);
// 201
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
resultMap
);
}
catch
(
Exception
e
)
{
resultMap
.
put
(
"
status
"
,
500
);
resultMap
.
put
(
"
resultCode
"
,
500
);
resultMap
.
put
(
"message"
,
"服务器忙"
);
logger
.
error
(
"新增成员错误!"
,
e
);
}
...
...
@@ -273,19 +281,19 @@ public class TUserController extends BaseController {
}
}
else
{
// 更新失败, 400
resultMap
.
put
(
"
status
"
,
400
);
resultMap
.
put
(
"
resultCode
"
,
400
);
resultMap
.
put
(
"message"
,
"请选择用户"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
if
(!
ret
)
{
// 更新失败, 500
resultMap
.
put
(
"
status
"
,
500
);
resultMap
.
put
(
"
resultCode
"
,
500
);
resultMap
.
put
(
"message"
,
"服务器忙"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
// 204
resultMap
.
put
(
"
status
"
,
201
);
resultMap
.
put
(
"
resultCode
"
,
201
);
resultMap
.
put
(
"message"
,
"更新成功"
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
resultMap
);
}
catch
(
Exception
e
)
{
...
...
@@ -325,11 +333,11 @@ public class TUserController extends BaseController {
boolean
ret2
=
this
.
tUserRoleService
.
remove
(
userRoleWrapper
);
if
(!
ret1
||
!
ret2
)
{
resultMap
.
put
(
"
status
"
,
400
);
resultMap
.
put
(
"
resultCode
"
,
400
);
resultMap
.
put
(
"message"
,
"删除失败"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
resultMap
.
put
(
"
status
"
,
201
);
resultMap
.
put
(
"
resultCode
"
,
201
);
resultMap
.
put
(
"message"
,
"删除成功"
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
resultMap
);
}
catch
(
Exception
e
)
{
...
...
@@ -368,11 +376,11 @@ public class TUserController extends BaseController {
stringRedisTemplate
.
delete
(
SHIRO_JWT_TOKEN
+
userId
);
}
if
(!
ret
)
{
resultMap
.
put
(
"
status
"
,
400
);
resultMap
.
put
(
"
resultCode
"
,
400
);
resultMap
.
put
(
"message"
,
"禁用失败"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
resultMap
.
put
(
"
status
"
,
201
);
resultMap
.
put
(
"
resultCode
"
,
201
);
resultMap
.
put
(
"message"
,
"禁用成功"
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
resultMap
);
}
catch
(
Exception
e
)
{
...
...
@@ -398,11 +406,11 @@ public class TUserController extends BaseController {
entity
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
boolean
ret
=
this
.
userService
.
updateById
(
entity
);
if
(!
ret
)
{
map
.
put
(
"
status
"
,
"500"
);
map
.
put
(
"
resultCode
"
,
"500"
);
map
.
put
(
"message"
,
"服务器错误"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
map
);
}
map
.
put
(
"
status
"
,
"201"
);
map
.
put
(
"
resultCode
"
,
"201"
);
map
.
put
(
"message"
,
"启用成功"
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
map
);
}
catch
(
Exception
e
)
{
...
...
@@ -434,24 +442,24 @@ public class TUserController extends BaseController {
ret
=
this
.
userService
.
updateById
(
user
);
}
else
{
logger
.
error
(
"旧密码不正确"
);
resultMap
.
put
(
"
status
"
,
400
);
resultMap
.
put
(
"
resultCode
"
,
400
);
resultMap
.
put
(
"message"
,
"旧密码不正确"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
if
(!
ret
)
{
resultMap
.
put
(
"
status
"
,
500
);
resultMap
.
put
(
"
resultCode
"
,
500
);
resultMap
.
put
(
"message"
,
"修改失败"
);
// 更新失败, 500
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
resultMap
.
put
(
"
status
"
,
200
);
resultMap
.
put
(
"
resultCode
"
,
200
);
resultMap
.
put
(
"message"
,
"修改成功"
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
resultMap
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"更新密码错误!"
,
e
);
}
// 500
resultMap
.
put
(
"
status
"
,
500
);
resultMap
.
put
(
"
resultCode
"
,
500
);
resultMap
.
put
(
"message"
,
"修改失败"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
...
...
@@ -479,9 +487,9 @@ public class TUserController extends BaseController {
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
build
();
}
stringRedisTemplate
.
delete
(
SHIRO_IS_LOCK
+
userService
.
getById
(
userId
).
getUserName
());
map
.
put
(
"
status
"
,
"201"
);
map
.
put
(
"
resultCode
"
,
"201"
);
map
.
put
(
"message"
,
"重置密码成功"
);
map
.
put
(
"
password
"
,
newPassword
);
map
.
put
(
"
data
"
,
newPassword
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
map
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"重置密码出错!"
,
e
);
...
...
@@ -509,5 +517,75 @@ public class TUserController extends BaseController {
return
getFailResult
();
}
//新增
@OperationLog
(
"新增机顶盒账号"
)
@ApiOperation
(
value
=
"新增机顶盒账号"
)
@RequestMapping
(
value
=
"/BoxAdd"
,
method
=
RequestMethod
.
POST
)
@RequiresPermissions
(
"/user/BoxAdd"
)
// @MethodLog(operModule = OperModule.USER, operType = OperType.ADD)
public
ResponseEntity
<
Map
<
String
,
Object
>>
BoxAdd
(
TUser
user
)
{
Map
<
String
,
Object
>
resultMap
=
new
LinkedHashMap
<
String
,
Object
>();
try
{
if
(
StringUtils
.
isBlank
(
user
.
getUserName
()))
{
resultMap
.
put
(
"resultCode"
,
400
);
resultMap
.
put
(
"message"
,
"账号不能为空!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
else
{
user
.
setUserName
(
StringUtils
.
trimToNull
(
user
.
getUserName
()));
}
user
.
setPassword
(
RandomUtil
.
createRandom
(
6
));
QueryWrapper
<
TUser
>
ew
=
new
QueryWrapper
<>();
if
(
StringUtils
.
isNoneBlank
(
user
.
getUserName
()))
{
user
.
setUserName
(
user
.
getUserName
().
trim
());
ew
.
eq
(
"is_deleted"
,
0
);
ew
.
eq
(
"user_name"
,
user
.
getUserName
());
TUser
one
=
this
.
userService
.
getOne
(
ew
);
if
(
one
!=
null
)
{
resultMap
.
put
(
"resultCode"
,
400
);
resultMap
.
put
(
"message"
,
"账号已存在!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
}
byte
[]
passwordSalt
=
SecureRandomSaltService
.
generateSalt
();
byte
[]
passwordHash
=
SHA256PasswordEncryptionService
.
createPasswordHash
(
user
.
getPassword
(),
passwordSalt
);
user
.
setPasswordSalt
(
passwordSalt
);
user
.
setPasswordHash
(
passwordHash
);
user
.
setCreateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
user
.
setUpdateTime
(
user
.
getCreateTime
());
user
.
setIsDeleted
(
false
);
user
.
setPermanent
(
true
);
user
.
setStatus
(
"1"
);
user
.
setAuditStatus
(
"4"
);
user
.
setType
(
"3"
);
boolean
ret
=
this
.
userService
.
save
(
user
);
if
(!
ret
)
{
// 新增失败, 500
resultMap
.
put
(
"resultCode"
,
500
);
resultMap
.
put
(
"message"
,
"服务器忙"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
.
body
(
resultMap
);
}
resultMap
.
put
(
"resultCode"
,
200
);
resultMap
.
put
(
"message"
,
"添加成功"
);
resultMap
.
put
(
"data"
,
user
.
getPassword
());
// 201
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
resultMap
);
}
catch
(
Exception
e
)
{
resultMap
.
put
(
"resultCode"
,
500
);
resultMap
.
put
(
"message"
,
"服务器忙"
);
logger
.
error
(
"新增成员错误!"
,
e
);
}
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
}
src/main/resources/mapper/TUserMapper.xml
View file @
b0a916b3
...
...
@@ -65,14 +65,16 @@
where u.id =#{id}
</select>
<select
id=
"
selec
tList"
resultMap=
"BaseResultMap"
>
<select
id=
"
ge
tList"
resultMap=
"BaseResultMap"
>
select u.*,o.name org_name,a.full_name area_name
from t_user u
left join t_organ o on o.id = u.org_id
left join t_area a on u.area_id = a.id
<if
test=
" user
name != null and usern
ame != '' "
>
<if
test=
" user
Name != null and userN
ame != '' "
>
where u.user_name LIKE concat('%', #{userName}, '%')
</if>
and u.is_deleted = false
order by u.create_time desc
</select>
<select
id=
"selectRoles"
resultMap=
"roleMap"
>
...
...
@@ -81,7 +83,7 @@
left join t_organ o on o.id = u.org_id
left join t_user_role_link l on l.user_id = u.id
left join t_role r on l.role_id = r.id
<if
test=
" user
name != null and usern
ame != '' "
>
<if
test=
" user
Name != null and userN
ame != '' "
>
where u.user_name =#{userName}
</if>
</select>
...
...
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