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
29f30b14
Commit
29f30b14
authored
Mar 22, 2021
by
wzp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录和机构管理,日志部分功能
parent
99bb83aa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
1916 additions
and
79 deletions
+1916
-79
JwtTokenUtil.java
.../cn/wisenergy/chnmuseum/party/auth/util/JwtTokenUtil.java
+3
-3
MethodLog.java
...va/cn/wisenergy/chnmuseum/party/common/log/MethodLog.java
+18
-0
OperModule.java
...a/cn/wisenergy/chnmuseum/party/common/log/OperModule.java
+9
-0
OperType.java
...ava/cn/wisenergy/chnmuseum/party/common/log/OperType.java
+15
-0
SystemOperationLogService.java
...chnmuseum/party/common/log/SystemOperationLogService.java
+199
-0
MysqlGenerator.java
...energy/chnmuseum/party/common/mybatis/MysqlGenerator.java
+3
-15
MenuMapper.java
.../java/cn/wisenergy/chnmuseum/party/mapper/MenuMapper.java
+1
-1
RoleMapper.java
.../java/cn/wisenergy/chnmuseum/party/mapper/RoleMapper.java
+5
-0
TOrganMapper.java
...ava/cn/wisenergy/chnmuseum/party/mapper/TOrganMapper.java
+16
-0
TUserMapper.java
...java/cn/wisenergy/chnmuseum/party/mapper/TUserMapper.java
+17
-0
TUserRoleLinkMapper.java
...wisenergy/chnmuseum/party/mapper/TUserRoleLinkMapper.java
+16
-0
TUserRoleMapper.java
.../cn/wisenergy/chnmuseum/party/mapper/TUserRoleMapper.java
+16
-0
SysLog.java
src/main/java/cn/wisenergy/chnmuseum/party/model/SysLog.java
+5
-1
TOrgan.java
src/main/java/cn/wisenergy/chnmuseum/party/model/TOrgan.java
+113
-0
TUser.java
src/main/java/cn/wisenergy/chnmuseum/party/model/TUser.java
+141
-0
TUserRole.java
...in/java/cn/wisenergy/chnmuseum/party/model/TUserRole.java
+67
-0
TUserRoleLink.java
...ava/cn/wisenergy/chnmuseum/party/model/TUserRoleLink.java
+66
-0
RoleService.java
...ava/cn/wisenergy/chnmuseum/party/service/RoleService.java
+11
-0
TOrganService.java
...a/cn/wisenergy/chnmuseum/party/service/TOrganService.java
+19
-0
TUserRoleLinkService.java
...senergy/chnmuseum/party/service/TUserRoleLinkService.java
+16
-0
TUserRoleService.java
...n/wisenergy/chnmuseum/party/service/TUserRoleService.java
+16
-0
TUserService.java
...va/cn/wisenergy/chnmuseum/party/service/TUserService.java
+17
-0
MenuServiceImpl.java
...senergy/chnmuseum/party/service/impl/MenuServiceImpl.java
+6
-2
TOrganServiceImpl.java
...nergy/chnmuseum/party/service/impl/TOrganServiceImpl.java
+53
-0
TUserRoleLinkServiceImpl.java
...hnmuseum/party/service/impl/TUserRoleLinkServiceImpl.java
+28
-0
TUserRoleServiceImpl.java
...gy/chnmuseum/party/service/impl/TUserRoleServiceImpl.java
+27
-0
TUserServiceImpl.java
...energy/chnmuseum/party/service/impl/TUserServiceImpl.java
+34
-0
LoginController.java
...nergy/chnmuseum/party/web/controller/LoginController.java
+61
-50
SysLogController.java
...ergy/chnmuseum/party/web/controller/SysLogController.java
+2
-0
TOrganController.java
...ergy/chnmuseum/party/web/controller/TOrganController.java
+172
-0
TUserController.java
...nergy/chnmuseum/party/web/controller/TUserController.java
+440
-0
TUserRoleLinkController.java
...nmuseum/party/web/controller/TUserRoleLinkController.java
+181
-0
MenuMapper.xml
src/main/resources/mapper/MenuMapper.xml
+7
-4
RoleMapper.xml
src/main/resources/mapper/RoleMapper.xml
+11
-2
SysLogMapper.xml
src/main/resources/mapper/SysLogMapper.xml
+2
-1
TOrganMapper.xml
src/main/resources/mapper/TOrganMapper.xml
+26
-0
TUserMapper.xml
src/main/resources/mapper/TUserMapper.xml
+41
-0
TUserRoleLinkMapper.xml
src/main/resources/mapper/TUserRoleLinkMapper.xml
+18
-0
TUserRoleMapper.xml
src/main/resources/mapper/TUserRoleMapper.xml
+18
-0
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/auth/util/JwtTokenUtil.java
View file @
29f30b14
...
@@ -54,7 +54,7 @@ public class JwtTokenUtil {
...
@@ -54,7 +54,7 @@ public class JwtTokenUtil {
Algorithm
algorithm
=
Algorithm
.
HMAC512
(
jwtTokenSecret
);
Algorithm
algorithm
=
Algorithm
.
HMAC512
(
jwtTokenSecret
);
JWTVerifier
verifier
=
JWT
.
require
(
algorithm
).
withIssuer
(
jwtTokenIssuer
).
withSubject
(
username
).
build
();
JWTVerifier
verifier
=
JWT
.
require
(
algorithm
).
withIssuer
(
jwtTokenIssuer
).
withSubject
(
username
).
build
();
DecodedJWT
jwt
=
verifier
.
verify
(
token
);
DecodedJWT
jwt
=
verifier
.
verify
(
token
);
return
jwt
.
getClaim
(
"
employee
_id"
).
asString
();
return
jwt
.
getClaim
(
"
user
_id"
).
asString
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
());
LOGGER
.
error
(
e
.
getMessage
());
return
null
;
return
null
;
...
@@ -83,7 +83,7 @@ public class JwtTokenUtil {
...
@@ -83,7 +83,7 @@ public class JwtTokenUtil {
public
static
String
getEmployeeId
(
String
token
)
{
public
static
String
getEmployeeId
(
String
token
)
{
try
{
try
{
DecodedJWT
jwt
=
JWT
.
decode
(
token
);
DecodedJWT
jwt
=
JWT
.
decode
(
token
);
return
jwt
.
getClaim
(
"
employee
_id"
).
asString
();
return
jwt
.
getClaim
(
"
user
_id"
).
asString
();
}
catch
(
JWTDecodeException
e
)
{
}
catch
(
JWTDecodeException
e
)
{
return
null
;
return
null
;
}
}
...
@@ -101,7 +101,7 @@ public class JwtTokenUtil {
...
@@ -101,7 +101,7 @@ public class JwtTokenUtil {
// 附带username信息
// 附带username信息
return
JWT
.
create
().
withIssuer
(
jwtTokenIssuer
)
return
JWT
.
create
().
withIssuer
(
jwtTokenIssuer
)
// 创建时间
// 创建时间
.
withIssuedAt
(
DateUtil80
.
getCurrDateTime
()).
withSubject
(
username
).
withClaim
(
"
employee
_id"
,
employeeId
)
.
withIssuedAt
(
DateUtil80
.
getCurrDateTime
()).
withSubject
(
username
).
withClaim
(
"
user
_id"
,
employeeId
)
.
withExpiresAt
(
DateUtil80
.
asDate
(
currentTime
.
plusMinutes
(
240
))).
sign
(
algorithm
);
.
withExpiresAt
(
DateUtil80
.
asDate
(
currentTime
.
plusMinutes
(
240
))).
sign
(
algorithm
);
}
}
...
...
src/main/java/cn/wisenergy/chnmuseum/party/common/log/MethodLog.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
log
;
import
java.lang.annotation.*
;
/**
* 日志切面注解
*/
@Target
({
ElementType
.
METHOD
,
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
MethodLog
{
OperModule
operModule
();
OperType
operType
();
// String desc() default "";
}
src/main/java/cn/wisenergy/chnmuseum/party/common/log/OperModule.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
log
;
public
enum
OperModule
{
用户管理
,
角色管理
,
人员管理
,
部门管理
,
机构管理
;
}
src/main/java/cn/wisenergy/chnmuseum/party/common/log/OperType.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
log
;
public
enum
OperType
{
/**
*
*/
添加
,
修改
,
删除
,
禁用
,
启用
,
复制
,
分享
,
注销
;
}
src/main/java/cn/wisenergy/chnmuseum/party/common/log/SystemOperationLogService.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
log
;
import
cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil
;
import
cn.wisenergy.chnmuseum.party.common.util.DateUtil80
;
import
cn.wisenergy.chnmuseum.party.mapper.SysLogMapper
;
import
cn.wisenergy.chnmuseum.party.model.SysLog
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.service.impl.TUserServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
javassist.util.HotSwapper
;
import
org.apache.commons.lang3.StringUtils
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.Signature
;
import
org.aspectj.lang.annotation.AfterThrowing
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Method
;
import
java.net.InetAddress
;
import
java.util.List
;
@Service
@Aspect
@Transactional
class
SystemOperationLogService
extends
ServiceImpl
<
SysLogMapper
,
SysLog
>
{
@Resource
private
SysLogMapper
sysLogMapper
;
@Autowired
private
TUserServiceImpl
userService
;
public
SystemOperationLogService
()
{
System
.
out
.
println
(
"Aop"
);
}
public
TUser
getCurAdmin
(
HttpServletRequest
request
)
{
String
header
=
request
.
getHeader
(
"Authorization"
);
if
(
StringUtils
.
isBlank
(
header
))
{
return
null
;
}
String
username
=
JwtTokenUtil
.
getUsername
(
header
);
TUser
user
=
userService
.
selectByUsername
(
username
);
return
user
;
}
/**
* 切点
*/
@Pointcut
(
"@annotation(cn.wisenergy.chnmuseum.party.common.log.MethodLog)"
)
public
void
methodCachePointcut
()
{
}
/**
* 切面
*
* @param point
* @return
* @throws Throwable
*/
@Around
(
"methodCachePointcut()"
)
public
Object
around
(
ProceedingJoinPoint
point
)
throws
Throwable
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
MethodLog
methodLog
=
getAnnotationLog
(
point
);
String
ip
=
getIp
(
request
);
TUser
user
=
getCurAdmin
(
request
);
String
methodName
=
user
.
getUserName
()
+
"登录本系统"
;
if
(
user
.
getOrgName
()
!=
null
)
{
methodName
+=
",机构"
+
user
.
getOrgName
();
}
String
packages
=
point
.
getThis
().
getClass
().
getName
();
if
(
packages
.
indexOf
(
"$$EnhancerByCGLIB$$"
)
>
-
1
)
{
// 如果是CGLIB动态生成的类
try
{
packages
=
packages
.
substring
(
0
,
packages
.
indexOf
(
"$$"
));
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
}
String
operatingcontent
=
""
;
Object
[]
method_param
=
null
;
Object
object
;
try
{
method_param
=
point
.
getArgs
();
//获取方法参数
// String param=(String) point.proceed(point.getArgs());
object
=
point
.
proceed
();
}
catch
(
Exception
e
)
{
// 异常处理记录日志..log.error(e);
throw
e
;
}
SysLog
sysLog
=
new
SysLog
();
if
(
"1"
.
equals
(
user
.
getId
()))
{
sysLog
.
setType
(
1
);
}
else
{
sysLog
.
setType
(
2
);
}
sysLog
.
setOperator
(
user
.
getUserName
());
sysLog
.
setOperationIp
(
ip
);
sysLog
.
setOperationContent
(
methodName
);
sysLog
.
setOperationTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
// 处理设置注解上的参数
getControllerMethodDescription
(
methodLog
,
sysLog
);
baseMapper
.
insert
(
sysLog
);
// System.out.println("日志实体:"+sysLog.getLoginName()+sysLog.getMethodRemark()+sysLog.getOperationContent());
return
object
;
}
/**
* 获取注解中对方法的描述信息 用于Controller层注解
*
* @param log 日志
* @param
* @throws Exception
*/
public
void
getControllerMethodDescription
(
MethodLog
log
,
SysLog
sysLog
)
throws
Exception
{
// 设置action动作
sysLog
.
setOperationType
(
log
.
operType
().
name
());
// 设置标题
sysLog
.
setOperationObject
(
log
.
operModule
().
name
());
}
/**
* 是否存在注解,如果存在就获取
*/
private
MethodLog
getAnnotationLog
(
JoinPoint
joinPoint
)
throws
Exception
{
Signature
signature
=
joinPoint
.
getSignature
();
MethodSignature
methodSignature
=
(
MethodSignature
)
signature
;
Method
method
=
methodSignature
.
getMethod
();
if
(
method
!=
null
)
{
return
method
.
getAnnotation
(
MethodLog
.
class
);
}
return
null
;
}
/**
* 方法异常时调用
*
* @param
*/
@AfterThrowing
(
"methodCachePointcut()"
)
public
void
afterThrowing
(
JoinPoint
point
)
throws
Throwable
{
}
/**
* 获取请求ip
*
* @param request
* @return
*/
public
static
String
getIp
(
HttpServletRequest
request
)
{
String
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"HTTP_CLIENT_IP"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"HTTP_X_FORWARDED_FOR"
);
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getRemoteAddr
();
if
(
"127.0.0.1"
.
equals
(
ip
)
||
"0:0:0:0:0:0:0:1"
.
equals
(
ip
))
{
//根据网卡取本机配置的IP
InetAddress
inet
=
null
;
try
{
inet
=
InetAddress
.
getLocalHost
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
ip
=
inet
.
getHostAddress
();
}
}
return
ip
;
}
}
src/main/java/cn/wisenergy/chnmuseum/party/common/mybatis/MysqlGenerator.java
View file @
29f30b14
...
@@ -3,22 +3,10 @@ package cn.wisenergy.chnmuseum.party.common.mybatis;
...
@@ -3,22 +3,10 @@ package cn.wisenergy.chnmuseum.party.common.mybatis;
public
class
MysqlGenerator
{
public
class
MysqlGenerator
{
private
static
final
String
[]
tableNames
=
new
String
[]
{
private
static
final
String
[]
tableNames
=
new
String
[]
{
"asset"
,
"t_user_role_link"
"asset_type"
,
"board_talking"
,
"copyright_owner"
,
"copyright_owner_asset_type"
,
"copyright_owner_board_type"
,
"exhibition_board"
,
"exhibition_board_cat"
,
"learning_content"
,
"learning_content_board"
,
"learning_content_board_cat"
,
"learning_content_copyright_owner"
,
"sys_log"
,
"run_log"
};
};
private
static
final
String
projectPath
=
"/opt/ss"
;
private
static
final
String
projectPath
=
"D:\\develop\\Project\\chnmuseum-party"
;
// private static final String projectPath = "/opt/ss";
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
CodeGenerator
codeGenerator
=
new
CodeGenerator
();
CodeGenerator
codeGenerator
=
new
CodeGenerator
();
...
...
src/main/java/cn/wisenergy/chnmuseum/party/mapper/MenuMapper.java
View file @
29f30b14
...
@@ -16,5 +16,5 @@ import java.util.List;
...
@@ -16,5 +16,5 @@ import java.util.List;
*/
*/
public
interface
MenuMapper
extends
BaseMapper
<
Menu
>
{
public
interface
MenuMapper
extends
BaseMapper
<
Menu
>
{
List
<
Menu
>
getUserMenuPerms
(
@Param
(
value
=
"roleId"
)
String
roleId
);
List
<
Menu
>
getUserMenuPerms
(
List
<
String
>
list
);
}
}
src/main/java/cn/wisenergy/chnmuseum/party/mapper/RoleMapper.java
View file @
29f30b14
...
@@ -3,7 +3,12 @@ package cn.wisenergy.chnmuseum.party.mapper;
...
@@ -3,7 +3,12 @@ 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.Role
;
import
cn.wisenergy.chnmuseum.party.model.Role
;
import
org.mapstruct.Mapper
;
import
java.util.List
;
@Mapper
public
interface
RoleMapper
extends
BaseMapper
<
Role
>
{
public
interface
RoleMapper
extends
BaseMapper
<
Role
>
{
List
<
Role
>
selectRole
(
String
id
);
}
}
\ No newline at end of file
src/main/java/cn/wisenergy/chnmuseum/party/mapper/TOrganMapper.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
cn.wisenergy.chnmuseum.party.model.TOrgan
;
/**
* <pre>
* 用户 Mapper 接口
* </pre>
*
* @author Danny Lee
* @since 2021-03-22
*/
public
interface
TOrganMapper
extends
BaseMapper
<
TOrgan
>
{
}
src/main/java/cn/wisenergy/chnmuseum/party/mapper/TUserMapper.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
/**
* <pre>
* 用户 Mapper 接口
* </pre>
*
* @author Danny Lee
* @since 2021-03-22
*/
public
interface
TUserMapper
extends
BaseMapper
<
TUser
>
{
TUser
selectByUsername
(
String
username
);
}
src/main/java/cn/wisenergy/chnmuseum/party/mapper/TUserRoleLinkMapper.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
cn.wisenergy.chnmuseum.party.model.TUserRoleLink
;
/**
* <pre>
* 用户角色关联 Mapper 接口
* </pre>
*
* @author Danny Lee
* @since 2021-03-22
*/
public
interface
TUserRoleLinkMapper
extends
BaseMapper
<
TUserRoleLink
>
{
}
src/main/java/cn/wisenergy/chnmuseum/party/mapper/TUserRoleMapper.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
cn.wisenergy.chnmuseum.party.model.TUserRole
;
/**
* <pre>
* 用户角色关联 Mapper 接口
* </pre>
*
* @author Danny Lee
* @since 2021-03-22
*/
public
interface
TUserRoleMapper
extends
BaseMapper
<
TUserRole
>
{
}
src/main/java/cn/wisenergy/chnmuseum/party/model/SysLog.java
View file @
29f30b14
...
@@ -22,7 +22,7 @@ import java.time.LocalDateTime;
...
@@ -22,7 +22,7 @@ import java.time.LocalDateTime;
*/
*/
@Data
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"sys_log"
)
@TableName
(
"
t_
sys_log"
)
@ApiModel
(
value
=
"SysLog对象"
,
description
=
"用户/平台操作日志"
)
@ApiModel
(
value
=
"SysLog对象"
,
description
=
"用户/平台操作日志"
)
public
class
SysLog
implements
Serializable
{
public
class
SysLog
implements
Serializable
{
...
@@ -56,4 +56,8 @@ public class SysLog implements Serializable {
...
@@ -56,4 +56,8 @@ public class SysLog implements Serializable {
@TableField
(
"operation_ip"
)
@TableField
(
"operation_ip"
)
private
String
operationIp
;
private
String
operationIp
;
@ApiModelProperty
(
value
=
"日志类型 1.平台操作日志 2.用户操作日志"
)
@TableField
(
"type"
)
private
Integer
type
;
}
}
src/main/java/cn/wisenergy/chnmuseum/party/model/TOrgan.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
model
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Add
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Update
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.Version
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.time.LocalDateTime
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
java.io.Serializable
;
import
java.util.List
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
com.baomidou.mybatisplus.annotation.TableField
;
/**
* <p>
* 用户
* </p>
*
* @author Danny Lee
* @since 2021-03-22
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"t_organ"
)
@ApiModel
(
value
=
"用户"
,
description
=
"用户"
)
public
class
TOrgan
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"机构ID"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@NotNull
(
message
=
"机构IDID不能为空"
,
groups
=
{
Update
.
class
})
private
String
id
;
@ApiModelProperty
(
"机构名称"
)
@TableField
(
"name"
)
@NotBlank
(
message
=
"机构名称不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
name
;
@ApiModelProperty
(
"父机构ID"
)
@TableField
(
"parent_id"
)
@NotBlank
(
message
=
"父机构ID不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
parentId
;
@ApiModelProperty
(
"0:未删除,1:已删除"
)
@TableField
(
"is_deleted"
)
private
Boolean
isDeleted
;
@ApiModelProperty
(
"创建时间"
)
@TableField
(
value
=
"create_time"
,
fill
=
FieldFill
.
INSERT
)
@NotNull
(
message
=
"创建时间不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
LocalDateTime
createTime
;
@ApiModelProperty
(
"修改时间"
)
@TableField
(
value
=
"update_time"
,
fill
=
FieldFill
.
INSERT_UPDATE
)
@NotNull
(
message
=
"修改时间不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
LocalDateTime
updateTime
;
@ApiModelProperty
(
"省"
)
@TableField
(
"province"
)
@NotNull
(
message
=
"省不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
Integer
province
;
@ApiModelProperty
(
"市"
)
@TableField
(
"city"
)
@NotNull
(
message
=
"市不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
Integer
city
;
@ApiModelProperty
(
"县"
)
@TableField
(
"country"
)
@NotNull
(
message
=
"县不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
Integer
country
;
@ApiModelProperty
(
"icon"
)
@TableField
(
"icon"
)
@NotBlank
(
message
=
"icon不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
icon
;
@ApiModelProperty
(
"备注"
)
@TableField
(
"remarks"
)
@NotBlank
(
message
=
"备注不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
remarks
;
@ApiModelProperty
(
"级别"
)
@TableField
(
"level"
)
private
Integer
level
;
@ApiModelProperty
(
"下级机构"
)
@TableField
(
exist
=
false
)
private
List
<
TOrgan
>
children
;
}
src/main/java/cn/wisenergy/chnmuseum/party/model/TUser.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
model
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Add
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Update
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
java.time.LocalDate
;
import
com.baomidou.mybatisplus.annotation.Version
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.time.LocalDateTime
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
java.io.Serializable
;
import
java.util.List
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
/**
* <p>
* 用户
* </p>
*
* @author Danny Lee
* @since 2021-03-22
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"t_user"
)
@ApiModel
(
value
=
"用户"
,
description
=
"用户"
)
public
class
TUser
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"用户标识"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@NotNull
(
message
=
"用户标识ID不能为空"
,
groups
=
{
Update
.
class
})
private
String
id
;
@ApiModelProperty
(
"用户名"
)
@TableField
(
"user_name"
)
@NotBlank
(
message
=
"用户名不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
userName
;
@TableField
(
"password_hash"
)
@NotNull
(
message
=
"不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
byte
[]
passwordHash
;
@TableField
(
"password_salt"
)
@NotNull
(
message
=
"不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
byte
[]
passwordSalt
;
@ApiModelProperty
(
"创建时间"
)
@TableField
(
value
=
"create_time"
,
fill
=
FieldFill
.
INSERT
)
@NotNull
(
message
=
"创建时间不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
LocalDateTime
createTime
;
@ApiModelProperty
(
"修改时间"
)
@TableField
(
value
=
"update_time"
,
fill
=
FieldFill
.
INSERT_UPDATE
)
private
LocalDateTime
updateTime
;
@ApiModelProperty
(
"所属机构ID"
)
@TableField
(
"org_id"
)
@NotBlank
(
message
=
"所属机构ID不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
orgId
;
@ApiModelProperty
(
"是否永久用户"
)
@TableField
(
"permanent"
)
private
Boolean
permanent
;
@ApiModelProperty
(
"生效日期"
)
@TableField
(
"effective_date"
)
private
LocalDate
effectiveDate
;
@ApiModelProperty
(
"失效日期"
)
@TableField
(
"exired_date"
)
private
LocalDate
exiredDate
;
@ApiModelProperty
(
"状态"
)
@TableField
(
"status"
)
private
String
status
;
@ApiModelProperty
(
"手机号"
)
@TableField
(
"phone"
)
private
Integer
phone
;
@ApiModelProperty
(
"邮箱"
)
@TableField
(
"email"
)
private
String
email
;
@ApiModelProperty
(
"微信"
)
@TableField
(
"we_chat"
)
private
String
weChat
;
@ApiModelProperty
(
"固话"
)
@TableField
(
"telephone"
)
private
String
telephone
;
@ApiModelProperty
(
"0:未删除,1:已删除"
)
@TableField
(
"is_deleted"
)
private
Boolean
isDeleted
;
@ApiModelProperty
(
"姓名"
)
@TableField
(
"real_name"
)
private
String
realName
;
@ApiModelProperty
(
"类型 1.平台账号 2.用户账号 3.机顶盒账号 4.运维账号"
)
@TableField
(
"type"
)
private
String
type
;
@ApiModelProperty
(
"审核状态 1.通过 2.待初审 3.待复审 4.已驳回"
)
@TableField
(
"audit_status"
)
private
String
auditStatus
;
@ApiModelProperty
(
"机构名称"
)
@TableField
(
exist
=
false
)
private
String
orgName
;
@ApiModelProperty
(
"角色集合"
)
@TableField
(
exist
=
false
)
private
List
<
Role
>
roleList
;
@ApiModelProperty
(
"密码"
)
@TableField
(
exist
=
false
)
private
String
password
;
}
src/main/java/cn/wisenergy/chnmuseum/party/model/TUserRole.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
model
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Add
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Update
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.Version
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
java.io.Serializable
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
com.baomidou.mybatisplus.annotation.TableField
;
/**
* <p>
* 用户角色关联
* </p>
*
* @author Danny Lee
* @since 2021-03-22
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"t_user_role_link"
)
@ApiModel
(
value
=
"用户角色关联"
,
description
=
"用户角色关联"
)
public
class
TUserRole
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"ID"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@NotNull
(
message
=
"IDID不能为空"
,
groups
=
{
Update
.
class
})
private
String
id
;
@ApiModelProperty
(
"用户名"
)
@TableField
(
"user_id"
)
@NotBlank
(
message
=
"用户名不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
userId
;
@TableField
(
"role_id"
)
@NotBlank
(
message
=
"不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
roleId
;
@ApiModelProperty
(
"0:未删除,1:已删除"
)
@TableField
(
"is_deleted"
)
private
Boolean
isDeleted
;
}
src/main/java/cn/wisenergy/chnmuseum/party/model/TUserRoleLink.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
model
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.Version
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
java.io.Serializable
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
com.baomidou.mybatisplus.annotations.Version
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
com.baomidou.mybatisplus.annotation.TableField
;
/**
* <p>
* 用户角色关联
* </p>
*
* @author Danny Lee
* @since 2021-03-22
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"t_user_role_link"
)
@ApiModel
(
value
=
"用户角色关联"
,
description
=
"用户角色关联"
)
public
class
TUserRoleLink
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"ID"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@NotNull
(
message
=
"IDID不能为空"
,
groups
=
{
Update
.
class
})
private
String
id
;
@ApiModelProperty
(
"用户名"
)
@TableField
(
"user_id"
)
@NotBlank
(
message
=
"用户名不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
userId
;
@TableField
(
"role_id"
)
@NotBlank
(
message
=
"不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
})
private
String
roleId
;
@ApiModelProperty
(
"0:未删除,1:已删除"
)
@TableField
(
"is_deleted"
)
private
Boolean
isDeleted
;
}
src/main/java/cn/wisenergy/chnmuseum/party/service/RoleService.java
View file @
29f30b14
...
@@ -6,7 +6,18 @@ import org.springframework.stereotype.Service;
...
@@ -6,7 +6,18 @@ import org.springframework.stereotype.Service;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Service
@Service
public
class
RoleService
extends
ServiceImpl
<
RoleMapper
,
Role
>
{
public
class
RoleService
extends
ServiceImpl
<
RoleMapper
,
Role
>
{
@Resource
private
RoleMapper
roleMapper
;
public
List
<
Role
>
selectRoleByUserId
(
String
id
){
List
<
Role
>
roles
=
roleMapper
.
selectRole
(
id
);
return
roles
;
}
}
}
src/main/java/cn/wisenergy/chnmuseum/party/service/TOrganService.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
;
import
cn.wisenergy.chnmuseum.party.model.TOrgan
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
java.util.List
;
/**
* <p>
* 用户 服务接口
* </p>
*
* @author Danny Lee
* @since 2021-03-22
*/
public
interface
TOrganService
extends
IService
<
TOrgan
>
{
List
<
TOrgan
>
getTree
();
}
src/main/java/cn/wisenergy/chnmuseum/party/service/TUserRoleLinkService.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
;
import
cn.wisenergy.chnmuseum.party.model.TUserRoleLink
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
* <p>
* 用户角色关联 服务接口
* </p>
*
* @author Danny Lee
* @since 2021-03-22
*/
public
interface
TUserRoleLinkService
extends
IService
<
TUserRoleLink
>
{
}
src/main/java/cn/wisenergy/chnmuseum/party/service/TUserRoleService.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
;
import
cn.wisenergy.chnmuseum.party.model.TUserRole
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
* <p>
* 用户角色关联 服务接口
* </p>
*
* @author Danny Lee
* @since 2021-03-22
*/
public
interface
TUserRoleService
extends
IService
<
TUserRole
>
{
}
src/main/java/cn/wisenergy/chnmuseum/party/service/TUserService.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
* <p>
* 用户 服务接口
* </p>
*
* @author Danny Lee
* @since 2021-03-22
*/
public
interface
TUserService
extends
IService
<
TUser
>
{
TUser
selectByUsername
(
String
username
);
}
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/MenuServiceImpl.java
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
.
impl
;
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
.
impl
;
import
cn.wisenergy.chnmuseum.party.model.Role
;
import
cn.wisenergy.chnmuseum.party.service.IMenuService
;
import
cn.wisenergy.chnmuseum.party.service.IMenuService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
cn.wisenergy.chnmuseum.party.mapper.MenuMapper
;
import
cn.wisenergy.chnmuseum.party.mapper.MenuMapper
;
...
@@ -7,6 +8,7 @@ import cn.wisenergy.chnmuseum.party.model.Menu;
...
@@ -7,6 +8,7 @@ import cn.wisenergy.chnmuseum.party.model.Menu;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -23,8 +25,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
...
@@ -23,8 +25,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
@Resource
@Resource
private
MenuMapper
menuMapper
;
private
MenuMapper
menuMapper
;
public
List
<
Menu
>
getUserMenuPerms
(
String
roleId
)
{
public
List
<
Menu
>
getUserMenuPerms
(
List
<
Role
>
list
)
{
return
menuMapper
.
getUserMenuPerms
(
roleId
);
List
<
String
>
list1
=
new
ArrayList
<>();
list
.
stream
().
forEach
(
r
->
list1
.
add
(
r
.
getId
()));
return
menuMapper
.
getUserMenuPerms
(
list1
);
}
}
}
}
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/TOrganServiceImpl.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
.
impl
;
import
cn.wisenergy.chnmuseum.party.model.TOrgan
;
import
cn.wisenergy.chnmuseum.party.mapper.TOrganMapper
;
import
cn.wisenergy.chnmuseum.party.service.TOrganService
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* <pre>
* 用户 服务实现类
* </pre>
*
* @author Danny Lee
* @since 2021-03-22
*/
@Slf4j
@Service
public
class
TOrganServiceImpl
extends
ServiceImpl
<
TOrganMapper
,
TOrgan
>
implements
TOrganService
{
@Resource
private
TOrganMapper
organMapper
;
@Override
public
List
<
TOrgan
>
getTree
()
{
List
<
TOrgan
>
list
=
list
(
Wrappers
.<
TOrgan
>
lambdaQuery
().
eq
(
TOrgan:
:
getIsDeleted
,
0
).
orderByDesc
(
TOrgan:
:
getLevel
));
HashMap
<
String
,
TOrgan
>
map
=
new
HashMap
<>();
list
.
forEach
(
o
->
map
.
put
(
o
.
getId
(),
o
));
for
(
TOrgan
o
:
list
)
{
TOrgan
parentOrg
=
map
.
get
(
o
.
getParentId
());
if
(
parentOrg
!=
null
){
//说明有值
if
(
parentOrg
.
getChildren
()==
null
){
parentOrg
.
setChildren
(
new
ArrayList
<>());
}
parentOrg
.
getChildren
().
add
(
o
);
}
}
list
=
list
.
stream
().
filter
(
o
->
o
.
getLevel
()
==
1
).
collect
(
Collectors
.
toList
());
return
list
;
}
}
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/TUserRoleLinkServiceImpl.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
.
impl
;
import
cn.wisenergy.chnmuseum.party.model.TUserRoleLink
;
import
cn.wisenergy.chnmuseum.party.mapper.TUserRoleLinkMapper
;
import
cn.wisenergy.chnmuseum.party.service.TUserRoleLinkService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
* <pre>
* 用户角色关联 服务实现类
* </pre>
*
* @author Danny Lee
* @since 2021-03-22
*/
@Slf4j
@Service
public
class
TUserRoleLinkServiceImpl
extends
ServiceImpl
<
TUserRoleLinkMapper
,
TUserRoleLink
>
implements
TUserRoleLinkService
{
@Autowired
private
TUserRoleLinkMapper
tUserRoleMapper
;
}
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/TUserRoleServiceImpl.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
.
impl
;
import
cn.wisenergy.chnmuseum.party.mapper.TUserRoleMapper
;
import
cn.wisenergy.chnmuseum.party.model.TUserRole
;
import
cn.wisenergy.chnmuseum.party.service.TUserRoleService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
* <pre>
* 用户角色关联 服务实现类
* </pre>
*
* @author Danny Lee
* @since 2021-03-22
*/
@Slf4j
@Service
public
class
TUserRoleServiceImpl
extends
ServiceImpl
<
TUserRoleMapper
,
TUserRole
>
implements
TUserRoleService
{
@Autowired
private
TUserRoleMapper
tUserRoleMapper
;
}
src/main/java/cn/wisenergy/chnmuseum/party/service/impl/TUserServiceImpl.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
service
.
impl
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.mapper.TUserMapper
;
import
cn.wisenergy.chnmuseum.party.service.TUserService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
javax.annotation.Resource
;
/**
* <pre>
* 用户 服务实现类
* </pre>
*
* @author Danny Lee
* @since 2021-03-22
*/
@Slf4j
@Service
public
class
TUserServiceImpl
extends
ServiceImpl
<
TUserMapper
,
TUser
>
implements
TUserService
{
@Resource
private
TUserMapper
tUserMapper
;
@Override
public
TUser
selectByUsername
(
String
username
)
{
return
tUserMapper
.
selectByUsername
(
username
);
}
}
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/LoginController.java
View file @
29f30b14
...
@@ -3,9 +3,14 @@ package cn.wisenergy.chnmuseum.party.web.controller;
...
@@ -3,9 +3,14 @@ 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.util.JwtTokenUtil
;
import
cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil
;
import
cn.wisenergy.chnmuseum.party.common.checkcode.SpecCaptcha
;
import
cn.wisenergy.chnmuseum.party.common.checkcode.SpecCaptcha
;
import
cn.wisenergy.chnmuseum.party.model.Employee
;
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.model.Role
;
import
cn.wisenergy.chnmuseum.party.model.TUser
;
import
cn.wisenergy.chnmuseum.party.model.Menu
;
import
cn.wisenergy.chnmuseum.party.model.Menu
;
import
cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl
;
import
cn.wisenergy.chnmuseum.party.service.RoleService
;
import
cn.wisenergy.chnmuseum.party.service.impl.TUserServiceImpl
;
import
cn.wisenergy.chnmuseum.party.service.impl.MenuServiceImpl
;
import
cn.wisenergy.chnmuseum.party.service.impl.MenuServiceImpl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -46,7 +51,10 @@ public class LoginController {
...
@@ -46,7 +51,10 @@ public class LoginController {
private
StringRedisTemplate
stringRedisTemplate
;
private
StringRedisTemplate
stringRedisTemplate
;
@Resource
@Resource
private
EmployeeServiceImpl
employeeService
;
private
TUserServiceImpl
userService
;
@Resource
private
RoleService
roleService
;
@Resource
@Resource
private
MenuServiceImpl
menuService
;
private
MenuServiceImpl
menuService
;
...
@@ -79,41 +87,41 @@ public class LoginController {
...
@@ -79,41 +87,41 @@ public class LoginController {
@RequestMapping
(
value
=
"ajaxLogin"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"ajaxLogin"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<
Map
<
String
,
Object
>>
ajaxLogin
(
@RequestParam
(
value
=
"username"
,
required
=
true
)
String
username
,
public
ResponseEntity
<
Map
<
String
,
Object
>>
ajaxLogin
(
@RequestParam
(
value
=
"username"
,
required
=
true
)
String
username
,
@RequestParam
(
value
=
"password"
,
required
=
true
)
String
password
,
@RequestParam
(
value
=
"password"
,
required
=
true
)
String
password
,
@RequestParam
(
value
=
"captcha"
,
required
=
true
)
String
captcha
,
//
@RequestParam(value = "captcha", required = true) String captcha,
HttpServletRequest
request
)
{
HttpServletRequest
request
)
{
Map
<
String
,
Object
>
resultMap
=
new
LinkedHashMap
<>();
Map
<
String
,
Object
>
resultMap
=
new
LinkedHashMap
<>();
String
captchaId
=
request
.
getHeader
(
"CaptchaId"
);
//
String captchaId = request.getHeader("CaptchaId");
if
(
StringUtils
.
isNotBlank
(
captcha
))
{
//
if (StringUtils.isNotBlank(captcha)) {
if
(
StringUtils
.
isNotBlank
(
captchaId
))
{
//
if (StringUtils.isNotBlank(captchaId)) {
String
uuidCap
=
stringRedisTemplate
.
opsForValue
().
get
(
captchaId
);
//
String uuidCap = stringRedisTemplate.opsForValue().get(captchaId);
if
(
StringUtils
.
isNotBlank
(
uuidCap
))
{
//
if (StringUtils.isNotBlank(uuidCap)) {
if
(!
uuidCap
.
trim
().
equalsIgnoreCase
(
captcha
.
trim
()))
{
//
if (!uuidCap.trim().equalsIgnoreCase(captcha.trim())) {
stringRedisTemplate
.
delete
(
captchaId
);
//
stringRedisTemplate.delete(captchaId);
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);
}
//
}
}
else
{
//
} else {
stringRedisTemplate
.
delete
(
captchaId
);
//
stringRedisTemplate.delete(captchaId);
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);
}
//
}
}
else
{
//
} else {
//stringRedisTemplate.delete(captchaId);
//
//stringRedisTemplate.delete(captchaId);
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);
}
//
}
}
else
{
//
} else {
stringRedisTemplate
.
delete
(
captchaId
);
//
stringRedisTemplate.delete(captchaId);
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);
}
//
}
stringRedisTemplate
.
delete
(
captchaId
);
//
stringRedisTemplate.delete(captchaId);
Employee
employee
;
TUser
user
;
if
(
StringUtils
.
isNoneBlank
(
username
))
{
if
(
StringUtils
.
isNoneBlank
(
username
))
{
//访问一次,计数一次
//访问一次,计数一次
ValueOperations
<
String
,
String
>
opsForValue
=
stringRedisTemplate
.
opsForValue
();
ValueOperations
<
String
,
String
>
opsForValue
=
stringRedisTemplate
.
opsForValue
();
...
@@ -123,24 +131,27 @@ public class LoginController {
...
@@ -123,24 +131,27 @@ public class LoginController {
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
}
employee
=
employeeService
.
selectByUsername
(
username
);
user
=
userService
.
selectByUsername
(
username
);
if
(
employee
==
null
)
{
List
<
Role
>
roles
=
roleService
.
selectRoleByUserId
(
user
.
getId
());
user
.
setRoleList
(
roles
);
if
(
user
==
null
)
{
resultMap
.
put
(
"status"
,
500
);
resultMap
.
put
(
"status"
,
500
);
resultMap
.
put
(
"message"
,
"用户名或密码不正确!"
);
resultMap
.
put
(
"message"
,
"用户名或密码不正确!"
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
resultMap
);
}
}
if
(
!
employee
.
getStatus
(
))
{
if
(
"2"
.
equals
(
user
.
getStatus
()
))
{
throw
new
DisabledAccountException
(
"此帐号已禁用,请联系管理员!"
);
throw
new
DisabledAccountException
(
"此帐号已禁用,请联系管理员!"
);
}
}
if
(!
employee
.
getAllowLogin
())
{
// if (!user
.getAllowLogin()) {
throw
new
DisabledAccountException
(
"您无权访问,请联系管理员!"
);
//
throw new DisabledAccountException("您无权访问,请联系管理员!");
}
//
}
try
{
try
{
byte
[]
salt
=
employee
.
getPasswordSalt
();
byte
[]
salt
=
user
.
getPasswordSalt
();
if
(!
new
String
(
SHA256PasswordEncryptionService
.
createPasswordHash
(
password
,
salt
)).
equals
(
new
String
(
employee
.
getPasswordHash
())))
{
String
s1
=
new
String
(
SHA256PasswordEncryptionService
.
createPasswordHash
(
password
,
salt
));
if
(!
new
String
(
SHA256PasswordEncryptionService
.
createPasswordHash
(
password
,
salt
)).
equals
(
new
String
(
user
.
getPasswordHash
())))
{
opsForValue
.
increment
(
SHIRO_LOGIN_COUNT
+
username
,
1
);
opsForValue
.
increment
(
SHIRO_LOGIN_COUNT
+
username
,
1
);
//计数大于5时,设置用户被锁定一小时
//计数大于5时,设置用户被锁定一小时
String
s
=
opsForValue
.
get
(
SHIRO_LOGIN_COUNT
+
username
);
String
s
=
opsForValue
.
get
(
SHIRO_LOGIN_COUNT
+
username
);
...
@@ -154,20 +165,20 @@ public class LoginController {
...
@@ -154,20 +165,20 @@ public class LoginController {
}
}
//获取当前用户角色拥有菜单
//获取当前用户角色拥有菜单
List
<
Menu
>
userMenuPerms
=
this
.
menuService
.
getUserMenuPerms
(
employee
.
getRoleId
()
);
List
<
Menu
>
userMenuPerms
=
this
.
menuService
.
getUserMenuPerms
(
roles
);
//登录时插入系统日志
//登录时插入系统日志
String
operationContent
=
username
+
"登录本系统"
;
String
operationContent
=
username
+
"登录本系统"
;
if
(
employee
.
getBankBranch
Name
()
!=
null
)
{
if
(
user
.
getOrg
Name
()
!=
null
)
{
operationContent
+=
",
归属网点"
+
employee
.
getBankBranch
Name
();
operationContent
+=
",
机构"
+
user
.
getOrg
Name
();
}
}
this
.
sysLogController
.
insertSysLog
(
operationContent
,
username
);
this
.
sysLogController
.
insertSysLog
(
operationContent
,
username
);
String
token
=
JwtTokenUtil
.
sign
(
username
,
employee
.
getId
());
String
token
=
JwtTokenUtil
.
sign
(
username
,
user
.
getId
());
// 将token信息存入Redis
// 将token信息存入Redis
stringRedisTemplate
.
opsForValue
().
set
(
SHIRO_JWT_TOKEN
+
token
,
employee
.
getId
(),
240
,
TimeUnit
.
MINUTES
);
stringRedisTemplate
.
opsForValue
().
set
(
SHIRO_JWT_TOKEN
+
token
,
user
.
getId
(),
240
,
TimeUnit
.
MINUTES
);
resultMap
.
put
(
"
employee"
,
employee
);
resultMap
.
put
(
"
user"
,
user
);
resultMap
.
put
(
"token"
,
token
);
resultMap
.
put
(
"token"
,
token
);
resultMap
.
put
(
"menuList"
,
userMenuPerms
);
resultMap
.
put
(
"menuList"
,
userMenuPerms
);
resultMap
.
put
(
"status"
,
201
);
resultMap
.
put
(
"status"
,
201
);
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/SysLogController.java
View file @
29f30b14
...
@@ -52,6 +52,8 @@ public class SysLogController extends BaseController {
...
@@ -52,6 +52,8 @@ public class SysLogController extends BaseController {
}
}
//日志内容
//日志内容
sysLog
.
setOperationContent
(
operationContent
);
sysLog
.
setOperationContent
(
operationContent
);
sysLog
.
setOperationObject
(
"登录管理"
);
sysLog
.
setOperationType
(
"登录"
);
Boolean
ret
=
this
.
sysLogService
.
save
(
sysLog
);
Boolean
ret
=
this
.
sysLogService
.
save
(
sysLog
);
return
ret
;
return
ret
;
}
}
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TOrganController.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
import
cn.wisenergy.chnmuseum.party.common.util.DateUtil80
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
cn.wisenergy.chnmuseum.party.model.TOrgan
;
import
cn.wisenergy.chnmuseum.party.service.TOrganService
;
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
com.beust.jcommander.Parameter
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.SystemUtils
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.stereotype.Controller
;
import
javax.annotation.Resource
;
import
javax.validation.constraints.NotNull
;
import
java.util.List
;
import
java.util.Map
;
/**
* <pre>
* 机构 前端控制器
* </pre>
*
* @author Danny Lee
* @since 2021-03-22
*/
@Slf4j
@RestController
@RequestMapping
(
"/organ"
)
@Api
(
tags
=
{
"机构操作接口"
})
public
class
TOrganController
extends
BaseController
{
@Resource
private
TOrganService
tOrganService
;
@PostMapping
(
"/add"
)
@RequiresPermissions
(
"/organ/add"
)
@ApiOperation
(
value
=
"添加机构"
,
notes
=
"添加机构"
)
public
Map
<
String
,
Object
>
add
(
TOrgan
organ
)
{
organ
.
setCreateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
organ
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
// 保存业务节点信息
boolean
result
=
tOrganService
.
save
(
organ
);
// 返回操作结果
if
(
result
)
{
return
getSuccessResult
();
}
else
{
// 保存失败
return
getFailResult
();
}
}
@PutMapping
(
"/update"
)
@RequiresPermissions
(
"/organ/update"
)
@ApiOperation
(
value
=
"update"
,
notes
=
"修改机构信息"
)
public
Map
<
String
,
Object
>
updateTOrgan
(
TOrgan
tOrgan
)
{
tOrgan
.
setUpdateTime
(
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
boolean
flag
=
tOrganService
.
updateById
(
tOrgan
);
if
(
flag
)
{
return
getSuccessResult
();
}
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"
)
@RequiresPermissions
(
"/organ/delete"
)
@ApiOperation
(
value
=
"根据ID删除机构"
,
notes
=
"根据ID删除机构"
)
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"id"
,
value
=
"标识ID"
,
paramType
=
"path"
,
dataType
=
"String"
)
})
public
Map
<
String
,
Object
>
deleteTOrgan
(
@PathVariable
(
"id"
)
String
id
)
{
UpdateWrapper
<
TOrgan
>
updateWrapper
=
new
UpdateWrapper
<>();
updateWrapper
.
eq
(
"id"
,
id
);
updateWrapper
.
eq
(
"is_deleted"
,
1
);
updateWrapper
.
eq
(
"update_time"
,
DateUtil80
.
getDateTimeOfTimestamp
(
System
.
currentTimeMillis
()));
boolean
result
=
tOrganService
.
update
(
updateWrapper
);
if
(
result
)
{
return
getSuccessResult
();
}
return
getFailResult
();
}
@GetMapping
(
"/getList"
)
@RequiresPermissions
(
"/organ/getList"
)
@ApiOperation
(
value
=
"获取机构全部列表(无分页)"
,
notes
=
"获取机构全部列表(无分页)"
)
public
Map
<
String
,
Object
>
getTOrganList
()
{
List
<
TOrgan
>
tOrganList
=
tOrganService
.
list
(
Wrappers
.<
TOrgan
>
lambdaQuery
().
eq
(
TOrgan:
:
getIsDeleted
,
0
));
return
getResult
(
tOrganList
);
}
@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
(
"/organ/getPageList"
)
@ApiOperation
(
value
=
"获取机构分页列表"
,
notes
=
"获取机构分页列表"
)
public
Map
<
String
,
Object
>
getTOrganPageList
(
GenericPageParam
genericPageParam
)
{
LambdaQueryWrapper
<
TOrgan
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
// 对名称或编码模糊查询
if
(
StringUtils
.
isNotBlank
(
genericPageParam
.
getNameOrCode
()))
{
queryWrapper
.
like
(
TOrgan:
:
getName
,
genericPageParam
.
getNameOrCode
());
}
// 根据创建时间区间检索
if
(
genericPageParam
.
getStartDate
()
!=
null
&&
genericPageParam
.
getEndDate
()
!=
null
)
{
queryWrapper
.
ge
(
TOrgan:
:
getCreateTime
,
genericPageParam
.
getStartDate
().
atTime
(
0
,
0
,
0
))
.
le
(
TOrgan:
:
getCreateTime
,
genericPageParam
.
getEndDate
().
atTime
(
23
,
59
,
59
));
}
// 设置排序规则
queryWrapper
.
orderByDesc
(
TOrgan:
:
getCreateTime
);
Page
<
TOrgan
>
page
=
this
.
tOrganService
.
page
(
getPage
(),
queryWrapper
);
return
getResult
(
page
);
}
@ApiOperation
(
value
=
"获取机构详情"
,
notes
=
"获取机构详情"
)
@GetMapping
(
"/getById"
)
@RequiresPermissions
(
"/organ/getById"
)
public
Map
<
String
,
Object
>
getById
(
String
id
)
{
TOrgan
tOrgan
=
tOrganService
.
getById
(
id
);
return
getResult
(
tOrgan
);
}
@GetMapping
(
"/getTree"
)
@RequiresPermissions
(
"/organ/getTree"
)
@ApiOperation
(
value
=
"获取机构树"
,
notes
=
"获取机构树"
)
public
Map
<
String
,
Object
>
getTree
()
{
List
<
TOrgan
>
tOrganList
=
tOrganService
.
getTree
();
return
getResult
(
tOrganList
);
}
}
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TUserController.java
0 → 100644
View file @
29f30b14
This diff is collapsed.
Click to expand it.
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/TUserRoleLinkController.java
0 → 100644
View file @
29f30b14
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
cn.wisenergy.chnmuseum.party.model.TUserRoleLink
;
import
cn.wisenergy.chnmuseum.party.service.TUserRoleLinkService
;
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.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.stereotype.Controller
;
import
javax.annotation.Resource
;
import
javax.validation.constraints.NotNull
;
import
java.util.List
;
import
java.util.Map
;
/**
* <pre>
* 用户角色关联 前端控制器
* </pre>
*
* @author Danny Lee
* @since 2021-03-22
*/
@Slf4j
@RestController
@RequestMapping
(
"/tUserRoleLink"
)
@Api
(
tags
=
{
"用户角色关联操作接口"
})
public
class
TUserRoleLinkController
extends
BaseController
{
@Resource
private
TUserRoleLinkService
tUserRoleLinkService
;
@PostMapping
(
"/batchSave"
)
@RequiresPermissions
(
"t:user:role:batch:save"
)
@ApiOperation
(
value
=
"批量添加用户角色关联"
,
notes
=
"批量添加用户角色关联"
)
public
Map
<
String
,
Object
>
batchSaveTUserRoleLink
(
@Validated
(
value
=
{
Add
.
class
})
List
<
TUserRoleLink
>
tUserRoleLinkList
)
{
// 保存业务节点信息
boolean
result
=
tUserRoleLinkService
.
saveBatch
(
tUserRoleLinkList
);
// 返回操作结果
if
(
result
)
{
return
getSuccessResult
();
}
else
{
// 保存失败
return
getFailResult
();
}
}
@PostMapping
(
"/save"
)
@RequiresPermissions
(
"t:user:role:save"
)
@ApiOperation
(
value
=
"添加用户角色关联"
,
notes
=
"添加用户角色关联"
)
public
Map
<
String
,
Object
>
saveTUserRoleLink
(
@Validated
(
value
=
{
Add
.
class
})
TUserRoleLink
tUserRoleLink
)
{
// 保存业务节点信息
boolean
result
=
tUserRoleLinkService
.
save
(
tUserRoleLink
);
// 返回操作结果
if
(
result
)
{
return
getSuccessResult
();
}
else
{
// 保存失败
return
getFailResult
();
}
}
@PutMapping
(
"/update"
)
@RequiresPermissions
(
"t:user:role:update"
)
@ApiOperation
(
value
=
"修改用户角色关联信息"
,
notes
=
"修改用户角色关联信息"
)
public
Map
<
String
,
Object
>
updateTUserRoleLink
(
@Validated
(
value
=
{
Update
.
class
})
TUserRoleLink
tUserRole
)
{
boolean
flag
=
tUserRoleLinkService
.
updateById
(
tUserRole
);
if
(
flag
)
{
return
getSuccessResult
();
}
return
getFailResult
();
}
@PutMapping
(
"/updateAuditStatus/{id}"
)
@RequiresPermissions
(
"t:user:role:update:audit:status"
)
@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
<
TUserRoleLink
>
updateWrapper
=
new
UpdateWrapper
<>();
updateWrapper
.
eq
(
"id"
,
id
);
updateWrapper
.
eq
(
"audit_status"
,
status
.
name
());
boolean
flag
=
tUserRoleLinkService
.
update
(
updateWrapper
);
if
(
flag
)
{
return
getSuccessResult
();
}
return
getFailResult
();
}
@DeleteMapping
(
"/delete/{id}"
)
@RequiresPermissions
(
"t:user:role:delete"
)
@ApiOperation
(
value
=
"根据ID删除用户角色关联"
,
notes
=
"根据ID删除用户角色关联"
)
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"id"
,
value
=
"标识ID"
,
paramType
=
"path"
,
dataType
=
"String"
)
})
public
Map
<
String
,
Object
>
deleteTUserRoleLink
(
@PathVariable
(
"id"
)
String
id
)
{
boolean
result
=
tUserRoleLinkService
.
removeById
(
id
);
if
(
result
)
{
return
getSuccessResult
();
}
return
getFailResult
();
}
@GetMapping
(
"/getList"
)
@RequiresPermissions
(
"t:user:role:list"
)
@ApiOperation
(
value
=
"获取用户角色关联全部列表(无分页)"
,
notes
=
"获取用户角色关联全部列表(无分页)"
)
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"auditStatus"
,
value
=
"审核状态"
,
paramType
=
"query"
,
dataType
=
"String"
)
})
public
Map
<
String
,
Object
>
getTUserRoleLinkList
(
@RequestParam
(
value
=
"auditStatus"
,
defaultValue
=
"APPROVED_FINAL"
,
required
=
false
)
AuditStatusEnum
auditStatus
)
{
List
<
TUserRoleLink
>
tUserRoleLinkList
=
tUserRoleLinkService
.
list
(
Wrappers
.<
TUserRoleLink
>
lambdaQuery
().
eq
(
TUserRoleLink:
:
getAuditStatus
,
auditStatus
.
name
()));
return
getResult
(
tUserRoleLinkList
);
}
@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
(
"t:user:role:page"
)
@ApiOperation
(
value
=
"获取用户角色关联分页列表"
,
notes
=
"获取用户角色关联分页列表"
)
public
Map
<
String
,
Object
>
getTUserRoleLinkPageList
(
GenericPageParam
genericPageParam
)
{
LambdaQueryWrapper
<
TUserRoleLink
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
// 对名称或编码模糊查询
if
(
StringUtils
.
isNotBlank
(
genericPageParam
.
getNameOrCode
()))
{
queryWrapper
.
like
(
TUserRoleLink:
:
getName
,
genericPageParam
.
getNameOrCode
());
}
// 根据创建时间区间检索
if
(
genericPageParam
.
getStartDate
()
!=
null
&&
genericPageParam
.
getEndDate
()
!=
null
)
{
queryWrapper
.
ge
(
TUserRoleLink:
:
getCreateTime
,
genericPageParam
.
getStartDate
().
atTime
(
0
,
0
,
0
))
.
le
(
TUserRoleLink:
:
getCreateTime
,
genericPageParam
.
getEndDate
().
atTime
(
23
,
59
,
59
));
}
// 设置排序规则
queryWrapper
.
orderByDesc
(
TUserRoleLink:
:
getCreateTime
);
// 设置查询内容
queryWrapper
.
select
(
TUserRoleLink:
:
getId
,
TUserRoleLink:
:
getName
,
TUserRoleLink:
:
getAuditStatus
,
TUserRoleLink:
:
getCreateTime
,
TUserRoleLink:
:
getUpdateTime
);
Page
<
TUserRoleLink
>
page
=
this
.
tUserRoleLinkService
.
page
(
getPage
(),
queryWrapper
);
for
(
TUserRoleLink
tUserRoleLink
:
page
.
getRecords
())
{
}
return
getResult
(
page
);
}
@ApiOperation
(
value
=
"获取用户角色关联详情"
,
notes
=
"获取用户角色关联详情"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"id"
,
value
=
"标识ID"
,
dataType
=
"String"
,
paramType
=
"path"
)
})
@GetMapping
(
"/get/{id}"
)
@RequiresPermissions
(
"t:user:role:get:id"
)
public
Map
<
String
,
Object
>
getById
(
@PathVariable
(
"id"
)
String
id
)
{
TUserRoleLink
tUserRoleLink
=
tUserRoleLinkService
.
getById
(
id
);
return
getResult
(
tUserRoleLink
);
}
}
src/main/resources/mapper/MenuMapper.xml
View file @
29f30b14
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<mapper
namespace=
"cn.wisenergy.chnmuseum.party.mapper.MenuMapper"
>
<mapper
namespace=
"cn.wisenergy.chnmuseum.party.mapper.MenuMapper"
>
<!-- 通用查询映射结果 -->
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"Menu"
>
<resultMap
id=
"BaseResultMap"
type=
"
cn.wisenergy.chnmuseum.party.model.
Menu"
>
<id
column=
"id"
property=
"id"
/>
<id
column=
"id"
property=
"id"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
...
@@ -15,15 +15,18 @@
...
@@ -15,15 +15,18 @@
</resultMap>
</resultMap>
<select
id=
"getUserMenuPerms"
resultMap=
"BaseResultMap"
>
<select
id=
"getUserMenuPerms"
resultMap=
"BaseResultMap"
>
SELECT
SELECT
distinct
m.id,m.menu_name,m.menu_url,m.parent_id,m.sort,m.is_button
m.id,m.menu_name,m.menu_url,m.parent_id,m.sort,m.is_button
FROM
FROM
ref_role_menu rm
ref_role_menu rm
LEFT JOIN menu m ON m.id = rm.menu_id
LEFT JOIN menu m ON m.id = rm.menu_id
<where>
<where>
m.is_deleted = 0
m.is_deleted = 0
<if
test=
"roleId!=null and roleId!='' "
>
<if
test=
"list!=null"
>
AND rm.role_id = #{roleId}
AND rm.role_id in
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</if>
</if>
</where>
</where>
ORDER BY m.sort ASC
ORDER BY m.sort ASC
...
...
src/main/resources/mapper/RoleMapper.xml
View file @
29f30b14
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<mapper
namespace=
"cn.wisenergy.chnmuseum.party.mapper.RoleMapper"
>
<mapper
namespace=
"cn.wisenergy.chnmuseum.party.mapper.RoleMapper"
>
<!-- 通用查询映射结果 -->
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"Role"
>
<resultMap
id=
"BaseResultMap"
type=
"
cn.wisenergy.chnmuseum.party.model.
Role"
>
<id
column=
"id"
property=
"id"
/>
<id
column=
"id"
property=
"id"
/>
<result
column=
"name"
property=
"name"
/>
<result
column=
"name"
property=
"name"
/>
<result
column=
"alias"
property=
"alias"
/>
<result
column=
"alias"
property=
"alias"
/>
...
@@ -12,8 +12,17 @@
...
@@ -12,8 +12,17 @@
<result
column=
"status"
property=
"status"
/>
<result
column=
"status"
property=
"status"
/>
<result
column=
"is_allow_login"
property=
"allowLogin"
/>
<result
column=
"is_allow_login"
property=
"allowLogin"
/>
<result
column=
"instruction"
property=
"instruction"
/>
<result
column=
"instruction"
property=
"instruction"
/>
<result
column=
"
flag"
property=
"flag
"
/>
<result
column=
"
is_deleted"
property=
"isDeleted
"
/>
<result
column=
"sortorder"
property=
"sortorder"
/>
<result
column=
"sortorder"
property=
"sortorder"
/>
</resultMap>
</resultMap>
<select
id=
"selectRole"
resultMap=
"BaseResultMap"
>
select
r.*
from t_user u
left join t_user_role_link ur on ur.user_id = u.id
left join role r on ur.role_id = r.id
where u.id = #{id}
</select>
</mapper>
</mapper>
src/main/resources/mapper/SysLogMapper.xml
View file @
29f30b14
...
@@ -11,11 +11,12 @@
...
@@ -11,11 +11,12 @@
<result
column=
"operation_content"
property=
"operationContent"
/>
<result
column=
"operation_content"
property=
"operationContent"
/>
<result
column=
"operation_time"
property=
"operationTime"
/>
<result
column=
"operation_time"
property=
"operationTime"
/>
<result
column=
"operation_ip"
property=
"operationIp"
/>
<result
column=
"operation_ip"
property=
"operationIp"
/>
<result
column=
"type"
property=
"type"
/>
</resultMap>
</resultMap>
<!-- 通用查询结果列 -->
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id, operator, operation_type, operation_object, operation_content, operation_time, operation_ip
id, operator, operation_type, operation_object, operation_content, operation_time, operation_ip
,type
</sql>
</sql>
</mapper>
</mapper>
src/main/resources/mapper/TOrganMapper.xml
0 → 100644
View file @
29f30b14
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.wisenergy.chnmuseum.party.mapper.TOrganMapper"
>
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"cn.wisenergy.chnmuseum.party.model.TOrgan"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"name"
property=
"name"
/>
<result
column=
"parent_id"
property=
"parentId"
/>
<result
column=
"is_deleted"
property=
"isDeleted"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"province"
property=
"province"
/>
<result
column=
"city"
property=
"city"
/>
<result
column=
"country"
property=
"country"
/>
<result
column=
"icon"
property=
"icon"
/>
<result
column=
"remarks"
property=
"remarks"
/>
<result
column=
"level"
property=
"level"
/>
</resultMap>
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id, name, parent_id, is_deleted, create_time, update_time, province, city, country, icon, remarks, level
</sql>
</mapper>
src/main/resources/mapper/TUserMapper.xml
0 → 100644
View file @
29f30b14
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.wisenergy.chnmuseum.party.mapper.TUserMapper"
>
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"cn.wisenergy.chnmuseum.party.model.TUser"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"user_name"
property=
"userName"
/>
<result
column=
"password_hash"
property=
"passwordHash"
/>
<result
column=
"password_salt"
property=
"passwordSalt"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"org_id"
property=
"orgId"
/>
<result
column=
"permanent"
property=
"permanent"
/>
<result
column=
"effective_date"
property=
"effectiveDate"
/>
<result
column=
"exired_date"
property=
"exiredDate"
/>
<result
column=
"status"
property=
"status"
/>
<result
column=
"phone"
property=
"phone"
/>
<result
column=
"email"
property=
"email"
/>
<result
column=
"we_chat"
property=
"weChat"
/>
<result
column=
"telephone"
property=
"telephone"
/>
<result
column=
"is_deleted"
property=
"isDeleted"
/>
<result
column=
"real_name"
property=
"realName"
/>
<result
column=
"type"
property=
"type"
/>
<result
column=
"audit_status"
property=
"auditStatus"
/>
<result
column=
"org_name"
property=
"orgName"
/>
</resultMap>
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id, user_name, password_hash, password_salt, create_time, update_time, org_id, permanent, effective_date, exired_date, status, phone, email, we_chat, telephone, is_deleted, real_name,type
</sql>
<select
id=
"selectByUsername"
resultMap=
"BaseResultMap"
>
select u.*,o.name org_name
from t_user u
left join t_organ o on o.id = u.org_id
where u.user_name =#{username}
</select>
</mapper>
src/main/resources/mapper/TUserRoleLinkMapper.xml
0 → 100644
View file @
29f30b14
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.wisenergy.chnmuseum.party.mapper.TUserRoleLinkMapper"
>
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"cn.wisenergy.chnmuseum.party.model.TUserRoleLink"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"user_id"
property=
"userId"
/>
<result
column=
"role_id"
property=
"roleId"
/>
<result
column=
"is_deleted"
property=
"isDeleted"
/>
</resultMap>
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id, user_id, role_id, is_deleted
</sql>
</mapper>
src/main/resources/mapper/TUserRoleMapper.xml
0 → 100644
View file @
29f30b14
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.wisenergy.chnmuseum.party.mapper.TUserRoleMapper"
>
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"cn.wisenergy.chnmuseum.party.model.TUserRole"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"user_id"
property=
"userId"
/>
<result
column=
"role_id"
property=
"roleId"
/>
<result
column=
"is_deleted"
property=
"isDeleted"
/>
</resultMap>
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id, user_id, role_id, is_deleted
</sql>
</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