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
2c27db79
Commit
2c27db79
authored
Mar 23, 2021
by
wzp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
机构管理查询和导入,用户管理
parent
1ffb1bd9
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
671 additions
and
301 deletions
+671
-301
pom.xml
pom.xml
+13
-0
OperModule.java
...a/cn/wisenergy/chnmuseum/party/common/log/OperModule.java
+31
-5
OperType.java
...ava/cn/wisenergy/chnmuseum/party/common/log/OperType.java
+37
-9
SystemOperationLogService.java
...chnmuseum/party/common/log/SystemOperationLogService.java
+2
-2
ImportExcelUtil.java
...isenergy/chnmuseum/party/common/util/ImportExcelUtil.java
+74
-0
SwaggerConfig.java
...java/cn/wisenergy/chnmuseum/party/conf/SwaggerConfig.java
+2
-2
WebLogAspect.java
...a/cn/wisenergy/chnmuseum/party/core/aop/WebLogAspect.java
+1
-1
TOrganMapper.java
...ava/cn/wisenergy/chnmuseum/party/mapper/TOrganMapper.java
+4
-1
TUserMapper.java
...java/cn/wisenergy/chnmuseum/party/mapper/TUserMapper.java
+5
-1
Role.java
src/main/java/cn/wisenergy/chnmuseum/party/model/Role.java
+1
-1
TUser.java
src/main/java/cn/wisenergy/chnmuseum/party/model/TUser.java
+2
-2
TOrganService.java
...a/cn/wisenergy/chnmuseum/party/service/TOrganService.java
+2
-0
TUserService.java
...va/cn/wisenergy/chnmuseum/party/service/TUserService.java
+4
-1
RunLogServiceImpl.java
...nergy/chnmuseum/party/service/impl/RunLogServiceImpl.java
+10
-0
TOrganServiceImpl.java
...nergy/chnmuseum/party/service/impl/TOrganServiceImpl.java
+45
-5
TUserServiceImpl.java
...energy/chnmuseum/party/service/impl/TUserServiceImpl.java
+8
-2
LoginController.java
...nergy/chnmuseum/party/web/controller/LoginController.java
+6
-6
SysLogController.java
...ergy/chnmuseum/party/web/controller/SysLogController.java
+21
-1
TOrganController.java
...ergy/chnmuseum/party/web/controller/TOrganController.java
+53
-27
TUserController.java
...nergy/chnmuseum/party/web/controller/TUserController.java
+308
-234
TOrganMapper.xml
src/main/resources/mapper/TOrganMapper.xml
+5
-0
TUserMapper.xml
src/main/resources/mapper/TUserMapper.xml
+37
-1
No files found.
pom.xml
View file @
2c27db79
...
@@ -115,6 +115,19 @@
...
@@ -115,6 +115,19 @@
<version>
1.27.2
</version>
<version>
1.27.2
</version>
</dependency>
</dependency>
<!-- POI导入导出 -->
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
3.17
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
3.17
</version>
</dependency>
<!-- Swagger2 Document -->
<!-- Swagger2 Document -->
<dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<groupId>
io.springfox
</groupId>
...
...
src/main/java/cn/wisenergy/chnmuseum/party/common/log/OperModule.java
View file @
2c27db79
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
log
;
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
log
;
public
enum
OperModule
{
public
enum
OperModule
{
用户管理
,
USER
(
1
,
"用户管理"
),
角色管理
,
ROLE
(
1
,
"角色管理"
),
人员管理
,
DEPT
(
1
,
"部门管理"
),
部门管理
,
ORG
(
1
,
"机构管理"
);
机构管理
;
// 错误编码
private
Integer
code
;
// 信息
private
String
msg
;
// 相应编码有参构造函数
OperModule
(
Integer
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
}
src/main/java/cn/wisenergy/chnmuseum/party/common/log/OperType.java
View file @
2c27db79
...
@@ -4,13 +4,41 @@ public enum OperType {
...
@@ -4,13 +4,41 @@ public enum OperType {
/**
/**
*
*
*/
*/
查询
,
添加
,
修改
,
SELECT
(
1
,
"查询"
),
删除
,
ADD
(
2
,
"新增"
),
禁用
,
UPDATE
(
3
,
"修改"
),
启用
,
DELETE
(
4
,
"删除"
),
复制
,
UNABLE
(
5
,
"启用"
),
分享
,
DISABLE
(
6
,
"禁用"
),
注销
;
IMPORT
(
7
,
"导入"
);
// 错误编码
private
Integer
code
;
// 信息
private
String
msg
;
// 相应编码有参构造函数
OperType
(
Integer
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
}
src/main/java/cn/wisenergy/chnmuseum/party/common/log/SystemOperationLogService.java
View file @
2c27db79
...
@@ -132,9 +132,9 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
...
@@ -132,9 +132,9 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
*/
*/
public
void
getControllerMethodDescription
(
MethodLog
log
,
SysLog
sysLog
)
throws
Exception
{
public
void
getControllerMethodDescription
(
MethodLog
log
,
SysLog
sysLog
)
throws
Exception
{
// 设置action动作
// 设置action动作
sysLog
.
setOperationType
(
log
.
operType
().
name
());
sysLog
.
setOperationType
(
log
.
operType
().
getMsg
());
// 设置标题
// 设置标题
sysLog
.
setOperationObject
(
log
.
operModule
().
name
());
sysLog
.
setOperationObject
(
log
.
operModule
().
getMsg
());
}
}
/**
/**
...
...
src/main/java/cn/wisenergy/chnmuseum/party/common/util/ImportExcelUtil.java
0 → 100644
View file @
2c27db79
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
util
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
ImportExcelUtil
{
// abc.xls
public
static
boolean
isXls
(
String
fileName
)
{
// (?i)忽略大小写
if
(
fileName
.
matches
(
"^.+\\.(?i)(xls)$"
))
{
return
true
;
}
else
if
(
fileName
.
matches
(
"^.+\\.(?i)(xlsx)$"
))
{
return
false
;
}
else
{
throw
new
RuntimeException
(
"格式不对"
);
}
}
public
static
List
<
Map
<
String
,
String
>>
readExcel
(
String
fileName
,
InputStream
is
)
throws
Exception
{
boolean
ret
=
isXls
(
fileName
);
Workbook
workbook
=
null
;
// 根据文件后缀创建不同的对象
if
(
ret
)
{
workbook
=
new
HSSFWorkbook
(
is
);
}
else
{
workbook
=
new
XSSFWorkbook
(
is
);
}
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
// 得到标题行
Row
titleRow
=
sheet
.
getRow
(
0
);
//行数
int
lastRowNum
=
sheet
.
getLastRowNum
();
//列数
int
lastCellNum
=
titleRow
.
getLastCellNum
();
List
<
Map
<
String
,
String
>>
list
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<=
lastRowNum
;
i
++)
{
ArrayList
<
String
>
list1
=
new
ArrayList
<>();
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
//获取行数据
Row
row
=
sheet
.
getRow
(
i
);
for
(
int
j
=
0
;
j
<
lastCellNum
;
j
++)
{
//获取单元格
Cell
cell
=
row
.
getCell
(
j
);
if
(
cell
!=
null
)
{
cell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
//获取单元格数据
list1
.
add
(
cell
.
getStringCellValue
());
//列名 :数据
map
.
put
(
titleRow
.
getCell
(
j
).
getStringCellValue
(),
cell
.
getStringCellValue
());
}
else
{
continue
;
}
}
list
.
add
(
map
);
}
is
.
close
();
return
list
;
}
}
\ No newline at end of file
src/main/java/cn/wisenergy/chnmuseum/party/conf/SwaggerConfig.java
View file @
2c27db79
...
@@ -32,8 +32,8 @@ public class SwaggerConfig {
...
@@ -32,8 +32,8 @@ public class SwaggerConfig {
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"cn.wisenergy.chnmuseum.party.web.controller"
))
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"cn.wisenergy.chnmuseum.party.web.controller"
))
.
paths
(
PathSelectors
.
any
())
.
paths
(
PathSelectors
.
any
())
.
build
()
.
build
()
//
.securitySchemes(newArrayList(apiKey()))
.
securitySchemes
(
newArrayList
(
apiKey
()))
//
.securityContexts(newArrayList(securityContext()))
.
securityContexts
(
newArrayList
(
securityContext
()))
;
;
}
}
...
...
src/main/java/cn/wisenergy/chnmuseum/party/core/aop/WebLogAspect.java
View file @
2c27db79
...
@@ -76,7 +76,7 @@ public class WebLogAspect {
...
@@ -76,7 +76,7 @@ public class WebLogAspect {
content
=
annotation
.
value
();
content
=
annotation
.
value
();
}
}
//插入到系统日志表
//插入到系统日志表
this
.
sysLogController
.
insertSysLog
(
content
,
null
);
this
.
sysLogController
.
insertSysLog
(
content
,
null
,
null
);
}
}
return
proceedingJoinPoint
.
proceed
();
return
proceedingJoinPoint
.
proceed
();
...
...
src/main/java/cn/wisenergy/chnmuseum/party/mapper/TOrganMapper.java
View file @
2c27db79
...
@@ -3,6 +3,9 @@ package cn.wisenergy.chnmuseum.party.mapper;
...
@@ -3,6 +3,9 @@ package cn.wisenergy.chnmuseum.party.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
cn.wisenergy.chnmuseum.party.model.TOrgan
;
import
cn.wisenergy.chnmuseum.party.model.TOrgan
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* <pre>
* <pre>
* 用户 Mapper 接口
* 用户 Mapper 接口
...
@@ -12,5 +15,5 @@ import cn.wisenergy.chnmuseum.party.model.TOrgan;
...
@@ -12,5 +15,5 @@ import cn.wisenergy.chnmuseum.party.model.TOrgan;
* @since 2021-03-22
* @since 2021-03-22
*/
*/
public
interface
TOrganMapper
extends
BaseMapper
<
TOrgan
>
{
public
interface
TOrganMapper
extends
BaseMapper
<
TOrgan
>
{
List
<
Map
<
String
,
Object
>>
selectArea
();
}
}
src/main/java/cn/wisenergy/chnmuseum/party/mapper/TUserMapper.java
View file @
2c27db79
...
@@ -3,6 +3,8 @@ package cn.wisenergy.chnmuseum.party.mapper;
...
@@ -3,6 +3,8 @@ package cn.wisenergy.chnmuseum.party.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
java.util.List
;
/**
/**
* <pre>
* <pre>
* 用户 Mapper 接口
* 用户 Mapper 接口
...
@@ -13,5 +15,7 @@ import cn.wisenergy.chnmuseum.party.model.TUser;
...
@@ -13,5 +15,7 @@ import cn.wisenergy.chnmuseum.party.model.TUser;
*/
*/
public
interface
TUserMapper
extends
BaseMapper
<
TUser
>
{
public
interface
TUserMapper
extends
BaseMapper
<
TUser
>
{
TUser
selectByUsername
(
String
username
);
TUser
selectByUsername
(
String
userName
);
List
<
TUser
>
selectList
(
String
userName
);
}
}
src/main/java/cn/wisenergy/chnmuseum/party/model/Role.java
View file @
2c27db79
...
@@ -18,7 +18,7 @@ import java.util.List;
...
@@ -18,7 +18,7 @@ import java.util.List;
* @author 杨智平
* @author 杨智平
* @since 2018-08-02
* @since 2018-08-02
*/
*/
@TableName
(
"role"
)
@TableName
(
"
t_
role"
)
public
class
Role
extends
Model
<
Role
>
{
public
class
Role
extends
Model
<
Role
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
...
src/main/java/cn/wisenergy/chnmuseum/party/model/TUser.java
View file @
2c27db79
...
@@ -90,7 +90,7 @@ public class TUser implements Serializable {
...
@@ -90,7 +90,7 @@ public class TUser implements Serializable {
@TableField
(
"exired_date"
)
@TableField
(
"exired_date"
)
private
LocalDate
exiredDate
;
private
LocalDate
exiredDate
;
@ApiModelProperty
(
"状态"
)
@ApiModelProperty
(
"状态
1.启用 2.禁用
"
)
@TableField
(
"status"
)
@TableField
(
"status"
)
private
String
status
;
private
String
status
;
...
@@ -122,7 +122,7 @@ public class TUser implements Serializable {
...
@@ -122,7 +122,7 @@ public class TUser implements Serializable {
@TableField
(
"type"
)
@TableField
(
"type"
)
private
String
type
;
private
String
type
;
@ApiModelProperty
(
"审核状态 1.
通过 2.待初审 3.待复审 4.已驳回
"
)
@ApiModelProperty
(
"审核状态 1.
待初审 2.已驳回 3.待复审 4.通过
"
)
@TableField
(
"audit_status"
)
@TableField
(
"audit_status"
)
private
String
auditStatus
;
private
String
auditStatus
;
...
...
src/main/java/cn/wisenergy/chnmuseum/party/service/TOrganService.java
View file @
2c27db79
...
@@ -16,4 +16,6 @@ import java.util.List;
...
@@ -16,4 +16,6 @@ import java.util.List;
public
interface
TOrganService
extends
IService
<
TOrgan
>
{
public
interface
TOrganService
extends
IService
<
TOrgan
>
{
List
<
TOrgan
>
getTree
();
List
<
TOrgan
>
getTree
();
boolean
batchUpload
(
List
excelList
);
}
}
src/main/java/cn/wisenergy/chnmuseum/party/service/TUserService.java
View file @
2c27db79
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
;
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
/**
...
@@ -13,5 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
...
@@ -13,5 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
*/
public
interface
TUserService
extends
IService
<
TUser
>
{
public
interface
TUserService
extends
IService
<
TUser
>
{
TUser
selectByUsername
(
String
username
);
TUser
selectByUsername
(
String
userName
);
Page
<
TUser
>
selectList
(
Page
<
TUser
>
page
,
String
userName
);
}
}
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/RunLogServiceImpl.java
View file @
2c27db79
...
@@ -6,6 +6,8 @@ import cn.wisenergy.chnmuseum.party.service.RunLogService;
...
@@ -6,6 +6,8 @@ import cn.wisenergy.chnmuseum.party.service.RunLogService;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
/**
/**
* <p>
* <p>
* 服务实现类
* 服务实现类
...
@@ -17,4 +19,12 @@ import org.springframework.stereotype.Service;
...
@@ -17,4 +19,12 @@ import org.springframework.stereotype.Service;
@Service
@Service
public
class
RunLogServiceImpl
extends
ServiceImpl
<
RunLogMapper
,
RunLog
>
implements
RunLogService
{
public
class
RunLogServiceImpl
extends
ServiceImpl
<
RunLogMapper
,
RunLog
>
implements
RunLogService
{
@Resource
private
RunLogMapper
runLogMapper
;
public
boolean
insertRunLog
(
RunLog
runLog
){
boolean
save
=
save
(
runLog
);
return
save
;
}
}
}
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/TOrganServiceImpl.java
View file @
2c27db79
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
.
impl
;
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
.
impl
;
import
cn.wisenergy.chnmuseum.party.common.util.DateUtil80
;
import
cn.wisenergy.chnmuseum.party.model.TOrgan
;
import
cn.wisenergy.chnmuseum.party.model.TOrgan
;
import
cn.wisenergy.chnmuseum.party.mapper.TOrganMapper
;
import
cn.wisenergy.chnmuseum.party.mapper.TOrganMapper
;
import
cn.wisenergy.chnmuseum.party.service.TOrganService
;
import
cn.wisenergy.chnmuseum.party.service.TOrganService
;
...
@@ -8,13 +10,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...
@@ -8,13 +10,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.*
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -50,4 +49,45 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme
...
@@ -50,4 +49,45 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme
list
=
list
.
stream
().
filter
(
o
->
o
.
getLevel
()
==
1
).
collect
(
Collectors
.
toList
());
list
=
list
.
stream
().
filter
(
o
->
o
.
getLevel
()
==
1
).
collect
(
Collectors
.
toList
());
return
list
;
return
list
;
}
}
@Override
public
boolean
batchUpload
(
List
excelList
)
{
boolean
flag
=
false
;
List
<
TOrgan
>
list
=
new
ArrayList
<>();
List
<
TOrgan
>
list1
=
list
();
HashMap
<
String
,
TOrgan
>
map1
=
new
HashMap
<>();
list1
.
stream
().
forEach
(
o
->
map1
.
put
(
o
.
getName
(),
o
));
HashMap
<
String
,
Integer
>
area
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
mapList
=
organMapper
.
selectArea
();
mapList
.
stream
().
forEach
(
m
->
area
.
put
(
m
.
get
(
"name"
).
toString
(),
Integer
.
valueOf
(
m
.
get
(
"id"
).
toString
())));
for
(
int
i
=
0
;
i
<
excelList
.
size
();
i
++)
{
Map
<
String
,
String
>
map
=
null
;
map
=
(
Map
<
String
,
String
>)
excelList
.
get
(
i
);
TOrgan
organ
=
new
TOrgan
();
organ
.
setName
(
map
.
get
(
"名称"
));
String
parent
=
map
.
get
(
"上级机构"
);
if
(
map1
.
get
(
parent
)==
null
){
organ
.
setParentId
(
"0"
);
organ
.
setLevel
(
1
);
}
else
{
organ
.
setParentId
(
map1
.
get
(
parent
).
getId
());
organ
.
setLevel
(
map1
.
get
(
parent
).
getLevel
()+
1
);
}
organ
.
setProvince
(
area
.
get
(
map
.
get
(
"省"
)+
"P"
));
organ
.
setCity
(
area
.
get
(
map
.
get
(
"市"
)+
"C"
));
organ
.
setCountry
(
area
.
get
(
map
.
get
(
"县"
)+
"T"
));
organ
.
setIcon
(
map
.
get
(
"icon"
));
organ
.
setRemarks
(
map
.
get
(
"备注"
));
organ
.
setIsDeleted
(
false
);
organ
.
setCreateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
organ
.
setUpdateTime
(
LocalDateTime
.
now
());
list
.
add
(
organ
);
}
flag
=
saveBatch
(
list
);
return
flag
;
}
}
}
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/TUserServiceImpl.java
View file @
2c27db79
...
@@ -3,6 +3,7 @@ package cn.wisenergy.chnmuseum.party.service.impl;
...
@@ -3,6 +3,7 @@ package cn.wisenergy.chnmuseum.party.service.impl;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.mapper.TUserMapper
;
import
cn.wisenergy.chnmuseum.party.mapper.TUserMapper
;
import
cn.wisenergy.chnmuseum.party.service.TUserService
;
import
cn.wisenergy.chnmuseum.party.service.TUserService
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -28,7 +29,12 @@ public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements
...
@@ -28,7 +29,12 @@ public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements
private
TUserMapper
tUserMapper
;
private
TUserMapper
tUserMapper
;
@Override
@Override
public
TUser
selectByUsername
(
String
username
)
{
public
TUser
selectByUsername
(
String
userName
)
{
return
tUserMapper
.
selectByUsername
(
username
);
return
tUserMapper
.
selectByUsername
(
userName
);
}
@Override
public
Page
<
TUser
>
selectList
(
Page
<
TUser
>
page
,
String
userName
)
{
return
page
.
setRecords
(
tUserMapper
.
selectList
(
userName
));
}
}
}
}
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/LoginController.java
View file @
2c27db79
...
@@ -32,10 +32,7 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -32,10 +32,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.LinkedHashMap
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
/**
...
@@ -165,14 +162,17 @@ public class LoginController {
...
@@ -165,14 +162,17 @@ public class LoginController {
}
}
//获取当前用户角色拥有菜单
//获取当前用户角色拥有菜单
List
<
Menu
>
userMenuPerms
=
this
.
menuService
.
getUserMenuPerms
(
roles
);
List
<
Menu
>
userMenuPerms
=
new
ArrayList
<>();
if
(
roles
.
size
()
>
0
)
{
userMenuPerms
=
this
.
menuService
.
getUserMenuPerms
(
roles
);
}
//登录时插入系统日志
//登录时插入系统日志
String
operationContent
=
username
+
"登录本系统"
;
String
operationContent
=
username
+
"登录本系统"
;
if
(
user
.
getOrgName
()
!=
null
)
{
if
(
user
.
getOrgName
()
!=
null
)
{
operationContent
+=
",机构"
+
user
.
getOrgName
();
operationContent
+=
",机构"
+
user
.
getOrgName
();
}
}
this
.
sysLogController
.
insertSysLog
(
operationContent
,
username
);
this
.
sysLogController
.
insertSysLog
(
operationContent
,
username
,
user
.
getId
()
);
String
token
=
JwtTokenUtil
.
sign
(
username
,
user
.
getId
());
String
token
=
JwtTokenUtil
.
sign
(
username
,
user
.
getId
());
// 将token信息存入Redis
// 将token信息存入Redis
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/SysLogController.java
View file @
2c27db79
...
@@ -2,7 +2,9 @@ package cn.wisenergy.chnmuseum.party.web.controller;
...
@@ -2,7 +2,9 @@ package cn.wisenergy.chnmuseum.party.web.controller;
import
cn.wisenergy.chnmuseum.party.common.util.DateUtil80
;
import
cn.wisenergy.chnmuseum.party.common.util.DateUtil80
;
import
cn.wisenergy.chnmuseum.party.common.util.NetWorkUtil
;
import
cn.wisenergy.chnmuseum.party.common.util.NetWorkUtil
;
import
cn.wisenergy.chnmuseum.party.model.RunLog
;
import
cn.wisenergy.chnmuseum.party.model.SysLog
;
import
cn.wisenergy.chnmuseum.party.model.SysLog
;
import
cn.wisenergy.chnmuseum.party.service.impl.RunLogServiceImpl
;
import
cn.wisenergy.chnmuseum.party.service.impl.SysLogServiceImpl
;
import
cn.wisenergy.chnmuseum.party.service.impl.SysLogServiceImpl
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
@@ -30,12 +32,15 @@ public class SysLogController extends BaseController {
...
@@ -30,12 +32,15 @@ public class SysLogController extends BaseController {
@Resource
@Resource
private
SysLogServiceImpl
sysLogService
;
private
SysLogServiceImpl
sysLogService
;
@Resource
private
RunLogServiceImpl
runLogService
;
/**
/**
* 插入系统日志表
* 插入系统日志表
*/
*/
@ApiOperation
(
value
=
"插入系统日志"
,
notes
=
"插入系统日志"
)
@ApiOperation
(
value
=
"插入系统日志"
,
notes
=
"插入系统日志"
)
@PostMapping
(
value
=
"/insertSysLog"
)
@PostMapping
(
value
=
"/insertSysLog"
)
public
Boolean
insertSysLog
(
String
operationContent
,
String
username
)
{
public
Boolean
insertSysLog
(
String
operationContent
,
String
username
,
String
id
)
{
SysLog
sysLog
=
new
SysLog
();
SysLog
sysLog
=
new
SysLog
();
//日志时间
//日志时间
sysLog
.
setOperationTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
sysLog
.
setOperationTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
...
@@ -50,6 +55,11 @@ public class SysLogController extends BaseController {
...
@@ -50,6 +55,11 @@ public class SysLogController extends BaseController {
}
else
{
}
else
{
sysLog
.
setOperator
(
username
);
sysLog
.
setOperator
(
username
);
}
}
if
(
"1"
.
equals
(
id
))
{
sysLog
.
setType
(
1
);
}
else
{
sysLog
.
setType
(
2
);
}
//日志内容
//日志内容
sysLog
.
setOperationContent
(
operationContent
);
sysLog
.
setOperationContent
(
operationContent
);
sysLog
.
setOperationObject
(
"登录管理"
);
sysLog
.
setOperationObject
(
"登录管理"
);
...
@@ -80,5 +90,15 @@ public class SysLogController extends BaseController {
...
@@ -80,5 +90,15 @@ public class SysLogController extends BaseController {
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
null
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
null
);
}
}
/**
* 插入机顶盒日志表
*/
@ApiOperation
(
value
=
"插入系统日志"
,
notes
=
"插入系统日志"
)
@PostMapping
(
value
=
"/insertRunLog"
)
public
Boolean
insertRunLog
(
RunLog
runLog
)
{
boolean
b
=
runLogService
.
insertRunLog
(
runLog
);
return
b
;
}
}
}
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TOrganController.java
View file @
2c27db79
...
@@ -4,6 +4,7 @@ import cn.wisenergy.chnmuseum.party.common.log.MethodLog;
...
@@ -4,6 +4,7 @@ import cn.wisenergy.chnmuseum.party.common.log.MethodLog;
import
cn.wisenergy.chnmuseum.party.common.log.OperModule
;
import
cn.wisenergy.chnmuseum.party.common.log.OperModule
;
import
cn.wisenergy.chnmuseum.party.common.log.OperType
;
import
cn.wisenergy.chnmuseum.party.common.log.OperType
;
import
cn.wisenergy.chnmuseum.party.common.util.DateUtil80
;
import
cn.wisenergy.chnmuseum.party.common.util.DateUtil80
;
import
cn.wisenergy.chnmuseum.party.common.util.ImportExcelUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
...
@@ -26,13 +27,20 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -26,13 +27,20 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.SystemUtils
;
import
org.apache.commons.lang3.SystemUtils
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.shiro.authz.annotation.RequiresAuthentication
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -57,7 +65,7 @@ public class TOrganController extends BaseController {
...
@@ -57,7 +65,7 @@ public class TOrganController extends BaseController {
@PostMapping
(
"/add"
)
@PostMapping
(
"/add"
)
@RequiresPermissions
(
"/organ/add"
)
@RequiresPermissions
(
"/organ/add"
)
@ApiOperation
(
value
=
"添加机构"
,
notes
=
"添加机构"
)
@ApiOperation
(
value
=
"添加机构"
,
notes
=
"添加机构"
)
@MethodLog
(
operModule
=
OperModule
.
机构管理
,
operType
=
OperType
.
添加
)
@MethodLog
(
operModule
=
OperModule
.
ORG
,
operType
=
OperType
.
ADD
)
public
Map
<
String
,
Object
>
add
(
TOrgan
organ
)
{
public
Map
<
String
,
Object
>
add
(
TOrgan
organ
)
{
organ
.
setCreateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
organ
.
setCreateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
organ
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
organ
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
...
@@ -75,7 +83,7 @@ public class TOrganController extends BaseController {
...
@@ -75,7 +83,7 @@ public class TOrganController extends BaseController {
@PutMapping
(
"/update"
)
@PutMapping
(
"/update"
)
@RequiresPermissions
(
"/organ/update"
)
@RequiresPermissions
(
"/organ/update"
)
@ApiOperation
(
value
=
"update"
,
notes
=
"修改机构信息"
)
@ApiOperation
(
value
=
"update"
,
notes
=
"修改机构信息"
)
@MethodLog
(
operModule
=
OperModule
.
机构管理
,
operType
=
OperType
.
修改
)
@MethodLog
(
operModule
=
OperModule
.
ORG
,
operType
=
OperType
.
UPDATE
)
public
Map
<
String
,
Object
>
updateTOrgan
(
TOrgan
tOrgan
)
{
public
Map
<
String
,
Object
>
updateTOrgan
(
TOrgan
tOrgan
)
{
tOrgan
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
tOrgan
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
boolean
flag
=
tOrganService
.
updateById
(
tOrgan
);
boolean
flag
=
tOrganService
.
updateById
(
tOrgan
);
...
@@ -85,28 +93,11 @@ public class TOrganController extends BaseController {
...
@@ -85,28 +93,11 @@ public class TOrganController extends BaseController {
return
getFailResult
();
return
getFailResult
();
}
}
// @PutMapping("/updateAuditStatus")
// @RequiresPermissions("/organ/updateAuditStatus")
// @ApiOperation(value = "更新机构审核状态", notes = "更新机构审核状态")
// @ApiImplicitParams(value = {
// @ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path"),
// @ApiImplicitParam(name = "status", value = "状态", paramType = "query", dataType = "String")
// })
// public Map<String, Object> updateStatus(@NotNull(message = "机构ID不能为空") @PathVariable("id") String id, @RequestParam("status") AuditStatusEnum status) {
// UpdateWrapper<TOrgan> updateWrapper = new UpdateWrapper<>();
// updateWrapper.eq("id", id);
// updateWrapper.eq("audit_status", status.name());
// boolean flag = tOrganService.update(updateWrapper);
// if (flag) {
// return getSuccessResult();
// }
// return getFailResult();
// }
@DeleteMapping
(
"/delete"
)
@DeleteMapping
(
"/delete"
)
@RequiresPermissions
(
"/organ/delete"
)
@RequiresPermissions
(
"/organ/delete"
)
@ApiOperation
(
value
=
"根据ID删除机构"
,
notes
=
"根据ID删除机构"
)
@ApiOperation
(
value
=
"根据ID删除机构"
,
notes
=
"根据ID删除机构"
)
@MethodLog
(
operModule
=
OperModule
.
机构管理
,
operType
=
OperType
.
删除
)
@MethodLog
(
operModule
=
OperModule
.
ORG
,
operType
=
OperType
.
DELETE
)
@ApiImplicitParams
(
value
=
{
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"id"
,
value
=
"标识ID"
,
paramType
=
"path"
,
dataType
=
"String"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"标识ID"
,
paramType
=
"path"
,
dataType
=
"String"
)
})
})
...
@@ -125,12 +116,14 @@ public class TOrganController extends BaseController {
...
@@ -125,12 +116,14 @@ public class TOrganController extends BaseController {
@GetMapping
(
"/getList"
)
@GetMapping
(
"/getList"
)
@RequiresPermissions
(
"/organ/getList"
)
@RequiresPermissions
(
"/organ/getList"
)
@ApiOperation
(
value
=
"获取机构全部列表(无分页)"
,
notes
=
"获取机构全部列表(无分页)"
)
@ApiOperation
(
value
=
"获取机构全部列表(无分页)"
,
notes
=
"获取机构全部列表(无分页)"
)
@MethodLog
(
operModule
=
OperModule
.
机构管理
,
operType
=
OperType
.
查询
)
@MethodLog
(
operModule
=
OperModule
.
ORG
,
operType
=
OperType
.
SELECT
)
public
Map
<
String
,
Object
>
getTOrganList
()
{
public
Map
<
String
,
Object
>
getTOrganList
()
{
List
<
TOrgan
>
tOrganList
=
tOrganService
.
list
(
Wrappers
.<
TOrgan
>
lambdaQuery
().
eq
(
TOrgan:
:
getIsDeleted
,
0
));
List
<
TOrgan
>
tOrganList
=
tOrganService
.
list
(
Wrappers
.<
TOrgan
>
lambdaQuery
().
eq
(
TOrgan:
:
getIsDeleted
,
0
));
return
getResult
(
tOrganList
);
return
getResult
(
tOrganList
);
}
}
@ApiImplicitParams
(
value
=
{
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"_index"
,
value
=
"分页起始偏移量"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"_index"
,
value
=
"分页起始偏移量"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"_size"
,
value
=
"返回条数"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
@ApiImplicitParam
(
name
=
"_size"
,
value
=
"返回条数"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
...
@@ -141,7 +134,7 @@ public class TOrganController extends BaseController {
...
@@ -141,7 +134,7 @@ public class TOrganController extends BaseController {
@PostMapping
(
"/getPageList"
)
@PostMapping
(
"/getPageList"
)
@RequiresPermissions
(
"/organ/getPageList"
)
@RequiresPermissions
(
"/organ/getPageList"
)
@ApiOperation
(
value
=
"获取机构分页列表"
,
notes
=
"获取机构分页列表"
)
@ApiOperation
(
value
=
"获取机构分页列表"
,
notes
=
"获取机构分页列表"
)
@MethodLog
(
operModule
=
OperModule
.
机构管理
,
operType
=
OperType
.
查询
)
@MethodLog
(
operModule
=
OperModule
.
ORG
,
operType
=
OperType
.
SELECT
)
public
Map
<
String
,
Object
>
getTOrganPageList
(
GenericPageParam
genericPageParam
)
{
public
Map
<
String
,
Object
>
getTOrganPageList
(
GenericPageParam
genericPageParam
)
{
LambdaQueryWrapper
<
TOrgan
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
TOrgan
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
// 对名称或编码模糊查询
// 对名称或编码模糊查询
...
@@ -162,7 +155,7 @@ public class TOrganController extends BaseController {
...
@@ -162,7 +155,7 @@ public class TOrganController extends BaseController {
@ApiOperation
(
value
=
"获取机构详情"
,
notes
=
"获取机构详情"
)
@ApiOperation
(
value
=
"获取机构详情"
,
notes
=
"获取机构详情"
)
@GetMapping
(
"/getById"
)
@GetMapping
(
"/getById"
)
@RequiresPermissions
(
"/organ/getById"
)
@RequiresPermissions
(
"/organ/getById"
)
@MethodLog
(
operModule
=
OperModule
.
机构管理
,
operType
=
OperType
.
查询
)
@MethodLog
(
operModule
=
OperModule
.
ORG
,
operType
=
OperType
.
SELECT
)
public
Map
<
String
,
Object
>
getById
(
String
id
)
{
public
Map
<
String
,
Object
>
getById
(
String
id
)
{
TOrgan
tOrgan
=
tOrganService
.
getById
(
id
);
TOrgan
tOrgan
=
tOrganService
.
getById
(
id
);
return
getResult
(
tOrgan
);
return
getResult
(
tOrgan
);
...
@@ -172,10 +165,43 @@ public class TOrganController extends BaseController {
...
@@ -172,10 +165,43 @@ public class TOrganController extends BaseController {
@GetMapping
(
"/getTree"
)
@GetMapping
(
"/getTree"
)
@RequiresPermissions
(
"/organ/getTree"
)
@RequiresPermissions
(
"/organ/getTree"
)
@ApiOperation
(
value
=
"获取机构树"
,
notes
=
"获取机构树"
)
@ApiOperation
(
value
=
"获取机构树"
,
notes
=
"获取机构树"
)
@MethodLog
(
operModule
=
OperModule
.
机构管理
,
operType
=
OperType
.
查询
)
@MethodLog
(
operModule
=
OperModule
.
ORG
,
operType
=
OperType
.
SELECT
)
public
Map
<
String
,
Object
>
getTree
()
{
public
Map
<
String
,
Object
>
getTree
(
String
name
)
{
List
<
TOrgan
>
tOrganList
=
tOrganService
.
getTree
();
List
<
TOrgan
>
list
=
new
ArrayList
<>();
return
getResult
(
tOrganList
);
if
(
StringUtils
.
isBlank
(
name
))
{
list
=
tOrganService
.
getTree
();
}
else
{
list
=
tOrganService
.
list
(
new
UpdateWrapper
<
TOrgan
>().
like
(
"name"
,
name
));
}
return
getResult
(
list
);
}
// 导入EXCEL
@ApiOperation
(
value
=
"导入EXCEL"
,
notes
=
"导入EXCEL"
,
httpMethod
=
"POST"
)
@RequestMapping
(
value
=
"/import"
,
method
=
RequestMethod
.
POST
)
@RequiresPermissions
(
"/organ/import"
)
@MethodLog
(
operModule
=
OperModule
.
ORG
,
operType
=
OperType
.
IMPORT
)
public
ResponseEntity
<
Map
>
upload
(
MultipartFile
file
)
{
Map
<
String
,
Object
>
resultMap
=
new
LinkedHashMap
<
String
,
Object
>();
try
{
boolean
flag
=
false
;
//使用工具类从文件中读取数据
List
excelList
=
ImportExcelUtil
.
readExcel
(
file
.
getOriginalFilename
(),
file
.
getInputStream
());
flag
=
tOrganService
.
batchUpload
(
excelList
);
if
(!
flag
)
{
resultMap
.
put
(
"status"
,
500
);
resultMap
.
put
(
"massage"
,
"导入失败!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
resultMap
.
put
(
"status"
,
200
);
resultMap
.
put
(
"massage"
,
"导入成功!"
);
return
ResponseEntity
.
ok
(
resultMap
);
}
catch
(
Exception
e
)
{
resultMap
.
put
(
"status"
,
500
);
resultMap
.
put
(
"massage"
,
"导入失败!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
}
}
}
}
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TUserController.java
View file @
2c27db79
...
@@ -2,24 +2,26 @@ package cn.wisenergy.chnmuseum.party.web.controller;
...
@@ -2,24 +2,26 @@ package cn.wisenergy.chnmuseum.party.web.controller;
import
cn.wisenergy.chnmuseum.party.auth.SHA256PasswordEncryptionService
;
import
cn.wisenergy.chnmuseum.party.auth.SHA256PasswordEncryptionService
;
import
cn.wisenergy.chnmuseum.party.auth.SecureRandomSaltService
;
import
cn.wisenergy.chnmuseum.party.auth.SecureRandomSaltService
;
import
cn.wisenergy.chnmuseum.party.common.enums.AuditStatusEnum
;
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.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.core.annotations.OperationLog
;
import
cn.wisenergy.chnmuseum.party.model.Role
;
import
cn.wisenergy.chnmuseum.party.model.Role
;
import
cn.wisenergy.chnmuseum.party.model.TOrgan
;
import
cn.wisenergy.chnmuseum.party.model.TUserRole
;
import
cn.wisenergy.chnmuseum.party.model.TUserRole
;
import
cn.wisenergy.chnmuseum.party.service.RoleService
;
import
cn.wisenergy.chnmuseum.party.service.TUserRoleService
;
import
cn.wisenergy.chnmuseum.party.service.TUserRoleService
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.service.TUserService
;
import
cn.wisenergy.chnmuseum.party.service.TUserService
;
import
cn.wisenergy.chnmuseum.party.common.enums.AuditStatusEnum
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Add
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Update
;
import
cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
...
@@ -32,11 +34,8 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
...
@@ -32,11 +34,8 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.stereotype.Controller
;
import
sun.security.util.Password
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
...
@@ -62,226 +61,281 @@ public class TUserController extends BaseController {
...
@@ -62,226 +61,281 @@ public class TUserController extends BaseController {
@Resource
@Resource
private
TUserRoleService
tUserRoleService
;
private
TUserRoleService
tUserRoleService
;
@Resource
private
RoleService
roleService
;
@Resource
@Resource
private
StringRedisTemplate
stringRedisTemplate
;
private
StringRedisTemplate
stringRedisTemplate
;
private
static
final
String
SHIRO_JWT_TOKEN
=
"shiro:jwt:token"
;
private
static
final
String
SHIRO_JWT_TOKEN
=
"shiro:jwt:token"
;
//用户登录是否被锁定 一小时 redisKey 前缀
//用户登录是否被锁定 一小时 redisKey 前缀
private
String
SHIRO_IS_LOCK
=
"shiro_is_lock_"
;
private
String
SHIRO_IS_LOCK
=
"shiro_is_lock_"
;
// /**
/**
// * 查询成员列表
* 查询成员列表
// *
*
// * @param employName (用户名称,账号,手机号,角色名称有一个满足即可返回值)
* @param userName (用户名称)
// * @return
* @return
// */
*/
// @ApiOperation(value = "查询成员列表")
@ApiOperation
(
value
=
"查询成员列表"
)
// @RequestMapping(value = "/getUserList", method = RequestMethod.GET)
@RequestMapping
(
value
=
"/getUserList"
,
method
=
RequestMethod
.
GET
)
// @RequiresPermissions("/user/getUserList")
@RequiresPermissions
(
"/user/getUserList"
)
// public ResponseEntity<Page<TUser>> queryUserList(String employName) {
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
SELECT
)
// try {
public
ResponseEntity
<
Page
<
TUser
>>
queryUserList
(
String
userName
)
{
// employName = StringUtils.trimToNull(employName);
try
{
// Page<TUser> page = getPage();
userName
=
StringUtils
.
trimToNull
(
userName
);
// Page<TUser> userPage = userService.selectRolenameList(page, employName);
Page
<
TUser
>
page
=
getPage
();
// return ResponseEntity.ok(userPage);
Page
<
TUser
>
userPage
=
userService
.
selectList
(
page
,
userName
);
// } catch (Exception e) {
return
ResponseEntity
.
ok
(
userPage
);
// logger.error("查询成员列表出错!", e);
}
catch
(
Exception
e
)
{
// }
logger
.
error
(
"查询成员列表出错!"
,
e
);
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
// }
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
null
);
//
}
// //新增
// @OperationLog("新增成员")
@ApiImplicitParams
(
value
=
{
// @ApiOperation(value = "新增成员")
@ApiImplicitParam
(
name
=
"_index"
,
value
=
"分页起始偏移量"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
// @RequestMapping(value = "/add", method = RequestMethod.POST)
@ApiImplicitParam
(
name
=
"_size"
,
value
=
"返回条数"
,
paramType
=
"query"
,
dataType
=
"Integer"
),
// @RequiresPermissions("/user/add")
@ApiImplicitParam
(
name
=
"nameOrCode"
,
value
=
"名称或编码"
,
paramType
=
"query"
,
dataType
=
"String"
),
// public ResponseEntity<Map<String, Object>> add(@RequestBody TUser user) {
@ApiImplicitParam
(
name
=
"startDate"
,
value
=
"创建时间-开始"
,
paramType
=
"query"
,
dataType
=
"String"
),
// Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
@ApiImplicitParam
(
name
=
"endDate"
,
value
=
"创建时间-结束"
,
paramType
=
"query"
,
dataType
=
"String"
)
// try {
})
// if (StringUtils.isBlank(user.getUserName())) {
@PostMapping
(
"/getPageList"
)
// resultMap.put("status", 400);
@RequiresPermissions
(
"/user/getPageList"
)
// resultMap.put("message", "账号不能为空!");
@ApiOperation
(
value
=
"获取用户分页列表"
,
notes
=
"获取用户分页列表"
)
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
SELECT
)
// } else {
public
Map
<
String
,
Object
>
getPageList
(
GenericPageParam
genericPageParam
)
{
// user.setUserName(StringUtils.trimToNull(user.getUserName()));
LambdaQueryWrapper
<
TUser
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
// }
// 对名称或编码模糊查询
// if (StringUtils.isBlank(user.getPassword())) {
if
(
StringUtils
.
isNotBlank
(
genericPageParam
.
getNameOrCode
()))
{
// resultMap.put("status", 400);
queryWrapper
.
like
(
TUser:
:
getUserName
,
genericPageParam
.
getNameOrCode
());
// resultMap.put("message", "密码不能为空!");
}
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
// 根据创建时间区间检索
// } else {
if
(
genericPageParam
.
getStartDate
()
!=
null
&&
genericPageParam
.
getEndDate
()
!=
null
)
{
// user.setPassword(StringUtils.trimToNull(user.getPassword()));
queryWrapper
.
ge
(
TUser:
:
getCreateTime
,
genericPageParam
.
getStartDate
().
atTime
(
0
,
0
,
0
))
// }
.
le
(
TUser:
:
getCreateTime
,
genericPageParam
.
getEndDate
().
atTime
(
23
,
59
,
59
));
// if (StringUtils.isBlank(user.getRealName())) {
}
// resultMap.put("status", 400);
// 设置排序规则
// resultMap.put("message", "姓名不能为空!");
queryWrapper
.
orderByDesc
(
TUser:
:
getCreateTime
);
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
Page
<
TUser
>
page
=
userService
.
page
(
getPage
(),
queryWrapper
);
// } else {
return
getResult
(
page
);
// user.setRealName(StringUtils.trimToNull(user.getRealName()));
}
// }
//
// if (user.getRoleList()==null||user.getRoleList().size()<1) {
@ApiOperation
(
value
=
"获取用户详情"
,
notes
=
"获取用户详情"
)
// resultMap.put("status", 400);
@GetMapping
(
"/getById"
)
// resultMap.put("message", "请选择角色!");
@RequiresPermissions
(
"/user/getById"
)
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
SELECT
)
// }
public
Map
<
String
,
Object
>
getById
(
String
id
)
{
// if (StringUtils.isBlank(user.getOrgId())) {
TUser
tUser
=
userService
.
getById
(
id
);
// resultMap.put("status", 400);
List
<
Role
>
list
=
roleService
.
selectRoleByUserId
(
id
);
// resultMap.put("message", "请选择机构!");
tUser
.
setRoleList
(
list
);
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
return
getResult
(
tUser
);
// }
}
//
// QueryWrapper<TUser> ew = new QueryWrapper<>();
//新增
// if (StringUtils.isNoneBlank(user.getUserName())) {
@OperationLog
(
"新增成员"
)
// user.setUserName(user.getUserName().trim());
@ApiOperation
(
value
=
"新增成员"
)
// ew.eq("is_deleted", 0);
@RequestMapping
(
value
=
"/add"
,
method
=
RequestMethod
.
POST
)
// ew.eq("username", user.getUserName());
@RequiresPermissions
(
"/user/add"
)
// TUser one = this.userService.getOne(ew);
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
ADD
)
// if (one != null) {
public
ResponseEntity
<
Map
<
String
,
Object
>>
add
(
@RequestBody
TUser
user
)
{
// resultMap.put("status", 400);
Map
<
String
,
Object
>
resultMap
=
new
LinkedHashMap
<
String
,
Object
>();
// resultMap.put("message", "账号已存在!");
try
{
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
if
(
StringUtils
.
isBlank
(
user
.
getUserName
()))
{
// }
resultMap
.
put
(
"status"
,
400
);
// }
resultMap
.
put
(
"message"
,
"账号不能为空!"
);
//
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
// byte[] passwordSalt = SecureRandomSaltService.generateSalt();
}
else
{
// byte[] passwordHash = SHA256PasswordEncryptionService
user
.
setUserName
(
StringUtils
.
trimToNull
(
user
.
getUserName
()));
// .createPasswordHash(user.getPassword(), passwordSalt);
}
// user.setPasswordSalt(passwordSalt);
if
(
StringUtils
.
isBlank
(
user
.
getPassword
()))
{
// user.setPasswordHash(passwordHash);
resultMap
.
put
(
"status"
,
400
);
// user.setCreateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
resultMap
.
put
(
"message"
,
"密码不能为空!"
);
// user.setUpdateTime(user.getCreateTime());
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
//
}
else
{
// boolean ret = this.userService.save(user);
user
.
setPassword
(
StringUtils
.
trimToNull
(
user
.
getPassword
()));
//
}
// List<Role> list = user.getRoleList();
if
(
StringUtils
.
isBlank
(
user
.
getRealName
()))
{
// List<TUserRole> list1 = new ArrayList<>();
resultMap
.
put
(
"status"
,
400
);
// for (Role role : list) {
resultMap
.
put
(
"message"
,
"姓名不能为空!"
);
// TUserRole entity = new TUserRole();
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
// entity.setUserId(user.getId());
}
else
{
// entity.setRoleId(role.getId());
user
.
setRealName
(
StringUtils
.
trimToNull
(
user
.
getRealName
()));
// entity.setIsDeleted(false);
}
// list1.add(entity);
// }
if
(
user
.
getRoleList
()==
null
||
user
.
getRoleList
().
size
()<
1
)
{
//
resultMap
.
put
(
"status"
,
400
);
// this.tUserRoleService.saveBatch(list1);
resultMap
.
put
(
"message"
,
"请选择角色!"
);
//
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
// if (!ret) {
}
// // 新增失败, 500
if
(
StringUtils
.
isBlank
(
user
.
getOrgId
()))
{
// resultMap.put("status", 500);
resultMap
.
put
(
"status"
,
400
);
// resultMap.put("message", "服务器忙");
resultMap
.
put
(
"message"
,
"请选择机构!"
);
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
// .body(resultMap);
}
// }
// resultMap.put("status", 201);
QueryWrapper
<
TUser
>
ew
=
new
QueryWrapper
<>();
// resultMap.put("message", "添加成功");
if
(
StringUtils
.
isNoneBlank
(
user
.
getUserName
()))
{
// // 201
user
.
setUserName
(
user
.
getUserName
().
trim
());
// return ResponseEntity.status(HttpStatus.CREATED).body(resultMap);
ew
.
eq
(
"is_deleted"
,
0
);
// } catch (Exception e) {
ew
.
eq
(
"user_name"
,
user
.
getUserName
());
// resultMap.put("status", 500);
TUser
one
=
this
.
userService
.
getOne
(
ew
);
// resultMap.put("message", "服务器忙");
if
(
one
!=
null
)
{
// logger.error("新增成员错误!", e);
resultMap
.
put
(
"status"
,
400
);
// }
resultMap
.
put
(
"message"
,
"账号已存在!"
);
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
// }
}
}
//
// // 编辑用户信息
byte
[]
passwordSalt
=
SecureRandomSaltService
.
generateSalt
();
// @OperationLog("修改成员信息")
byte
[]
passwordHash
=
SHA256PasswordEncryptionService
// @ApiOperation(value = "编辑用户信息(必须传 1username 2name 3roleId)")
.
createPasswordHash
(
user
.
getPassword
(),
passwordSalt
);
// @PutMapping(value = "/modify")
user
.
setPasswordSalt
(
passwordSalt
);
// @RequiresPermissions("/user/modify")
user
.
setPasswordHash
(
passwordHash
);
// public ResponseEntity<Map<String, Object>> edit(TUser user) {
user
.
setCreateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
// Map<String, Object> resultMap = new HashMap<>();
user
.
setUpdateTime
(
user
.
getCreateTime
());
// try {
user
.
setIsDeleted
(
false
);
// boolean ret = false;
// if (user.getId() != null) {
boolean
ret
=
this
.
userService
.
save
(
user
);
// if ("1".equals(user.getId()) && user.getStatus() == "2") {
// resultMap.put("status", 400);
List
<
Role
>
list
=
user
.
getRoleList
();
// resultMap.put("message", "该账号不能被禁用");
List
<
TUserRole
>
list1
=
new
ArrayList
<>();
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
for
(
Role
role
:
list
)
{
// }
TUserRole
entity
=
new
TUserRole
();
//
entity
.
setUserId
(
user
.
getId
());
// user.setUserName(StringUtils.trimToNull(user.getUserName()));
entity
.
setRoleId
(
role
.
getId
());
// user.setPassword(StringUtils.trimToNull(user.getPassword()));
entity
.
setIsDeleted
(
false
);
// user.setRealName(StringUtils.trimToNull(user.getRealName()));
list1
.
add
(
entity
);
// user.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
}
// ret = userService.updateById(user);
// //查询当前用户拥有的角色
this
.
tUserRoleService
.
saveBatch
(
list1
);
// QueryWrapper<TUserRole> userRoleWrapper = new QueryWrapper<>();
// userRoleWrapper.eq("user_id", user.getId());
if
(!
ret
)
{
// TUserRole userRole = this.userRoleService.getOne(userRoleWrapper);
// 新增失败, 500
//
resultMap
.
put
(
"status"
,
500
);
// if (userRole != null && user.getRoleId() != null
resultMap
.
put
(
"message"
,
"服务器忙"
);
// && user.getRoleId() != userRole.getRoleId()) {
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
// // 角色有变化即修改角色
.
body
(
resultMap
);
// userRole.setRoleId(user.getRoleId());
}
// userRole.setUpdateTime(user.getUpdateTime());
resultMap
.
put
(
"status"
,
200
);
// ret = this.userRoleService.updateById(userRole);
resultMap
.
put
(
"message"
,
"添加成功"
);
// }
// 201
// } else {
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
resultMap
);
// // 更新失败, 400
}
catch
(
Exception
e
)
{
// resultMap.put("status", 400);
resultMap
.
put
(
"status"
,
500
);
// resultMap.put("message", "请选择用户");
resultMap
.
put
(
"message"
,
"服务器忙"
);
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
logger
.
error
(
"新增成员错误!"
,
e
);
// }
}
//
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
// if (!ret) {
}
// // 更新失败, 500
// resultMap.put("status", 500);
// resultMap.put("message", "服务器忙");
// 编辑用户信息
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
@OperationLog
(
"修改成员信息"
)
// }
@ApiOperation
(
value
=
"编辑用户信息(必须传 1username 2name 3roleId)"
)
// // 204
@PutMapping
(
value
=
"/update"
)
// resultMap.put("status", 201);
@RequiresPermissions
(
"/user/update"
)
// resultMap.put("message", "更新成功");
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
UPDATE
)
// return ResponseEntity.status(HttpStatus.CREATED).body(resultMap);
public
ResponseEntity
<
Map
<
String
,
Object
>>
edit
(
@RequestBody
TUser
user
)
{
// } catch (Exception e) {
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
// logger.error("更新错误!", e);
try
{
// }
boolean
ret
=
false
;
// // 500
if
(
user
.
getId
()
!=
null
)
{
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
if
(
"1"
.
equals
(
user
.
getId
())
&&
user
.
getStatus
()
==
"2"
)
{
// }
resultMap
.
put
(
"status"
,
400
);
resultMap
.
put
(
"message"
,
"该账号不能被禁用"
);
// /**
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
// * 删除
}
// *
// * @param userId
user
.
setUserName
(
StringUtils
.
trimToNull
(
user
.
getUserName
()));
// * @return
user
.
setPassword
(
StringUtils
.
trimToNull
(
user
.
getPassword
()));
// */
user
.
setRealName
(
StringUtils
.
trimToNull
(
user
.
getRealName
()));
// @OperationLog("删除成员")
user
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
// @ApiOperation(value = "删除成员")
ret
=
userService
.
updateById
(
user
);
// @DeleteMapping(value = "/delete")
//查询当前用户拥有的角色
// @RequiresPermissions("/user/delete")
QueryWrapper
<
TUserRole
>
userRoleWrapper
=
new
QueryWrapper
<>();
// public ResponseEntity<Map<String, Object>> delete(String userId) {
userRoleWrapper
.
eq
(
"user_id"
,
user
.
getId
());
// Map<String, Object> resultMap = new HashMap<>();
boolean
remove
=
tUserRoleService
.
remove
(
userRoleWrapper
);
// try {
// if ("1".equals(userId)) {
// resultMap.put("status", 400);
List
<
Role
>
list
=
user
.
getRoleList
();
// resultMap.put("message", "该账号不能被删除");
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
ArrayList
<
TUserRole
>
list1
=
new
ArrayList
<>();
// }
for
(
Role
r
:
list
)
{
// TUser entity = new TUser();
TUserRole
userRole
=
new
TUserRole
();
// entity.setId(userId);
userRole
.
setUserId
(
user
.
getId
());
// entity.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
userRole
.
setRoleId
(
r
.
getId
());
// entity.setIsDeleted(true);
userRole
.
setIsDeleted
(
false
);
// boolean ret1 = this.userService.updateById(entity);
list1
.
add
(
userRole
);
//
}
// QueryWrapper<TUserRole> userRoleWrapper = new QueryWrapper<>();
// userRoleWrapper.eq("user_id", userId);
ret
=
this
.
tUserRoleService
.
saveBatch
(
list1
);
// boolean ret2 = this.userRoleService.remove(userRoleWrapper);
}
//
}
else
{
// if (!ret1 || !ret2) {
// 更新失败, 400
// resultMap.put("status", 400);
resultMap
.
put
(
"status"
,
400
);
// resultMap.put("message", "删除失败");
resultMap
.
put
(
"message"
,
"请选择用户"
);
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resultMap);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
// }
}
// resultMap.put("status", 201);
// resultMap.put("message", "删除成功");
if
(!
ret
)
{
// return ResponseEntity.status(HttpStatus.CREATED).body(resultMap);
// 更新失败, 500
// } catch (Exception e) {
resultMap
.
put
(
"status"
,
500
);
// logger.error("删除用户出错!", e);
resultMap
.
put
(
"message"
,
"服务器忙"
);
// }
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
// }
// 204
resultMap
.
put
(
"status"
,
201
);
resultMap
.
put
(
"message"
,
"更新成功"
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
resultMap
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"更新错误!"
,
e
);
}
// 500
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
build
();
}
/**
* 删除
*
* @param userId
* @return
*/
@OperationLog
(
"删除成员"
)
@ApiOperation
(
value
=
"删除成员"
)
@DeleteMapping
(
value
=
"/delete"
)
@RequiresPermissions
(
"/user/delete"
)
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
DELETE
)
public
ResponseEntity
<
Map
<
String
,
Object
>>
delete
(
String
userId
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
try
{
if
(
"1"
.
equals
(
userId
))
{
resultMap
.
put
(
"status"
,
400
);
resultMap
.
put
(
"message"
,
"该账号不能被删除"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
TUser
entity
=
new
TUser
();
entity
.
setId
(
userId
);
entity
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
entity
.
setIsDeleted
(
true
);
boolean
ret1
=
this
.
userService
.
updateById
(
entity
);
QueryWrapper
<
TUserRole
>
userRoleWrapper
=
new
QueryWrapper
<>();
userRoleWrapper
.
eq
(
"user_id"
,
userId
);
boolean
ret2
=
this
.
tUserRoleService
.
remove
(
userRoleWrapper
);
if
(!
ret1
||
!
ret2
)
{
resultMap
.
put
(
"status"
,
400
);
resultMap
.
put
(
"message"
,
"删除失败"
);
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
body
(
resultMap
);
}
resultMap
.
put
(
"status"
,
201
);
resultMap
.
put
(
"message"
,
"删除成功"
);
return
ResponseEntity
.
status
(
HttpStatus
.
CREATED
).
body
(
resultMap
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"删除用户出错!"
,
e
);
}
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
null
);
}
/**
/**
...
@@ -294,12 +348,15 @@ public class TUserController extends BaseController {
...
@@ -294,12 +348,15 @@ public class TUserController extends BaseController {
@ApiOperation
(
value
=
"禁用"
)
@ApiOperation
(
value
=
"禁用"
)
@RequestMapping
(
value
=
"/disable"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
value
=
"/disable"
,
method
=
RequestMethod
.
PUT
)
@RequiresPermissions
(
"/user/disable"
)
@RequiresPermissions
(
"/user/disable"
)
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
DISABLE
)
public
ResponseEntity
<
Map
<
String
,
Object
>>
disableTUser
(
String
userId
)
{
public
ResponseEntity
<
Map
<
String
,
Object
>>
disableTUser
(
String
userId
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
try
{
try
{
TUser
entity
=
new
TUser
();
TUser
entity
=
new
TUser
();
entity
.
setId
(
userId
);
entity
.
setId
(
userId
);
entity
.
setStatus
(
"2"
);
entity
.
setStatus
(
"2"
);
Integer
code
=
AuditStatusEnum
.
TBC
.
getCode
();
entity
.
setAuditStatus
(
code
.
toString
());
entity
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
entity
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
boolean
ret
=
this
.
userService
.
updateById
(
entity
);
boolean
ret
=
this
.
userService
.
updateById
(
entity
);
...
@@ -329,7 +386,8 @@ public class TUserController extends BaseController {
...
@@ -329,7 +386,8 @@ public class TUserController extends BaseController {
@ApiOperation
(
value
=
"启用"
)
@ApiOperation
(
value
=
"启用"
)
@RequestMapping
(
value
=
"/enable"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
value
=
"/enable"
,
method
=
RequestMethod
.
PUT
)
@RequiresPermissions
(
"/user/enable"
)
@RequiresPermissions
(
"/user/enable"
)
public
ResponseEntity
<
Map
<
String
,
Object
>>
enableUser
(
String
userId
,
String
currBankId
)
{
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
UNABLE
)
public
ResponseEntity
<
Map
<
String
,
Object
>>
enableUser
(
String
userId
)
{
try
{
try
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
...
@@ -358,6 +416,7 @@ public class TUserController extends BaseController {
...
@@ -358,6 +416,7 @@ public class TUserController extends BaseController {
@ApiOperation
(
value
=
"管理员更改自己的登录密码"
,
notes
=
"管理员更改自己的登录密码"
)
@ApiOperation
(
value
=
"管理员更改自己的登录密码"
,
notes
=
"管理员更改自己的登录密码"
)
@RequestMapping
(
value
=
"/editPwd"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
value
=
"/editPwd"
,
method
=
RequestMethod
.
PUT
)
@RequiresPermissions
(
"/user/editPwd"
)
@RequiresPermissions
(
"/user/editPwd"
)
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
UPDATE
)
public
ResponseEntity
<
Map
<
String
,
Object
>>
editPwd
(
@RequestParam
(
value
=
"oldPassWord"
,
required
=
true
)
String
oldPassWord
,
public
ResponseEntity
<
Map
<
String
,
Object
>>
editPwd
(
@RequestParam
(
value
=
"oldPassWord"
,
required
=
true
)
String
oldPassWord
,
@RequestParam
(
value
=
"password"
,
required
=
true
)
String
password
)
{
@RequestParam
(
value
=
"password"
,
required
=
true
)
String
password
)
{
Map
<
String
,
Object
>
resultMap
=
new
LinkedHashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
resultMap
=
new
LinkedHashMap
<
String
,
Object
>();
...
@@ -396,13 +455,6 @@ public class TUserController extends BaseController {
...
@@ -396,13 +455,6 @@ public class TUserController extends BaseController {
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
}
@ApiOperation
(
value
=
"获取用户详情"
,
notes
=
"获取用户详情"
)
@GetMapping
(
"/getById"
)
@RequiresPermissions
(
"/user/getById"
)
public
Map
<
String
,
Object
>
getById
(
String
id
)
{
TUser
tUser
=
userService
.
getById
(
id
);
return
getResult
(
tUser
);
}
// 管理员重置密码
// 管理员重置密码
...
@@ -410,12 +462,13 @@ public class TUserController extends BaseController {
...
@@ -410,12 +462,13 @@ public class TUserController extends BaseController {
@ApiOperation
(
value
=
"管理员重置密码"
,
notes
=
"管理员重置密码"
)
@ApiOperation
(
value
=
"管理员重置密码"
,
notes
=
"管理员重置密码"
)
@RequestMapping
(
value
=
"/resetPassword"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
value
=
"/resetPassword"
,
method
=
RequestMethod
.
PUT
)
@RequiresPermissions
(
"/user/resetPassword"
)
@RequiresPermissions
(
"/user/resetPassword"
)
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
UPDATE
)
public
ResponseEntity
<
Map
<
Object
,
String
>>
resetPassword
(
String
userId
)
{
public
ResponseEntity
<
Map
<
Object
,
String
>>
resetPassword
(
String
userId
)
{
try
{
try
{
Map
<
Object
,
String
>
map
=
new
LinkedHashMap
<>();
Map
<
Object
,
String
>
map
=
new
LinkedHashMap
<>();
TUser
user
=
new
TUser
();
TUser
user
=
new
TUser
();
user
.
setId
(
userId
);
user
.
setId
(
userId
);
String
newPassword
=
RandomUtil
.
createRandom
(
6
)
;
String
newPassword
=
"123456"
;
byte
[]
passwordSalt
=
SecureRandomSaltService
.
generateSalt
();
byte
[]
passwordSalt
=
SecureRandomSaltService
.
generateSalt
();
byte
[]
passwordHash
=
SHA256PasswordEncryptionService
.
createPasswordHash
(
newPassword
,
passwordSalt
);
byte
[]
passwordHash
=
SHA256PasswordEncryptionService
.
createPasswordHash
(
newPassword
,
passwordSalt
);
user
.
setPasswordSalt
(
passwordSalt
);
user
.
setPasswordSalt
(
passwordSalt
);
...
@@ -436,5 +489,26 @@ public class TUserController extends BaseController {
...
@@ -436,5 +489,26 @@ public class TUserController extends BaseController {
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
null
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
null
);
}
}
@PutMapping
(
"/updateAuditStatus"
)
@RequiresPermissions
(
"/user/updateAuditStatus"
)
@ApiOperation
(
value
=
"更新用户审核状态"
,
notes
=
"更新用户审核状态"
)
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"id"
,
value
=
"标识ID"
,
dataType
=
"String"
,
paramType
=
"path"
),
@ApiImplicitParam
(
name
=
"status"
,
value
=
"状态"
,
paramType
=
"query"
,
dataType
=
"String"
)
})
@MethodLog
(
operModule
=
OperModule
.
USER
,
operType
=
OperType
.
UPDATE
)
public
Map
<
String
,
Object
>
updateStatus
(
@NotNull
(
message
=
"机构用户不能为空"
)
@PathVariable
(
"id"
)
String
id
,
@RequestParam
(
"status"
)
AuditStatusEnum
status
)
{
UpdateWrapper
<
TUser
>
updateWrapper
=
new
UpdateWrapper
<>();
updateWrapper
.
eq
(
"id"
,
id
);
updateWrapper
.
eq
(
"audit_status"
,
status
.
name
());
boolean
flag
=
userService
.
update
(
updateWrapper
);
if
(
flag
)
{
return
getSuccessResult
();
}
return
getFailResult
();
}
}
}
src/main/resources/mapper/TOrganMapper.xml
View file @
2c27db79
...
@@ -23,4 +23,9 @@
...
@@ -23,4 +23,9 @@
id, name, parent_id, is_deleted, create_time, update_time, province, city, country, icon, remarks, level
id, name, parent_id, is_deleted, create_time, update_time, province, city, country, icon, remarks, level
</sql>
</sql>
<select
id=
"selectArea"
resultType=
"java.util.HashMap"
>
select concat(name,type) name,id from t_area
</select>
</mapper>
</mapper>
src/main/resources/mapper/TUserMapper.xml
View file @
2c27db79
...
@@ -24,6 +24,22 @@
...
@@ -24,6 +24,22 @@
<result
column=
"type"
property=
"type"
/>
<result
column=
"type"
property=
"type"
/>
<result
column=
"audit_status"
property=
"auditStatus"
/>
<result
column=
"audit_status"
property=
"auditStatus"
/>
<result
column=
"org_name"
property=
"orgName"
/>
<result
column=
"org_name"
property=
"orgName"
/>
<collection
fetchType=
"eager"
property=
"roleList"
ofType=
"cn.wisenergy.chnmuseum.party.model.Role"
select=
"selectRoles"
column=
"user_name"
/>
</resultMap>
<resultMap
id=
"roleMap"
type=
"cn.wisenergy.chnmuseum.party.model.Role"
>
<result
column=
"id"
property=
"id"
/>
<result
column=
"name"
property=
"name"
/>
<result
column=
"alias"
property=
"alias"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"status"
property=
"status"
/>
<result
column=
"is_allow_login"
property=
"allowLogin"
/>
<result
column=
"instruction"
property=
"instruction"
/>
<result
column=
"is_deleted"
property=
"isDeleted"
/>
<result
column=
"sortorder"
property=
"sortorder"
/>
</resultMap>
</resultMap>
<!-- 通用查询结果列 -->
<!-- 通用查询结果列 -->
...
@@ -35,7 +51,27 @@
...
@@ -35,7 +51,27 @@
select u.*,o.name org_name
select u.*,o.name org_name
from t_user u
from t_user u
left join t_organ o on o.id = u.org_id
left join t_organ o on o.id = u.org_id
where u.user_name =#{username}
where u.user_name =#{userName}
</select>
<select
id=
"selectList"
resultMap=
"BaseResultMap"
>
select u.*,o.name org_name
from t_user u
left join t_organ o on o.id = u.org_id
<if
test=
" username != null and username != '' "
>
where u.user_name LIKE concat('%', #{userName}, '%')
</if>
</select>
<select
id=
"selectRoles"
resultMap=
"roleMap"
>
select r.*
from t_user u
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=
" username != null and username != '' "
>
where u.user_name =#{userName}
</if>
</select>
</select>
</mapper>
</mapper>
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