Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-microservice-exam
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
汪想
spring-microservice-exam
Commits
4a5971c6
Commit
4a5971c6
authored
Apr 11, 2019
by
tangyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配置、权限等优化
parent
8a2ca63e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
58 changed files
with
468 additions
and
540 deletions
+468
-540
CrudMapper.java
...com/github/tangyi/common/core/persistence/CrudMapper.java
+8
-0
CrudService.java
...va/com/github/tangyi/common/core/service/CrudService.java
+10
-0
SecurityConstant.java
...hub/tangyi/common/security/constant/SecurityConstant.java
+13
-3
UserDetailsImpl.java
...m/github/tangyi/common/security/core/UserDetailsImpl.java
+20
-2
auth-service.yml
config-service/src/main/resources/config/auth-service.yml
+9
-3
exam-service.yml
config-service/src/main/resources/config/exam-service.yml
+9
-3
user-service.yml
config-service/src/main/resources/config/user-service.yml
+15
-3
GatewayServiceApplication.java
.../com/github/tangyi/gateway/GatewayServiceApplication.java
+0
-4
GatewayExceptionHandler.java
...ithub/tangyi/gateway/handler/GatewayExceptionHandler.java
+1
-1
pom.xml
pom.xml
+2
-10
pom.xml
service-api-impl/auth-service/pom.xml
+0
-6
MybatisConfig.java
...ain/java/com/github/tangyi/auth/config/MybatisConfig.java
+0
-31
UserDetailsServiceImpl.java
...om/github/tangyi/auth/service/UserDetailsServiceImpl.java
+13
-14
bootstrap.yml
...ce-api-impl/auth-service/src/main/resources/bootstrap.yml
+2
-1
OauthClientMapper.xml
...h-service/src/main/resources/mapper/OauthClientMapper.xml
+1
-1
mybatis-config.xml
...i-impl/auth-service/src/main/resources/mybatis-config.xml
+0
-16
pom.xml
service-api-impl/exam-service/pom.xml
+0
-6
MybatisConfig.java
...ain/java/com/github/tangyi/exam/config/MybatisConfig.java
+0
-33
ExamRecordController.java
...m/github/tangyi/exam/controller/ExamRecordController.java
+0
-0
ExaminationController.java
.../github/tangyi/exam/controller/ExaminationController.java
+15
-16
IncorrectAnswerController.java
...hub/tangyi/exam/controller/IncorrectAnswerController.java
+10
-15
KnowledgeController.java
...om/github/tangyi/exam/controller/KnowledgeController.java
+23
-16
SubjectBankController.java
.../github/tangyi/exam/controller/SubjectBankController.java
+19
-16
SubjectCategoryController.java
...hub/tangyi/exam/controller/SubjectCategoryController.java
+13
-7
SubjectController.java
.../com/github/tangyi/exam/controller/SubjectController.java
+20
-18
AnswerService.java
...in/java/com/github/tangyi/exam/service/AnswerService.java
+33
-32
AnswerMapper.xml
...l/exam-service/src/main/resources/mapper/AnswerMapper.xml
+1
-1
CourseMapper.xml
...l/exam-service/src/main/resources/mapper/CourseMapper.xml
+1
-1
ExamRecodeMapper.xml
...am-service/src/main/resources/mapper/ExamRecodeMapper.xml
+1
-1
ExaminationMapper.xml
...m-service/src/main/resources/mapper/ExaminationMapper.xml
+1
-1
IncorrectAnswerMapper.xml
...rvice/src/main/resources/mapper/IncorrectAnswerMapper.xml
+1
-1
KnowledgeMapper.xml
...xam-service/src/main/resources/mapper/KnowledgeMapper.xml
+1
-1
SubjectBankMapper.xml
...m-service/src/main/resources/mapper/SubjectBankMapper.xml
+1
-1
SubjectCategoryMapper.xml
...rvice/src/main/resources/mapper/SubjectCategoryMapper.xml
+1
-1
SubjectMapper.xml
.../exam-service/src/main/resources/mapper/SubjectMapper.xml
+1
-1
mybatis-config.xml
...i-impl/exam-service/src/main/resources/mybatis-config.xml
+0
-16
pom.xml
service-api-impl/user-service/pom.xml
+0
-6
MybatisConfig.java
...ain/java/com/github/tangyi/user/config/MybatisConfig.java
+0
-33
RabbitConfig.java
...main/java/com/github/tangyi/user/config/RabbitConfig.java
+11
-0
AttachmentController.java
...m/github/tangyi/user/controller/AttachmentController.java
+5
-5
DeptController.java
...ava/com/github/tangyi/user/controller/DeptController.java
+23
-15
MenuController.java
...ava/com/github/tangyi/user/controller/MenuController.java
+48
-49
RoleController.java
...ava/com/github/tangyi/user/controller/RoleController.java
+14
-16
UserController.java
...ava/com/github/tangyi/user/controller/UserController.java
+57
-67
AttachmentService.java
...ava/com/github/tangyi/user/service/AttachmentService.java
+0
-2
MenuService.java
...main/java/com/github/tangyi/user/service/MenuService.java
+15
-6
UserService.java
...main/java/com/github/tangyi/user/service/UserService.java
+26
-27
AttachmentMapper.xml
...er-service/src/main/resources/mapper/AttachmentMapper.xml
+1
-1
DeptMapper.xml
...mpl/user-service/src/main/resources/mapper/DeptMapper.xml
+1
-1
LogMapper.xml
...impl/user-service/src/main/resources/mapper/LogMapper.xml
+1
-1
MenuMapper.xml
...mpl/user-service/src/main/resources/mapper/MenuMapper.xml
+9
-1
RoleDeptMapper.xml
...user-service/src/main/resources/mapper/RoleDeptMapper.xml
+3
-3
RoleMapper.xml
...mpl/user-service/src/main/resources/mapper/RoleMapper.xml
+1
-1
RoleMenuMapper.xml
...user-service/src/main/resources/mapper/RoleMenuMapper.xml
+3
-3
RouteMapper.xml
...pl/user-service/src/main/resources/mapper/RouteMapper.xml
+1
-1
UserMapper.xml
...mpl/user-service/src/main/resources/mapper/UserMapper.xml
+1
-1
UserRoleMapper.xml
...user-service/src/main/resources/mapper/UserRoleMapper.xml
+3
-3
mybatis-config.xml
...i-impl/user-service/src/main/resources/mybatis-config.xml
+0
-16
No files found.
common/common-core/src/main/java/com/github/tangyi/common/core/persistence/CrudMapper.java
View file @
4a5971c6
...
...
@@ -27,6 +27,14 @@ public interface CrudMapper<T> extends BaseMapper {
List
<
T
>
findList
(
T
entity
);
/**
* 获取全部列表数据
*
* @param entity entity
* @return List
*/
List
<
T
>
findAllList
(
T
entity
);
/**
* 根据id获取列表数据
*
* @param entity entity
...
...
common/common-core/src/main/java/com/github/tangyi/common/core/service/CrudService.java
View file @
4a5971c6
...
...
@@ -60,6 +60,16 @@ public abstract class CrudService<D extends CrudMapper<T>, T extends BaseEntity<
* @param entity entity
* @return List
*/
public
List
<
T
>
findAllList
(
T
entity
)
{
return
dao
.
findList
(
entity
);
}
/**
* 查询列表
*
* @param entity entity
* @return List
*/
public
List
<
T
>
findListById
(
T
entity
)
{
return
dao
.
findListById
(
entity
);
}
...
...
common/common-security/src/main/java/com/github/tangyi/common/security/constant/SecurityConstant.java
View file @
4a5971c6
...
...
@@ -9,17 +9,17 @@ public class SecurityConstant {
/**
* 基础角色
*/
public
static
final
String
BASE_ROLE
=
"
ROLE_USER
"
;
public
static
final
String
BASE_ROLE
=
"
role_user
"
;
/**
* 管理员角色
*/
public
static
final
String
ROLE_ADMIN
=
"
ROLE_ADMIN
"
;
public
static
final
String
ROLE_ADMIN
=
"
role_admin
"
;
/**
* 老师角色
*/
public
static
final
String
ROLE_TEACHER
=
"
ROLE_TEACHER
"
;
public
static
final
String
ROLE_TEACHER
=
"
role_teacher
"
;
/**
* token
...
...
@@ -35,4 +35,14 @@ public class SecurityConstant {
* oauth 客户端信息
*/
public
static
final
String
CLIENT_DETAILS_KEY
=
"exam_oauth:client:details"
;
/**
* 正常状态
*/
public
static
final
String
NORMAL
=
"0"
;
/**
* 异常状态
*/
public
static
final
String
ABNORMAL
=
"1"
;
}
common/common-security/src/main/java/com/github/tangyi/common/security/core/UserDetailsImpl.java
View file @
4a5971c6
package
com
.
github
.
tangyi
.
common
.
security
.
core
;
import
com.github.tangyi.common.security.constant.SecurityConstant
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.userdetails.UserDetails
;
...
...
@@ -15,14 +16,31 @@ public class UserDetailsImpl implements UserDetails {
private
static
final
long
serialVersionUID
=
-
6509897037222767090L
;
/**
* 权限
*/
private
Set
<
GrantedAuthority
>
authorities
;
/**
* 密码
*/
private
String
password
;
/**
* 用户名
*/
private
String
username
;
public
UserDetailsImpl
(
String
username
,
String
password
,
Set
<
GrantedAuthority
>
authorities
)
{
/**
* 启用禁用状态
*/
private
String
status
;
public
UserDetailsImpl
(
String
username
,
String
password
,
String
status
,
Set
<
GrantedAuthority
>
authorities
)
{
this
.
authorities
=
authorities
;
this
.
username
=
username
;
this
.
password
=
password
;
this
.
status
=
status
;
}
@Override
...
...
@@ -57,6 +75,6 @@ public class UserDetailsImpl implements UserDetails {
@Override
public
boolean
isEnabled
()
{
return
true
;
return
SecurityConstant
.
NORMAL
.
equals
(
this
.
status
)
;
}
}
config-service/src/main/resources/config/auth-service.yml
View file @
4a5971c6
...
...
@@ -5,7 +5,7 @@ spring:
url
:
jdbc:mysql://${MYSQL_HOST:192.168.0.144}:${MYSQL_PORT:3306}/microservice-auth?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
username
:
${MYSQL_USERNAME:platform}
password
:
${MYSQL_PASSWORD:11}
type
:
com.
alibaba.druid.pool.Druid
DataSource
type
:
com.
zaxxer.hikari.Hikari
DataSource
driver-class-name
:
com.mysql.jdbc.Driver
redis
:
host
:
${REDIS_HOST:192.168.0.213}
...
...
@@ -57,9 +57,15 @@ management:
health
:
show-details
:
ALWAYS
# mybatis配置
mybatis
:
mapperLocations
:
classpath:mapper/*.xml
configLocation
:
classpath:/mybatis-config.xml
type-aliases-package
:
com.github.tangyi.auth.api.module
configuration
:
# 驼峰转换
map-underscore-to-camel-case
:
true
# 延迟加载
lazy-loading-enabled
:
true
mapper-locations
:
classpath:mapper/*.xml
pagehelper
:
helperDialect
:
mysql
reasonable
:
true
...
...
config-service/src/main/resources/config/exam-service.yml
View file @
4a5971c6
...
...
@@ -5,7 +5,7 @@ spring:
url
:
jdbc:mysql://${MYSQL_HOST:192.168.0.144}:${MYSQL_PORT:3306}/microservice-exam?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
username
:
${MYSQL_USERNAME:platform}
password
:
${MYSQL_PASSWORD:11}
type
:
com.
alibaba.druid.pool.Druid
DataSource
type
:
com.
zaxxer.hikari.Hikari
DataSource
driver-class-name
:
com.mysql.jdbc.Driver
redis
:
host
:
${REDIS_HOST:192.168.0.213}
...
...
@@ -48,9 +48,15 @@ security:
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAimUKhvBhsoeSM3HkIOP/Y3RXjvonBlZnLj8oO92TyAKG53lmAoK0wZ5MTZPsfrOz2Z7CeAp6mPhUANX2RUoFwVzG7rJmgWyqGmGFNBmtYL+uVqQ80TzWi5zyzXTxgVMWiCqqw/u4AeE1qhN8chnGwhUBnpgPAPd8v57mIwg0n5JxjdYe7pgHlpvt8ZXTXd1KBxB5K7WjNlCfMf75ZEeBaplxsSfJUwKbnHQKWcY3NnpjkVR8y4jviAbkOHmGMaliM7fcsLzbosBUPDQuNlvYdjPBRfH6MMPeXRW6On3u0Um9wIYmkQS+AEgHCq4UuLOnTTqqxnGkwFYeMAAXmRyMtQIDAQAB
-----END PUBLIC KEY-----
# mybatis配置
mybatis
:
mapperLocations
:
classpath:mapper/*.xml
configLocation
:
classpath:/mybatis-config.xml
type-aliases-package
:
com.github.tangyi.exam.api.module
configuration
:
# 驼峰转换
map-underscore-to-camel-case
:
true
# 延迟加载
lazy-loading-enabled
:
true
mapper-locations
:
classpath:mapper/*.xml
pagehelper
:
helperDialect
:
mysql
reasonable
:
true
...
...
config-service/src/main/resources/config/user-service.yml
View file @
4a5971c6
server
:
port
:
8082
spring
:
servlet
:
multipart
:
# 单个文件的大小
max-file-size
:
10MB
# 单次请求的文件的总大小
max-request-size
:
100MB
datasource
:
url
:
jdbc:mysql://${MYSQL_HOST:192.168.0.144}:${MYSQL_PORT:3306}/microservice-user?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
username
:
${MYSQL_USERNAME:platform}
password
:
${MYSQL_PASSWORD:11}
type
:
com.
alibaba.druid.pool.Druid
DataSource
type
:
com.
zaxxer.hikari.Hikari
DataSource
driver-class-name
:
com.mysql.jdbc.Driver
redis
:
host
:
${REDIS_HOST:192.168.0.213}
...
...
@@ -48,9 +54,15 @@ security:
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAimUKhvBhsoeSM3HkIOP/Y3RXjvonBlZnLj8oO92TyAKG53lmAoK0wZ5MTZPsfrOz2Z7CeAp6mPhUANX2RUoFwVzG7rJmgWyqGmGFNBmtYL+uVqQ80TzWi5zyzXTxgVMWiCqqw/u4AeE1qhN8chnGwhUBnpgPAPd8v57mIwg0n5JxjdYe7pgHlpvt8ZXTXd1KBxB5K7WjNlCfMf75ZEeBaplxsSfJUwKbnHQKWcY3NnpjkVR8y4jviAbkOHmGMaliM7fcsLzbosBUPDQuNlvYdjPBRfH6MMPeXRW6On3u0Um9wIYmkQS+AEgHCq4UuLOnTTqqxnGkwFYeMAAXmRyMtQIDAQAB
-----END PUBLIC KEY-----
# mybatis配置
mybatis
:
mapperLocations
:
classpath:mapper/*.xml
configLocation
:
classpath:/mybatis-config.xml
type-aliases-package
:
com.github.tangyi.user.api.module
configuration
:
# 驼峰转换
map-underscore-to-camel-case
:
true
# 延迟加载
lazy-loading-enabled
:
true
mapper-locations
:
classpath:mapper/*.xml
pagehelper
:
helperDialect
:
mysql
reasonable
:
true
...
...
gateway-service/src/main/java/com/github/tangyi/gateway/GatewayServiceApplication.java
View file @
4a5971c6
...
...
@@ -5,16 +5,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.context.annotation.ComponentScan
;
@EnableDiscoveryClient
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
})
// 配置包扫描,排查Swagger配置
@ComponentScan
(
basePackages
=
{
"com.github.tangyi"
})
@EnableCircuitBreaker
// 动态刷新
@RefreshScope
public
class
GatewayServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
gateway-service/src/main/java/com/github/tangyi/gateway/handler/GatewayExceptionHandler.java
View file @
4a5971c6
...
...
@@ -123,7 +123,7 @@ public class GatewayExceptionHandler implements ErrorWebExceptionHandler {
}
pr
otected
Mono
<
ServerResponse
>
renderErrorResponse
(
ServerRequest
request
)
{
pr
ivate
Mono
<
ServerResponse
>
renderErrorResponse
(
ServerRequest
request
)
{
ResponseBean
<?>
responseBean
=
exceptionHandlerResult
.
get
();
return
ServerResponse
.
status
(
responseBean
.
getStatus
())
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
)
...
...
pom.xml
View file @
4a5971c6
...
...
@@ -54,7 +54,6 @@
<!--<spring-boot-devtools.version>2.0.4.RELEASE</spring-boot-devtools.version>-->
<zipkin.version>
2.11.3
</zipkin.version>
<swagger.version>
2.9.2
</swagger.version>
<driud.version>
1.1.4
</driud.version>
<fastdfs-client.version>
1.26.5
</fastdfs-client.version>
<mysql.connector.version>
8.0.13
</mysql.connector.version>
<!-- common-->
...
...
@@ -65,8 +64,8 @@
<!-- 其它依赖 -->
<hibernate-validator.version>
6.0.14.Final
</hibernate-validator.version>
<mybatis.version>
1.1
.1
</mybatis.version>
<pagehelper.version>
1.2.
3
</pagehelper.version>
<mybatis.version>
2.0
.1
</mybatis.version>
<pagehelper.version>
1.2.
10
</pagehelper.version>
<poi.version>
3.9
</poi.version>
<xmlbeans.version>
2.3.0
</xmlbeans.version>
<hutool.version>
4.5.0
</hutool.version>
...
...
@@ -226,13 +225,6 @@
<version>
${mysql.connector.version}
</version>
</dependency>
<!-- druid阿里巴巴数据库连接池 -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
${driud.version}
</version>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
...
...
service-api-impl/auth-service/pom.xml
View file @
4a5971c6
...
...
@@ -77,12 +77,6 @@
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<!-- druid阿里巴巴数据库连接池 -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
...
...
service-api-impl/auth-service/src/main/java/com/github/tangyi/auth/config/MybatisConfig.java
deleted
100644 → 0
View file @
8a2ca63e
package
com
.
github
.
tangyi
.
auth
.
config
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.transaction.annotation.TransactionManagementConfigurer
;
import
javax.sql.DataSource
;
/**
* @author tangyi
* @date 2019/3/30 23:48
*/
@Configuration
@EnableTransactionManagement
public
class
MybatisConfig
implements
TransactionManagementConfigurer
{
private
final
DataSource
dataSource
;
@Autowired
public
MybatisConfig
(
DataSource
dataSource
)
{
this
.
dataSource
=
dataSource
;
}
@Override
public
PlatformTransactionManager
annotationDrivenTransactionManager
()
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
}
service-api-impl/auth-service/src/main/java/com/github/tangyi/auth/service/UserDetailsServiceImpl.java
View file @
4a5971c6
...
...
@@ -4,11 +4,10 @@ import com.github.tangyi.common.core.vo.Role;
import
com.github.tangyi.common.core.vo.UserVo
;
import
com.github.tangyi.common.security.core.GrantedAuthorityImpl
;
import
com.github.tangyi.common.security.core.UserDetailsImpl
;
import
com.github.tangyi.user.api.constant.MenuConstant
;
import
com.github.tangyi.user.api.feign.UserServiceClient
;
import
com.github.tangyi.user.api.module.Menu
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.userdetails.UserDetails
;
...
...
@@ -18,7 +17,9 @@ import org.springframework.stereotype.Service;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.stream.Stream
;
/**
* 模拟从数据库获取用户信息
...
...
@@ -29,8 +30,6 @@ import java.util.Set;
@Service
public
class
UserDetailsServiceImpl
implements
UserDetailsService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserDetailsServiceImpl
.
class
);
@Autowired
private
UserServiceClient
userServiceClient
;
...
...
@@ -48,7 +47,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
UserVo
userVo
=
userServiceClient
.
findUserByUsername
(
username
);
if
(
userVo
==
null
)
throw
new
UsernameNotFoundException
(
"User name not found."
);
userDetails
=
new
UserDetailsImpl
(
username
,
userVo
.
getPassword
(),
getAuthority
(
userVo
));
userDetails
=
new
UserDetailsImpl
(
username
,
userVo
.
getPassword
(),
userVo
.
getStatus
(),
getAuthority
(
userVo
));
}
catch
(
Exception
e
)
{
throw
new
UsernameNotFoundException
(
"Exception occurred wile reading user info."
);
}
...
...
@@ -69,18 +68,18 @@ public class UserDetailsServiceImpl implements UserDetailsService {
// 角色
List
<
Role
>
roleList
=
userVo
.
getRoleList
();
if
(
CollectionUtils
.
isNotEmpty
(
roleList
))
{
for
(
Role
role
:
roleList
)
{
roleList
.
forEach
(
role
->
{
// 权限如果前缀是ROLE_,security就会认为这是个角色信息,而不是权限,例如ROLE_ADMIN就是ADMIN角色,MENU:ADD就是MENU:ADD权限
authorities
.
add
(
new
GrantedAuthorityImpl
(
role
.
getRoleCode
()
.
toUpperCase
()
));
authorities
.
add
(
new
GrantedAuthorityImpl
(
role
.
getRoleCode
()));
// 根据角色查找菜单权限
List
<
Menu
>
menuList
=
userServiceClient
.
findMenuByRole
(
role
.
getRoleCode
()
);
if
(
CollectionUtils
.
isNotEmpty
(
menuList
))
{
for
(
Menu
menu
:
menuList
)
{
// 菜单权限
authorities
.
add
(
new
GrantedAuthorityImpl
(
menu
.
getPermission
()));
}
Stream
<
Menu
>
menuStream
=
userServiceClient
.
findMenuByRole
(
role
.
getRoleCode
()).
stream
(
);
if
(
Optional
.
ofNullable
(
menuStream
).
isPresent
(
))
{
menuStream
// 菜单权限
.
filter
(
menu
->
MenuConstant
.
MENU_TYPE_PERMISSION
.
equals
(
menu
.
getType
()))
.
forEach
(
menu
->
authorities
.
add
(
new
GrantedAuthorityImpl
(
menu
.
getPermission
())));
}
}
}
);
}
return
authorities
;
}
...
...
service-api-impl/auth-service/src/main/resources/bootstrap.yml
View file @
4a5971c6
...
...
@@ -17,4 +17,4 @@ spring:
# 默认false,设为true表示使用注册中心中的配置服务(服务发现)而不自己指定配置服务的地址(即uri)
enabled
:
true
# 指向配置中心在consul注册的服务名称(即:spring.application.name)
service-id
:
config-service
service-id
:
config-service
\ No newline at end of file
service-api-impl/auth-service/src/main/resources/mapper/OauthClientMapper.xml
View file @
4a5971c6
...
...
@@ -23,7 +23,7 @@
</resultMap>
<sql
id=
"oauthClientColumns"
>
a.id
as "id"
,
a.id,
a.client_id,
a.resource_ids,
a.client_secret_plain_text,
...
...
service-api-impl/auth-service/src/main/resources/mybatis-config.xml
deleted
100644 → 0
View file @
8a2ca63e
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- 驼峰转换 -->
<setting
name=
"mapUnderscoreToCamelCase"
value=
"true"
/>
<!-- 延迟加载 -->
<setting
name=
"lazyLoadingEnabled"
value=
"true"
/>
</settings>
<typeAliases>
<package
name=
"com.tangyi.module"
/>
</typeAliases>
</configuration>
\ No newline at end of file
service-api-impl/exam-service/pom.xml
View file @
4a5971c6
...
...
@@ -72,12 +72,6 @@
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<!-- druid阿里巴巴数据库连接池 -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/config/MybatisConfig.java
deleted
100644 → 0
View file @
8a2ca63e
package
com
.
github
.
tangyi
.
exam
.
config
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.transaction.annotation.TransactionManagementConfigurer
;
import
javax.sql.DataSource
;
/**
* mybatis 配置
*
* @author tangyi
* @date 2019/3/16 21:03
*/
@Configuration
@EnableTransactionManagement
public
class
MybatisConfig
implements
TransactionManagementConfigurer
{
private
final
DataSource
dataSource
;
@Autowired
public
MybatisConfig
(
DataSource
dataSource
)
{
this
.
dataSource
=
dataSource
;
}
@Override
public
PlatformTransactionManager
annotationDrivenTransactionManager
()
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
}
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/ExamRecordController.java
View file @
4a5971c6
This diff is collapsed.
Click to expand it.
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/ExaminationController.java
View file @
4a5971c6
...
...
@@ -28,7 +28,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
import
org.springframework.web.bind.annotation.*
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 考试controller
...
...
@@ -101,29 +103,26 @@ public class ExaminationController extends BaseController {
PageInfo
<
Examination
>
page
=
examinationService
.
findPage
(
PageUtil
.
pageInfo
(
pageNum
,
pageSize
,
sort
,
order
),
examination
);
PageInfo
<
ExaminationDto
>
examinationDtoPageInfo
=
new
PageInfo
<>();
BeanUtils
.
copyProperties
(
page
,
examinationDtoPageInfo
);
List
<
ExaminationDto
>
examinationDtos
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
page
.
getList
()))
{
Set
<
String
>
courseIdSet
=
new
HashSet
<>();
page
.
getList
().
forEach
(
exam
->
{
courseIdSet
.
add
(
exam
.
getCourseId
());
});
Course
course
=
new
Course
();
course
.
setIds
(
courseIdSet
.
toArray
(
new
String
[
courseIdSet
.
size
()]));
// 流处理获取课程ID集合,转成字符串数组
course
.
setIds
(
page
.
getList
().
stream
().
map
(
Examination:
:
getCourseId
).
distinct
().
toArray
(
String
[]::
new
));
List
<
Course
>
courses
=
courseService
.
findListById
(
course
);
// 当前时间
String
currentTime
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
());
page
.
getList
().
forEach
(
exam
->
{
// 流处理转成Dto集合
List
<
ExaminationDto
>
examinationDtos
=
page
.
getList
().
stream
().
map
(
exam
->
{
ExaminationDto
examinationDto
=
new
ExaminationDto
();
BeanUtils
.
copyProperties
(
exam
,
examinationDto
);
examinationDto
.
setCurrentTime
(
currentTime
);
courses
.
forEach
(
tempCourse
->
{
if
(
tempCourse
.
getId
().
equals
(
exam
.
getCourseId
()))
{
examinationDto
.
setCourse
(
tempCourse
);
}
})
;
examinationDtos
.
add
(
examinationDto
);
}
);
// 设置考试所属课程
Course
examinationCourse
=
courses
.
stream
().
filter
(
tempCourse
->
tempCourse
.
getId
().
equals
(
exam
.
getCourseId
())).
findFirst
().
orElse
(
null
);
if
(
examinationCourse
!=
null
)
examinationDto
.
setCourse
(
examinationCourse
);
return
examinationDto
;
}).
collect
(
Collectors
.
toList
()
);
examinationDtoPageInfo
.
setList
(
examinationDtos
);
}
examinationDtoPageInfo
.
setList
(
examinationDtos
);
return
examinationDtoPageInfo
;
}
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/IncorrectAnswerController.java
View file @
4a5971c6
...
...
@@ -26,9 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* 错题controller
...
...
@@ -100,24 +98,21 @@ public class IncorrectAnswerController extends BaseController {
PageInfo
<
IncorrectAnswerDto
>
pageInfo
=
new
PageInfo
<>();
List
<
IncorrectAnswerDto
>
incorrectAnswerDtoList
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
incorrectAnswerPageInfo
.
getList
()))
{
Set
<
String
>
subjectIds
=
new
HashSet
<>();
incorrectAnswerPageInfo
.
getList
().
forEach
(
incorrect
->
{
subjectIds
.
add
(
incorrect
.
getSubjectId
());
});
Subject
subject
=
new
Subject
();
subject
.
setIds
(
subjectIds
.
toArray
(
new
String
[
subjectIds
.
size
()]));
// 获取题目ID
subject
.
setIds
(
incorrectAnswerPageInfo
.
getList
().
stream
().
map
(
IncorrectAnswer:
:
getSubjectId
).
distinct
().
toArray
(
String
[]::
new
));
// 查找题目
List
<
Subject
>
subjects
=
subjectService
.
findListById
(
subject
);
if
(
CollectionUtils
.
isNotEmpty
(
subjects
))
{
subjects
.
forEach
(
tempSubject
->
{
incorrectAnswerPageInfo
.
getList
().
forEach
(
tempIncorrectAnswer
->
{
if
(
tempSubject
.
getId
().
equalsIgnoreCase
(
tempIncorrectAnswer
.
getSubjectId
()))
{
IncorrectAnswerDto
incorrectAnswerDto
=
new
IncorrectAnswerDto
();
BeanUtils
.
copyProperties
(
tempSubject
,
incorrectAnswerDto
);
incorrectAnswerDto
.
setIncorrectAnswer
(
tempIncorrectAnswer
.
getIncorrectAnswer
()
);
incorrectAnswerDtoList
.
add
(
incorrectAnswerDto
);
}
});
incorrectAnswerPageInfo
.
getList
().
stream
()
.
filter
(
tempIncorrectAnswer
->
tempSubject
.
getId
().
equalsIgnoreCase
(
tempIncorrectAnswer
.
getSubjectId
()))
.
forEach
(
tempIncorrectAnswer
->
{
IncorrectAnswerDto
incorrectAnswerDto
=
new
IncorrectAnswerDto
(
);
BeanUtils
.
copyProperties
(
tempSubject
,
incorrectAnswerDto
);
incorrectAnswerDto
.
setIncorrectAnswer
(
tempIncorrectAnswer
.
getIncorrectAnswer
()
);
incorrectAnswerDtoList
.
add
(
incorrectAnswerDto
);
});
});
}
}
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/KnowledgeController.java
View file @
4a5971c6
...
...
@@ -99,31 +99,38 @@ public class KnowledgeController extends BaseController {
PageInfo
<
Knowledge
>
knowledgePageInfo
=
knowledgeService
.
findPage
(
PageUtil
.
pageInfo
(
pageNum
,
pageSize
,
sort
,
order
),
knowledge
);
PageInfo
<
KnowledgeDto
>
knowledgeDtoPageInfo
=
new
PageInfo
<>();
List
<
KnowledgeDto
>
knowledgeDtoList
=
new
ArrayList
<>();
// 查询附件
Set
<
String
>
attachmentIdSet
=
new
HashSet
<>();
knowledgePageInfo
.
getList
().
forEach
(
tempKnowledge
->
{
attachmentIdSet
.
add
(
tempKnowledge
.
getAttachmentId
());
});
AttachmentVo
attachmentVo
=
new
AttachmentVo
();
attachmentVo
.
setIds
(
attachmentIdSet
.
toArray
(
new
String
[
attachmentIdSet
.
size
()
]));
attachmentVo
.
setIds
(
attachmentIdSet
.
toArray
(
new
String
[
0
]));
// 根据附件ID查询附件
ResponseBean
<
List
<
AttachmentVo
>>
returnT
=
userServiceClient
.
findAttachmentById
(
attachmentVo
);
for
(
Knowledge
tempKnowledge
:
knowledgePageInfo
.
getList
())
{
KnowledgeDto
knowledgeDto
=
new
KnowledgeDto
();
BeanUtils
.
copyProperties
(
tempKnowledge
,
knowledgeDto
);
if
(
returnT
!=
null
&&
CollectionUtils
.
isNotEmpty
(
returnT
.
getData
()))
{
for
(
AttachmentVo
tempAttachmentVo
:
returnT
.
getData
())
{
// 设置附件名称和大小
if
(
tempAttachmentVo
.
getId
().
equals
(
tempKnowledge
.
getAttachmentId
()))
{
knowledgeDto
.
setAttachName
(
tempAttachmentVo
.
getAttachName
());
knowledgeDto
.
setAttachSize
(
tempAttachmentVo
.
getAttachSize
());
break
;
knowledgePageInfo
.
getList
().
stream
()
// 转成Dto
.
map
(
tempKnowledge
->
{
KnowledgeDto
knowledgeDto
=
new
KnowledgeDto
();
BeanUtils
.
copyProperties
(
tempKnowledge
,
knowledgeDto
);
return
knowledgeDto
;
})
// 遍历
.
forEach
(
tempKnowledgeDto
->
{
if
(
returnT
!=
null
&&
CollectionUtils
.
isNotEmpty
(
returnT
.
getData
()))
{
AttachmentVo
tempKnowledgeDtoAttachmentVo
=
returnT
.
getData
().
stream
()
// 根据ID过滤
.
filter
(
tempAttachmentVo
->
tempAttachmentVo
.
getId
().
equals
(
tempKnowledgeDto
.
getAttachmentId
()))
// 匹配第一个
.
findFirst
().
orElse
(
null
);
// 设置附件名称、附件大小
if
(
tempKnowledgeDtoAttachmentVo
!=
null
)
{
tempKnowledgeDto
.
setAttachName
(
tempKnowledgeDtoAttachmentVo
.
getAttachName
());
tempKnowledgeDto
.
setAttachSize
(
tempKnowledgeDtoAttachmentVo
.
getAttachSize
());
}
}
}
}
knowledgeDtoList
.
add
(
knowledgeDto
);
}
knowledgeDtoList
.
add
(
tempKnowledgeDto
);
});
knowledgeDtoPageInfo
.
setList
(
knowledgeDtoList
);
knowledgeDtoPageInfo
.
setTotal
(
knowledgePageInfo
.
getTotal
());
knowledgeDtoPageInfo
.
setPageNum
(
knowledgePageInfo
.
getPageNum
());
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/SubjectBankController.java
View file @
4a5971c6
...
...
@@ -28,7 +28,11 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Stream
;
/**
* 题库controller
...
...
@@ -98,22 +102,21 @@ public class SubjectBankController extends BaseController {
PageInfo
<
SubjectBank
>
page
=
subjectBankService
.
findPage
(
PageUtil
.
pageInfo
(
pageNum
,
pageSize
,
sort
,
order
),
subjectBank
);
if
(
CollectionUtils
.
isNotEmpty
(
page
.
getList
()))
{
// 查询分类信息
Set
<
String
>
categoryIdSet
=
new
HashSet
<>();
page
.
getList
().
forEach
(
tempSubjectBank
->
{
categoryIdSet
.
add
(
tempSubjectBank
.
getCategoryId
());
});
SubjectCategory
subjectCategory
=
new
SubjectCategory
();
subjectCategory
.
setIds
(
categoryIdSet
.
toArray
(
new
String
[
categoryIdSet
.
size
()]));
List
<
SubjectCategory
>
subjectCategoryList
=
subjectCategoryService
.
findListById
(
subjectCategory
);
page
.
getList
().
forEach
(
tempSubjectBank
->
{
for
(
SubjectCategory
tempSubjectCategory
:
subjectCategoryList
)
{
if
(
tempSubjectCategory
.
getId
().
equals
(
tempSubjectBank
.
getCategoryId
()))
{
// 设置分类名称
tempSubjectBank
.
setCategoryName
(
tempSubjectCategory
.
getCategoryName
());
break
;
}
}
});
// 流处理获取分类ID,去重,转成字符串数组
subjectCategory
.
setIds
(
page
.
getList
().
stream
().
map
(
SubjectBank:
:
getCategoryId
).
distinct
().
toArray
(
String
[]::
new
));
Stream
<
SubjectCategory
>
subjectCategoryStream
=
subjectCategoryService
.
findListById
(
subjectCategory
).
stream
();
if
(
Optional
.
ofNullable
(
subjectCategoryStream
).
isPresent
())
{
page
.
getList
().
forEach
(
tempSubjectBank
->
{
SubjectCategory
category
=
subjectCategoryStream
.
filter
(
tempSubjectCategory
->
tempSubjectCategory
.
getId
().
equals
(
tempSubjectBank
.
getCategoryId
()))
.
findFirst
()
.
orElse
(
null
);
// 设置分类名称
if
(
category
!=
null
)
tempSubjectBank
.
setCategoryName
(
category
.
getCategoryName
());
});
}
}
return
page
;
}
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/SubjectCategoryController.java
View file @
4a5971c6
...
...
@@ -14,12 +14,16 @@ import com.github.tangyi.exam.service.SubjectCategoryService;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 题目分类controller
...
...
@@ -46,12 +50,14 @@ public class SubjectCategoryController extends BaseController {
@ApiOperation
(
value
=
"获取分类列表"
)
public
List
<
SubjectCategoryDto
>
menus
()
{
// 查询所有分类
Set
<
SubjectCategory
>
subjectCategorySet
=
new
HashSet
<
SubjectCategory
>(
categoryService
.
findList
(
new
SubjectCategory
()));
List
<
SubjectCategoryDto
>
subjectCategorySetTreeList
=
new
ArrayList
<
SubjectCategoryDto
>();
subjectCategorySet
.
forEach
(
subjectCategory
->
subjectCategorySetTreeList
.
add
(
new
SubjectCategoryDto
(
subjectCategory
)));
// 排序
CollUtil
.
sort
(
subjectCategorySetTreeList
,
Comparator
.
comparingInt
(
SubjectCategoryDto:
:
getSort
));
return
TreeUtil
.
buildTree
(
subjectCategorySetTreeList
,
"-1"
);
List
<
SubjectCategory
>
subjectCategoryList
=
categoryService
.
findList
(
new
SubjectCategory
());
if
(
CollectionUtils
.
isNotEmpty
(
subjectCategoryList
))
{
// 转成dto
List
<
SubjectCategoryDto
>
subjectCategorySetTreeList
=
subjectCategoryList
.
stream
().
map
(
SubjectCategoryDto:
:
new
).
distinct
().
collect
(
Collectors
.
toList
());
// 排序、组装树形结构
return
TreeUtil
.
buildTree
(
CollUtil
.
sort
(
subjectCategorySetTreeList
,
Comparator
.
comparingInt
(
SubjectCategoryDto:
:
getSort
)),
"-1"
);
}
return
new
ArrayList
<>();
}
/**
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/SubjectController.java
View file @
4a5971c6
...
...
@@ -33,9 +33,9 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.SimpleDateFormat
;
import
java.util.
ArrayList
;
import
java.util.
Date
;
import
java.util.
List
;
import
java.util.
*
;
import
java.util.
stream.Collectors
;
import
java.util.
stream.Stream
;
/**
* 题目controller
...
...
@@ -214,13 +214,15 @@ public class SubjectController extends BaseController {
List
<
Subject
>
subjects
=
new
ArrayList
<>();
// 根据题目id导出
if
(
StringUtils
.
isNotEmpty
(
subjectDto
.
getIdString
()))
{
for
(
String
id
:
subjectDto
.
getIdString
().
split
(
","
))
{
Subject
subject
=
new
Subject
();
subject
.
setId
(
id
);
subject
=
subjectService
.
get
(
subject
);
if
(
subject
!=
null
)
subjects
.
add
(
subject
);
}
subjects
=
Stream
.
of
(
subjectDto
.
getIdString
().
split
(
","
))
// 根据ID查找题目信息
.
map
(
id
->
{
Subject
subject
=
new
Subject
();
subject
.
setId
(
id
);
return
subjectService
.
get
(
subject
);
})
// 过滤收集
.
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
}
else
if
(
StringUtils
.
isNotEmpty
(
subjectDto
.
getExaminationId
()))
{
// 根据考试id导出
Subject
subject
=
new
Subject
();
subject
.
setExaminationId
(
subjectDto
.
getExaminationId
());
...
...
@@ -251,17 +253,17 @@ public class SubjectController extends BaseController {
Assert
.
notNull
(
examinationId
,
CommonConstant
.
IllEGAL_ARGUMENT
);
try
{
logger
.
debug
(
"开始导入题目数据,分类ID:{}"
,
examinationId
);
List
<
Subject
>
subjects
=
MapUtil
.
map2Java
(
Subject
.
class
,
ExcelToolUtil
.
importExcel
(
file
.
getInputStream
(),
SubjectUtil
.
getSubjectMap
()));
if
(
CollectionUtils
.
isNotEmpty
(
subjects
))
{
for
(
Subject
subject
:
subjects
)
{
Stream
<
Subject
>
subjectStream
=
MapUtil
.
map2Java
(
Subject
.
class
,
ExcelToolUtil
.
importExcel
(
file
.
getInputStream
(),
SubjectUtil
.
getSubjectMap
()))
.
stream
()
;
if
(
Optional
.
ofNullable
(
subjectStream
).
isPresent
(
))
{
subjectStream
.
forEach
(
subject
->
{
// 初始化考试ID
if
(
StringUtils
.
isBlank
(
subject
.
getId
()))
{
subject
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
(),
SysUtil
.
getSysCode
());
subject
.
setExaminationId
(
examinationId
);
subjectService
.
insert
(
subject
);
}
}
}
);
// 更新考试的题目数
Examination
examination
=
new
Examination
();
examination
.
setId
(
examinationId
);
...
...
@@ -297,9 +299,9 @@ public class SubjectController extends BaseController {
success
=
subjectService
.
deleteAll
(
subjectIds
)
>
0
;
Subject
subject
=
new
Subject
();
subject
.
setIds
(
subjectIds
);
List
<
Subject
>
subjectList
=
subjectService
.
findListById
(
subject
);
if
(
CollectionUtils
.
isNotEmpty
(
subjectList
))
{
subject
List
.
forEach
(
tempSubject
->
{
Stream
<
Subject
>
subjectStream
=
subjectService
.
findListById
(
subject
).
stream
(
);
if
(
Optional
.
ofNullable
(
subjectStream
).
isPresent
(
))
{
subject
Stream
.
forEach
(
tempSubject
->
{
// 更新考试的题目数
Examination
examination
=
new
Examination
();
examination
.
setId
(
tempSubject
.
getExaminationId
());
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/service/AnswerService.java
View file @
4a5971c6
...
...
@@ -3,11 +3,11 @@ package com.github.tangyi.exam.service;
import
com.github.tangyi.common.core.service.CrudService
;
import
com.github.tangyi.common.core.utils.SysUtil
;
import
com.github.tangyi.common.security.utils.SecurityUtil
;
import
com.github.tangyi.exam.mapper.AnswerMapper
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.api.module.ExamRecord
;
import
com.github.tangyi.exam.api.module.IncorrectAnswer
;
import
com.github.tangyi.exam.api.module.Subject
;
import
com.github.tangyi.exam.mapper.AnswerMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
...
...
@@ -16,9 +16,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* 答题service
...
...
@@ -38,9 +36,6 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
@Autowired
private
ExamRecordService
examRecordService
;
@Autowired
private
ExaminationService
examinationService
;
/**
* 查找答题
*
...
...
@@ -57,6 +52,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
/**
* 根据用户ID、考试ID、考试记录ID、题目ID查找答题
*
* @param answer answer
* @return Answer
* @author tangyi
...
...
@@ -121,37 +117,43 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
*/
@Transactional
public
boolean
submit
(
Answer
answer
)
{
long
start
=
System
.
currentTimeMillis
();
boolean
success
=
false
;
logger
.
debug
(
"提交答卷:{}, {}"
,
answer
.
getExaminationId
(),
answer
.
getUserId
());
// 总分
Integer
totalScore
=
0
,
correctNumber
=
0
,
incorrectNumber
=
0
;
String
currentUsername
=
SecurityUtil
.
getCurrentUsername
();
// 查找已提交的题目
List
<
Answer
>
answerList
=
findList
(
answer
);
if
(
CollectionUtils
.
isNotEmpty
(
answerList
))
{
// 收集题目id
Set
<
String
>
subjectIdSet
=
new
HashSet
<>();
answerList
.
forEach
(
tempAnswer
->
{
subjectIdSet
.
add
(
tempAnswer
.
getSubjectId
());
});
Subject
subject
=
new
Subject
();
subject
.
setIds
(
subjectIdSet
.
toArray
(
new
String
[
subjectIdSet
.
size
()]));
// 获取题目ID,去重,转成字符串数组
subject
.
setIds
(
answerList
.
stream
().
map
(
Answer:
:
getSubjectId
).
distinct
().
toArray
(
String
[]::
new
));
// 查找题目列表
List
<
Subject
>
subjects
=
subjectService
.
findListById
(
subject
);
if
(
CollectionUtils
.
isNotEmpty
(
subjects
))
{
// 保存答题正确的题目分数
List
<
String
>
rightScore
=
new
ArrayList
<>();
answerList
.
forEach
(
tempAnswer
->
{
// 题目集合
subjects
.
stream
()
// 题目ID、题目答案匹配
.
filter
(
tempSubject
->
tempSubject
.
getId
().
equals
(
tempAnswer
.
getSubjectId
())
&&
tempSubject
.
getAnswer
().
equalsIgnoreCase
(
tempAnswer
.
getAnswer
()))
// 记录答题正确的成绩
.
findFirst
().
ifPresent
(
right
->
rightScore
.
add
(
right
.
getScore
()));
});
// 求和计算总分
int
totalScore
=
rightScore
.
stream
().
mapToInt
(
Integer:
:
parseInt
).
sum
();
// 错题列表
List
<
IncorrectAnswer
>
incorrectAnswers
=
new
ArrayList
<>();
for
(
Subject
tempSubject
:
subjects
)
{
for
(
Answer
tempAnswer
:
answerList
)
{
if
(
tempAnswer
.
getSubjectId
().
equals
(
tempSubject
.
getId
()))
{
// 答题正确
if
(
tempSubject
.
getAnswer
().
toUpperCase
().
equalsIgnoreCase
(
tempAnswer
.
getAnswer
()))
{
totalScore
+=
Integer
.
parseInt
(
tempSubject
.
getScore
());
correctNumber
++;
}
else
{
incorrectNumber
++;
answerList
.
forEach
(
tempAnswer
->
{
// 题目集合
subjects
.
stream
()
// 题目ID、题目答案匹配
.
filter
(
tempSubject
->
tempSubject
.
getId
().
equals
(
tempAnswer
.
getSubjectId
())
&&
!
tempSubject
.
getAnswer
().
equalsIgnoreCase
(
tempAnswer
.
getAnswer
()))
// 错题
.
findFirst
()
.
ifPresent
(
tempSubject
->
{
// 记录错题
IncorrectAnswer
incorrectAnswer
=
new
IncorrectAnswer
();
incorrectAnswer
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
()
,
SysUtil
.
getSysCode
());
incorrectAnswer
.
setCommonValue
(
currentUsername
,
SysUtil
.
getSysCode
());
incorrectAnswer
.
setExaminationId
(
tempAnswer
.
getExaminationId
());
incorrectAnswer
.
setExamRecordId
(
answer
.
getExamRecordId
());
incorrectAnswer
.
setSubjectId
(
tempAnswer
.
getSubjectId
());
...
...
@@ -159,18 +161,16 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
incorrectAnswer
.
setUserId
(
tempAnswer
.
getUserId
());
incorrectAnswer
.
setIncorrectAnswer
(
tempAnswer
.
getAnswer
());
incorrectAnswers
.
add
(
incorrectAnswer
);
}
}
}
}
});
});
// 保存成绩
ExamRecord
examRecord
=
new
ExamRecord
();
examRecord
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
(),
SysUtil
.
getSysCode
());
examRecord
.
setId
(
answer
.
getExamRecordId
());
examRecord
.
setEndTime
(
examRecord
.
getCreateDate
());
examRecord
.
setScore
(
totalScore
.
toString
(
));
examRecord
.
setCorrectNumber
(
correctNumber
.
toString
(
));
examRecord
.
setInCorrectNumber
(
incorrectNumber
.
toString
(
));
examRecord
.
setScore
(
Integer
.
toString
(
totalScore
));
examRecord
.
setCorrectNumber
(
String
.
valueOf
(
rightScore
.
size
()
));
examRecord
.
setInCorrectNumber
(
String
.
valueOf
(
incorrectAnswers
.
size
()
));
success
=
examRecordService
.
update
(
examRecord
)
>
0
;
// 保存错题
ExamRecord
searchExamRecord
=
new
ExamRecord
();
...
...
@@ -185,6 +185,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
}
}
}
logger
.
debug
(
"提交答卷,用户名:{},考试ID:{},耗时:{}ms"
,
currentUsername
,
answer
.
getExaminationId
(),
System
.
currentTimeMillis
()
-
start
);
return
success
;
}
}
service-api-impl/exam-service/src/main/resources/mapper/AnswerMapper.xml
View file @
4a5971c6
...
...
@@ -18,7 +18,7 @@
</resultMap>
<sql
id=
"answerColumns"
>
a.id
as "id"
,
a.id,
a.user_id,
a.examination_id,
a.exam_record_id,
...
...
service-api-impl/exam-service/src/main/resources/mapper/CourseMapper.xml
View file @
4a5971c6
...
...
@@ -17,7 +17,7 @@
</resultMap>
<sql
id=
"courseColumns"
>
a.id
as "id"
,
a.id,
a.course_name,
a.college,
a.major,
...
...
service-api-impl/exam-service/src/main/resources/mapper/ExamRecodeMapper.xml
View file @
4a5971c6
...
...
@@ -21,7 +21,7 @@
</resultMap>
<sql
id=
"examRecordColumns"
>
a.id
as "id"
,
a.id,
a.user_id,
a.examination_id,
a.examination_name,
...
...
service-api-impl/exam-service/src/main/resources/mapper/ExaminationMapper.xml
View file @
4a5971c6
...
...
@@ -27,7 +27,7 @@
</resultMap>
<sql
id=
"examinationColumns"
>
a.id
as "id"
,
a.id,
a.examination_name,
a.type,
a.attention,
...
...
service-api-impl/exam-service/src/main/resources/mapper/IncorrectAnswerMapper.xml
View file @
4a5971c6
...
...
@@ -18,7 +18,7 @@
</resultMap>
<sql
id=
"incorrectAnswerColumns"
>
a.id
as "id"
,
a.id,
a.user_id,
a.examination_id,
a.exam_record_id,
...
...
service-api-impl/exam-service/src/main/resources/mapper/KnowledgeMapper.xml
View file @
4a5971c6
...
...
@@ -16,7 +16,7 @@
</resultMap>
<sql
id=
"knowledgeColumns"
>
a.id
as "id"
,
a.id,
a.knowledge_name,
a.knowledge_desc,
a.attachment_id,
...
...
service-api-impl/exam-service/src/main/resources/mapper/SubjectBankMapper.xml
View file @
4a5971c6
...
...
@@ -27,7 +27,7 @@
</resultMap>
<sql
id=
"subjectBankColumns"
>
a.id
as "id"
,
a.id,
a.category_id,
a.serial_number,
a.subject_name,
...
...
service-api-impl/exam-service/src/main/resources/mapper/SubjectCategoryMapper.xml
View file @
4a5971c6
...
...
@@ -16,7 +16,7 @@
</resultMap>
<sql
id=
"subjectCategoryColumns"
>
a.id
as "id"
,
a.id,
a.category_name,
a.category_desc,
a.parent_id,
...
...
service-api-impl/exam-service/src/main/resources/mapper/SubjectMapper.xml
View file @
4a5971c6
...
...
@@ -27,7 +27,7 @@
</resultMap>
<sql
id=
"subjectColumns"
>
a.id
as "id"
,
a.id,
a.examination_id,
a.serial_number,
a.subject_name,
...
...
service-api-impl/exam-service/src/main/resources/mybatis-config.xml
deleted
100644 → 0
View file @
8a2ca63e
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- 驼峰转换 -->
<setting
name=
"mapUnderscoreToCamelCase"
value=
"true"
/>
<!-- 延迟加载 -->
<setting
name=
"lazyLoadingEnabled"
value=
"true"
/>
</settings>
<typeAliases>
<package
name=
"com.tangyi.module"
/>
</typeAliases>
</configuration>
\ No newline at end of file
service-api-impl/user-service/pom.xml
View file @
4a5971c6
...
...
@@ -60,12 +60,6 @@
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<!-- druid阿里巴巴数据库连接池 -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
...
...
service-api-impl/user-service/src/main/java/com/github/tangyi/user/config/MybatisConfig.java
deleted
100644 → 0
View file @
8a2ca63e
package
com
.
github
.
tangyi
.
user
.
config
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.transaction.annotation.TransactionManagementConfigurer
;
import
javax.sql.DataSource
;
/**
* mybatis 配置
*
* @author tangyi
* @date 2019/3/16 21:03
*/
@Configuration
@EnableTransactionManagement
public
class
MybatisConfig
implements
TransactionManagementConfigurer
{
private
final
DataSource
dataSource
;
@Autowired
public
MybatisConfig
(
DataSource
dataSource
)
{
this
.
dataSource
=
dataSource
;
}
@Override
public
PlatformTransactionManager
annotationDrivenTransactionManager
()
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
}
service-api-impl/user-service/src/main/java/com/github/tangyi/user/config/RabbitConfig.java
View file @
4a5971c6
...
...
@@ -33,4 +33,15 @@ public class RabbitConfig {
public
Queue
delQueue
()
{
return
new
Queue
(
MqConstant
.
DEL_GATEWAY_ROUTE_QUEUE
);
}
/**
* 刷新路由
*
* @return Queue
*/
@Bean
public
Queue
refreshQueue
()
{
return
new
Queue
(
MqConstant
.
REFRESH_GATEWAY_ROUTE_QUEUE
);
}
}
service-api-impl/user-service/src/main/java/com/github/tangyi/user/controller/AttachmentController.java
View file @
4a5971c6
...
...
@@ -30,8 +30,8 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 附件信息管理
...
...
@@ -253,12 +253,12 @@ public class AttachmentController extends BaseController {
attachment
.
setIds
(
attachmentVo
.
getIds
());
List
<
Attachment
>
attachmentList
=
attachmentService
.
findListById
(
attachment
);
if
(
CollectionUtils
.
isNotEmpty
(
attachmentList
))
{
List
<
AttachmentVo
>
attachmentVoList
=
new
ArrayList
<>();
attachmentList
.
forEach
(
tempAttachment
->
{
// 流处理转换成AttachmentVo
List
<
AttachmentVo
>
attachmentVoList
=
attachmentList
.
stream
().
map
(
tempAttachment
->
{
AttachmentVo
tempAttachmentVo
=
new
AttachmentVo
();
BeanUtils
.
copyProperties
(
tempAttachment
,
tempAttachmentVo
);
attachmentVoList
.
add
(
tempAttachmentVo
)
;
});
return
tempAttachmentVo
;
})
.
collect
(
Collectors
.
toList
())
;
returnT
=
new
ResponseBean
<>(
attachmentVoList
);
}
return
returnT
;
...
...
service-api-impl/user-service/src/main/java/com/github/tangyi/user/controller/DeptController.java
View file @
4a5971c6
...
...
@@ -15,13 +15,17 @@ import com.github.tangyi.user.service.DeptService;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* 部门controller
...
...
@@ -47,13 +51,17 @@ public class DeptController extends BaseController {
@GetMapping
(
value
=
"/depts"
)
@ApiOperation
(
value
=
"获取部门列表"
)
public
List
<
DeptDto
>
depts
()
{
// 查询所有部门
Set
<
Dept
>
deptSet
=
new
HashSet
<
Dept
>(
deptService
.
findList
(
new
Dept
()));
List
<
DeptDto
>
deptTreeList
=
new
ArrayList
<
DeptDto
>();
deptSet
.
forEach
(
dept
->
deptTreeList
.
add
(
new
DeptDto
(
dept
)));
// 排序
CollUtil
.
sort
(
deptTreeList
,
Comparator
.
comparingInt
(
DeptDto:
:
getSort
));
return
TreeUtil
.
buildTree
(
deptTreeList
,
"-1"
);
Dept
dept
=
new
Dept
();
dept
.
setApplicationCode
(
SysUtil
.
getSysCode
());
// 查询部门集合
Stream
<
Dept
>
deptStream
=
deptService
.
findList
(
dept
).
stream
();
if
(
Optional
.
ofNullable
(
deptStream
).
isPresent
())
{
// 流处理转成DeptDto
List
<
DeptDto
>
deptTreeList
=
deptStream
.
map
(
DeptDto:
:
new
).
collect
(
Collectors
.
toList
());
// 排序、构建树形结构
return
TreeUtil
.
buildTree
(
CollUtil
.
sort
(
deptTreeList
,
Comparator
.
comparingInt
(
DeptDto:
:
getSort
)),
"-1"
);
}
return
new
ArrayList
<>();
}
/**
...
...
@@ -144,14 +152,14 @@ public class DeptController extends BaseController {
ResponseBean
<
List
<
DeptVo
>>
returnT
=
null
;
Dept
dept
=
new
Dept
();
dept
.
setIds
(
deptVo
.
getIds
());
List
<
Dept
>
depts
=
deptService
.
findListById
(
dept
);
if
(
CollectionUtils
.
isNotEmpty
(
depts
))
{
List
<
DeptVo
>
deptVoList
=
new
ArrayList
<>();
depts
.
forEach
(
tempDept
->
{
Stream
<
Dept
>
deptStream
=
deptService
.
findListById
(
dept
).
stream
(
);
if
(
Optional
.
ofNullable
(
deptStream
).
isPresent
(
))
{
// 流处理转换成DeptVo
List
<
DeptVo
>
deptVoList
=
deptStream
.
map
(
tempDept
->
{
DeptVo
tempDeptVo
=
new
DeptVo
();
BeanUtils
.
copyProperties
(
tempDept
,
tempDeptVo
);
deptVoList
.
add
(
tempDeptVo
)
;
});
return
tempDeptVo
;
})
.
collect
(
Collectors
.
toList
())
;
returnT
=
new
ResponseBean
<>(
deptVoList
);
}
return
returnT
;
...
...
service-api-impl/user-service/src/main/java/com/github/tangyi/user/controller/MenuController.java
View file @
4a5971c6
...
...
@@ -10,13 +10,13 @@ import com.github.tangyi.common.core.web.BaseController;
import
com.github.tangyi.common.log.annotation.Log
;
import
com.github.tangyi.common.security.constant.SecurityConstant
;
import
com.github.tangyi.common.security.utils.SecurityUtil
;
import
com.github.tangyi.user.api.constant.MenuConstant
;
import
com.github.tangyi.user.api.dto.MenuDto
;
import
com.github.tangyi.user.api.module.Menu
;
import
com.github.tangyi.user.service.MenuService
;
import
com.github.tangyi.user.utils.MenuUtil
;
import
com.google.common.net.HttpHeaders
;
import
io.swagger.annotations.*
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
...
...
@@ -27,6 +27,8 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* 菜单controller
...
...
@@ -50,34 +52,29 @@ public class MenuController extends BaseController {
@GetMapping
(
value
=
"/userMenu"
)
@ApiOperation
(
value
=
"获取当前用户的菜单列表"
)
public
List
<
MenuDto
>
userMenu
()
{
// 查询菜单
Set
<
Menu
>
menuSet
=
new
HashSet
<>();
SecurityUtil
.
getCurrentAuthentication
().
getAuthorities
().
forEach
(
roleName
->
{
// 获取角色的菜单
List
<
Menu
>
menus
=
menuService
.
findMenuByRole
(
roleName
.
getAuthority
());
if
(
CollectionUtils
.
isNotEmpty
(
menus
))
{
menus
.
forEach
(
menu
->
{
// 检查是否已经存在
boolean
exist
=
false
;
for
(
Menu
existMenu
:
menuSet
)
{
if
(
existMenu
.
getId
().
equals
(
menu
.
getId
())
&&
!
exist
)
exist
=
true
;
List
<
MenuDto
>
menuDtoList
=
new
ArrayList
<>();
// 根据角色code查找菜单
SecurityUtil
.
getCurrentAuthentication
().
getAuthorities
().
stream
()
// 按角色过滤
.
filter
(
authority
->
authority
.
getAuthority
()
!=
null
&&
authority
.
getAuthority
().
startsWith
(
"role_"
))
// 查找菜单
.
forEach
(
roleName
->
{
// 获取角色的菜单
Stream
<
Menu
>
menuStream
=
menuService
.
findMenuByRole
(
roleName
.
getAuthority
()).
stream
();
if
(
Optional
.
ofNullable
(
menuStream
).
isPresent
())
{
// 筛选出类型为菜单的菜单,放进menuMap,防止重复,用菜单的ID作为key
menuStream
// 菜单类型
.
filter
(
menu
->
MenuConstant
.
MENU_TYPE_MENU
.
equals
(
menu
.
getType
()))
// dto封装
.
map
(
MenuDto:
:
new
)
// 去重
.
distinct
()
.
forEach
(
menuDtoList:
:
add
);
}
// 不存在
if
(!
exist
)
menuSet
.
add
(
menu
);
});
}
});
List
<
MenuDto
>
menuTreeList
=
new
ArrayList
<
MenuDto
>();
menuSet
.
forEach
(
menuVo
->
{
if
(
CommonConstant
.
MENU
.
equals
(
menuVo
.
getType
()))
{
menuTreeList
.
add
(
new
MenuDto
(
menuVo
));
}
});
CollUtil
.
sort
(
menuTreeList
,
Comparator
.
comparingInt
(
MenuDto:
:
getSort
));
return
TreeUtil
.
buildTree
(
menuTreeList
,
"-1"
);
// 排序、构建树形关系
return
TreeUtil
.
buildTree
(
CollUtil
.
sort
(
menuDtoList
,
Comparator
.
comparingInt
(
MenuDto:
:
getSort
)),
"-1"
);
}
/**
...
...
@@ -89,12 +86,16 @@ public class MenuController extends BaseController {
@ApiOperation
(
value
=
"获取树形菜单列表"
)
public
List
<
MenuDto
>
menus
()
{
// 查询所有菜单
Set
<
Menu
>
menuSet
=
new
HashSet
<
Menu
>(
menuService
.
findList
(
new
Menu
()));
List
<
MenuDto
>
menuTreeList
=
new
ArrayList
<
MenuDto
>();
menuSet
.
forEach
(
menuVo
->
menuTreeList
.
add
(
new
MenuDto
(
menuVo
)));
// 排序
CollUtil
.
sort
(
menuTreeList
,
Comparator
.
comparingInt
(
MenuDto:
:
getSort
));
return
TreeUtil
.
buildTree
(
menuTreeList
,
"-1"
);
Menu
condition
=
new
Menu
();
condition
.
setApplicationCode
(
SysUtil
.
getSysCode
());
Stream
<
Menu
>
menuStream
=
menuService
.
findAllList
(
condition
).
stream
();
if
(
Optional
.
ofNullable
(
menuStream
).
isPresent
())
{
// 转成MenuDto
List
<
MenuDto
>
menuDtoList
=
menuStream
.
map
(
MenuDto:
:
new
).
collect
(
Collectors
.
toList
());
// 排序、构建树形关系
return
TreeUtil
.
buildTree
(
CollUtil
.
sort
(
menuDtoList
,
Comparator
.
comparingInt
(
MenuDto:
:
getSort
)),
"-1"
);
}
return
new
ArrayList
<>();
}
/**
...
...
@@ -223,10 +224,12 @@ public class MenuController extends BaseController {
@ApiOperation
(
value
=
"根据角色查找菜单"
,
notes
=
"根据角色code获取角色菜单"
)
@ApiImplicitParam
(
name
=
"roleCode"
,
value
=
"角色code"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
public
List
<
String
>
roleTree
(
@PathVariable
String
roleCode
)
{
List
<
Menu
>
menus
=
menuService
.
findMenuByRole
(
roleCode
);
List
<
String
>
menuList
=
new
ArrayList
<>();
menus
.
forEach
(
menu
->
menuList
.
add
(
menu
.
getId
()));
return
menuList
;
// 根据角色查找菜单
Stream
<
Menu
>
menuStream
=
menuService
.
findMenuByRole
(
roleCode
).
stream
();
// 获取菜单ID
if
(
Optional
.
ofNullable
(
menuStream
).
isPresent
())
return
menuStream
.
map
(
Menu:
:
getId
).
collect
(
Collectors
.
toList
());
return
new
ArrayList
<>();
}
/**
...
...
@@ -247,19 +250,15 @@ public class MenuController extends BaseController {
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"multipart/form-data"
);
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"菜单信息"
+
new
SimpleDateFormat
(
"yyyyMMddhhmmssSSS"
).
format
(
new
Date
())
+
".xlsx"
));
List
<
Menu
>
menus
=
new
ArrayList
<>()
;
List
<
Menu
>
menus
;
// 导出所有
if
(
StringUtils
.
isEmpty
(
menuVo
.
getIdString
()))
{
Menu
menu
=
new
Menu
();
menus
=
menuService
.
findList
(
menu
);
}
else
{
// 导出选中
Set
<
String
>
menuIdSet
=
new
HashSet
<>();
for
(
String
id
:
menuVo
.
getIdString
().
split
(
","
))
{
if
(
StringUtils
.
isNotBlank
(
id
))
menuIdSet
.
add
(
id
);
}
Menu
menu
=
new
Menu
();
menu
.
setIds
(
menuIdSet
.
toArray
(
new
String
[
menuIdSet
.
size
()]));
// 按逗号切割ID,流处理获取ID集合,去重,转成字符串数组
menu
.
setIds
(
Stream
.
of
(
menuVo
.
getIdString
().
split
(
","
)).
filter
(
StringUtils:
:
isNotBlank
).
distinct
().
toArray
(
String
[]::
new
));
menus
=
menuService
.
findListById
(
menu
);
}
ExcelToolUtil
.
exportExcel
(
request
.
getInputStream
(),
response
.
getOutputStream
(),
MapUtil
.
java2Map
(
menus
),
MenuUtil
.
getMenuMap
());
...
...
@@ -283,13 +282,13 @@ public class MenuController extends BaseController {
public
ResponseBean
<
Boolean
>
importMenu
(
@ApiParam
(
value
=
"要上传的文件"
,
required
=
true
)
MultipartFile
file
,
HttpServletRequest
request
)
{
try
{
logger
.
debug
(
"开始导入菜单数据"
);
List
<
Menu
>
menus
=
MapUtil
.
map2Java
(
Menu
.
class
,
ExcelToolUtil
.
importExcel
(
file
.
getInputStream
(),
MenuUtil
.
getMenuMap
()));
if
(
CollectionUtils
.
isNotEmpty
(
menus
))
{
for
(
Menu
menu
:
menus
)
{
Stream
<
Menu
>
menuStream
=
MapUtil
.
map2Java
(
Menu
.
class
,
ExcelToolUtil
.
importExcel
(
file
.
getInputStream
(),
MenuUtil
.
getMenuMap
()))
.
stream
()
;
if
(
Optional
.
ofNullable
(
menuStream
).
isPresent
(
))
{
menuStream
.
forEach
(
menu
->
{
if
(
menuService
.
update
(
menu
)
<
1
)
menuService
.
insert
(
menu
);
}
}
);
}
return
new
ResponseBean
<>(
Boolean
.
TRUE
);
}
catch
(
Exception
e
)
{
...
...
service-api-impl/user-service/src/main/java/com/github/tangyi/user/controller/RoleController.java
View file @
4a5971c6
...
...
@@ -20,15 +20,16 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* 角色controller
...
...
@@ -101,8 +102,9 @@ public class RoleController extends BaseController {
Role
role
)
{
// 查询所属部门
PageInfo
<
Role
>
pageInfo
=
roleService
.
findPage
(
PageUtil
.
pageInfo
(
pageNum
,
pageSize
,
sort
,
order
),
role
);
if
(
CollectionUtils
.
isNotEmpty
(
pageInfo
.
getList
()))
{
pageInfo
.
getList
().
forEach
(
tempRole
->
{
Stream
<
Role
>
roleStream
=
pageInfo
.
getList
().
stream
();
if
(
Optional
.
ofNullable
(
roleStream
).
isPresent
())
{
roleStream
.
forEach
(
tempRole
->
{
RoleDept
roleDept
=
new
RoleDept
();
roleDept
.
setRoleId
(
tempRole
.
getId
());
// 查询角色部门关系
...
...
@@ -136,17 +138,13 @@ public class RoleController extends BaseController {
List
<
Role
>
roles
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
deptId
))
{
// 获取角色部门关系
List
<
RoleDept
>
roleDepts
=
roleDeptService
.
getRoleByDeptId
(
deptId
);
// 遍历
if
(
CollectionUtils
.
isNotEmpty
(
roleDepts
))
{
roleDepts
.
forEach
(
roleDept
->
{
Role
role
=
new
Role
();
role
.
setId
(
roleDept
.
getRoleId
());
// 查询部门信息
role
=
roleService
.
get
(
role
);
if
(
role
!=
null
)
roles
.
add
(
role
);
});
Stream
<
RoleDept
>
roleDeptStream
=
roleDeptService
.
getRoleByDeptId
(
deptId
).
stream
();
// 获取角色列表
if
(
Optional
.
ofNullable
(
roleDeptStream
).
isPresent
())
{
Role
role
=
new
Role
();
// 流处理获取角色ID集合,去重,转成字符串数组
role
.
setIds
(
roleDeptStream
.
map
(
RoleDept:
:
getRoleId
).
distinct
().
toArray
(
String
[]::
new
));
roles
=
roleService
.
findListById
(
role
);
}
}
return
roles
;
...
...
@@ -190,7 +188,7 @@ public class RoleController extends BaseController {
role
=
roleService
.
get
(
role
);
// 保存角色菜单关系
if
(
role
!=
null
&&
StringUtils
.
isNotBlank
(
deptId
))
success
=
roleMenuService
.
saveRoleMenus
(
role
.
getId
(),
Arrays
.
asList
(
deptId
.
split
(
","
)))
>
0
;
success
=
roleMenuService
.
saveRoleMenus
(
role
.
getId
(),
Stream
.
of
(
deptId
.
split
(
","
)).
collect
(
Collectors
.
toList
(
)))
>
0
;
}
return
new
ResponseBean
<>(
success
);
}
...
...
service-api-impl/user-service/src/main/java/com/github/tangyi/user/controller/UserController.java
View file @
4a5971c6
...
...
@@ -37,7 +37,12 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.security.Principal
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* @author tangyi
...
...
@@ -140,58 +145,48 @@ public class UserController extends BaseController {
PageInfo
<
User
>
page
=
userService
.
findPage
(
PageUtil
.
pageInfo
(
pageNum
,
pageSize
,
sort
,
order
),
user
);
List
<
User
>
users
=
page
.
getList
();
if
(
CollectionUtils
.
isNotEmpty
(
users
))
{
// 收集用户、部门id
Set
<
String
>
deptIdSet
=
new
HashSet
<>(),
userIdSet
=
new
HashSet
<>();
users
.
forEach
(
tempUser
->
{
if
(
tempUser
.
getDeptId
()
!=
null
)
deptIdSet
.
add
(
tempUser
.
getDeptId
());
userIdSet
.
add
(
tempUser
.
getId
());
});
Dept
dept
=
new
Dept
();
// 流处理获取部门ID集合,转成字符串数组
dept
.
setIds
(
users
.
stream
().
filter
(
tempUser
->
tempUser
.
getDeptId
()
!=
null
).
map
(
User:
:
getDeptId
).
distinct
().
toArray
(
String
[]::
new
));
// 批量查找部门
List
<
Dept
>
deptList
=
null
;
if
(!
deptIdSet
.
isEmpty
())
{
Dept
dept
=
new
Dept
();
dept
.
setIds
(
deptIdSet
.
toArray
(
new
String
[
deptIdSet
.
size
()]));
deptList
=
deptService
.
findListById
(
dept
);
}
// 批量查找角色
List
<
UserRole
>
userRoles
=
userRoleService
.
getByUserIds
(
new
ArrayList
<>(
userIdSet
));
List
<
Dept
>
deptList
=
deptService
.
findListById
(
dept
);
// 流处理获取用户ID集合,根据用户ID批量查找角色
List
<
UserRole
>
userRoles
=
userRoleService
.
getByUserIds
(
users
.
stream
().
map
(
User:
:
getId
).
collect
(
Collectors
.
toList
()));
List
<
Role
>
roleList
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
userRoles
))
{
Set
<
String
>
roleIdSet
=
new
HashSet
<>();
userRoles
.
forEach
(
tempUserRole
->
{
roleIdSet
.
add
(
tempUserRole
.
getRoleId
());
});
Role
role
=
new
Role
();
role
.
setIds
(
roleIdSet
.
toArray
(
new
String
[
roleIdSet
.
size
()]));
// 查询所有角色
// 获取角色ID集合,转成字节数组
role
.
setIds
(
userRoles
.
stream
().
map
(
UserRole:
:
getRoleId
).
distinct
().
toArray
(
String
[]::
new
));
// 批量查找角色
roleList
=
roleService
.
findListById
(
role
);
}
//
设置部门、角色信息
for
(
User
tempUser
:
users
)
{
List
<
Role
>
userRoleList
=
new
ArrayList
<>();
//
遍历用户集合,设置部门、角色
List
<
Role
>
finalRoleList
=
roleList
;
users
.
forEach
(
tempUser
->
{
// 设置部门信息
if
(
deptList
!=
null
)
{
for
(
Dept
tempDept
:
deptList
)
{
if
(
tempDept
.
getId
().
equals
(
tempUser
.
getDeptId
()))
{
tempUser
.
setDeptName
(
tempDept
.
getDeptName
());
tempUser
.
setDeptId
(
tempDept
.
getId
());
break
;
}
if
(
CollectionUtils
.
isNotEmpty
(
deptList
))
{
// 用户所属部门
Dept
userDept
=
deptList
.
stream
()
// 按部门ID找到部门信息
.
filter
(
tempDept
->
tempDept
.
getId
().
equals
(
tempUser
.
getDeptId
()))
.
findFirst
().
orElse
(
null
);
if
(
userDept
!=
null
)
{
tempUser
.
setDeptName
(
userDept
.
getDeptName
());
tempUser
.
setDeptId
(
userDept
.
getId
());
}
}
for
(
UserRole
tempUserRole
:
userRoles
)
{
if
(
tempUser
.
getId
().
equals
(
tempUserRole
.
getUserId
()))
{
for
(
Role
role
:
roleList
)
{
if
(
role
.
getId
().
equals
(
tempUserRole
.
getRoleId
()))
{
userRoleList
.
add
(
role
);
}
}
}
// 设置角色信息
if
(
CollectionUtils
.
isNotEmpty
(
userRoles
))
{
List
<
Role
>
userRoleList
=
new
ArrayList
<>();
userRoles
.
stream
()
// 过滤
.
filter
(
tempUserRole
->
tempUser
.
getId
().
equals
(
tempUserRole
.
getUserId
()))
.
forEach
(
tempUserRole
->
finalRoleList
.
stream
()
.
filter
(
role
->
role
.
getId
().
equals
(
tempUserRole
.
getRoleId
()))
.
forEach
(
userRoleList:
:
add
));
tempUser
.
setRoleList
(
userRoleList
);
}
tempUser
.
setRoleList
(
userRoleList
);
}
});
}
return
page
;
}
...
...
@@ -259,9 +254,7 @@ public class UserController extends BaseController {
// 新密码不为空
if
(
StringUtils
.
isNotEmpty
(
userDto
.
getNewPassword
()))
{
if
(!
encoder
.
matches
(
userDto
.
getOldPassword
(),
userDto
.
getPassword
()))
{
ResponseBean
<
Boolean
>
returnT
=
new
ResponseBean
<>(
Boolean
.
FALSE
);
returnT
.
setMsg
(
"新旧密码不匹配"
);
return
returnT
;
return
new
ResponseBean
<>(
Boolean
.
FALSE
,
"新旧密码不匹配"
);
}
else
{
// 新旧密码一致,修改密码
userDto
.
setPassword
(
encoder
.
encode
(
userDto
.
getNewPassword
()));
...
...
@@ -314,13 +307,9 @@ public class UserController extends BaseController {
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"用户信息"
+
new
SimpleDateFormat
(
"yyyyMMddhhmmssSSS"
).
format
(
new
Date
())
+
".xlsx"
));
List
<
User
>
users
;
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getIdString
()))
{
List
<
String
>
userIdList
=
new
ArrayList
<>();
for
(
String
id
:
userVo
.
getIdString
().
split
(
","
))
{
if
(
StringUtils
.
isNotEmpty
(
id
))
userIdList
.
add
(
id
);
}
User
user
=
new
User
();
user
.
setIds
(
userIdList
.
toArray
(
new
String
[
userIdList
.
size
()]));
// 按逗号切割ID,流处理获取ID集合,去重,转成字符串数组
user
.
setIds
(
Stream
.
of
(
userVo
.
getIdString
().
split
(
","
)).
filter
(
StringUtils:
:
isNotBlank
).
distinct
().
toArray
(
String
[]::
new
));
users
=
userService
.
findListById
(
user
);
}
else
{
// 导出全部用户
users
=
userService
.
findList
(
new
User
());
...
...
@@ -400,14 +389,13 @@ public class UserController extends BaseController {
ResponseBean
<
List
<
UserVo
>>
returnT
=
null
;
User
user
=
new
User
();
user
.
setIds
(
userVo
.
getIds
());
List
<
User
>
users
=
userService
.
findListById
(
user
);
if
(
CollectionUtils
.
isNotEmpty
(
users
))
{
List
<
UserVo
>
userVoList
=
new
ArrayList
<>();
users
.
forEach
(
tempUser
->
{
Stream
<
User
>
userStream
=
userService
.
findListById
(
user
).
stream
();
if
(
Optional
.
ofNullable
(
userStream
).
isPresent
())
{
List
<
UserVo
>
userVoList
=
userStream
.
map
(
tempUser
->
{
UserVo
tempUserVo
=
new
UserVo
();
BeanUtils
.
copyProperties
(
tempUser
,
tempUserVo
);
userVoList
.
add
(
tempUserVo
)
;
});
return
tempUserVo
;
})
.
collect
(
Collectors
.
toList
())
;
returnT
=
new
ResponseBean
<>(
userVoList
);
}
return
returnT
;
...
...
@@ -441,15 +429,17 @@ public class UserController extends BaseController {
Role
role
=
new
Role
();
role
.
setIsDefault
(
RoleConstant
.
IS_DEFAULT_ROLE
);
// 查询默认角色
List
<
Role
>
roleList
=
roleService
.
findList
(
role
);
if
(
CollectionUtils
.
isNotEmpty
(
roleList
))
{
Role
defaultRole
=
roleList
.
get
(
0
);
UserRole
userRole
=
new
UserRole
();
userRole
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
(),
SysUtil
.
getSysCode
());
userRole
.
setUserId
(
user
.
getId
());
userRole
.
setRoleId
(
defaultRole
.
getId
());
// 保存用户角色关系
success
=
userRoleService
.
insert
(
userRole
)
>
0
;
Stream
<
Role
>
roleStream
=
roleService
.
findList
(
role
).
stream
();
if
(
Optional
.
ofNullable
(
roleStream
).
isPresent
())
{
Role
defaultRole
=
roleStream
.
findFirst
().
orElse
(
null
);
if
(
defaultRole
!=
null
)
{
UserRole
userRole
=
new
UserRole
();
userRole
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
(),
SysUtil
.
getSysCode
());
userRole
.
setUserId
(
user
.
getId
());
userRole
.
setRoleId
(
defaultRole
.
getId
());
// 保存用户角色关系
success
=
userRoleService
.
insert
(
userRole
)
>
0
;
}
}
}
return
new
ResponseBean
<>(
success
);
...
...
service-api-impl/user-service/src/main/java/com/github/tangyi/user/service/AttachmentService.java
View file @
4a5971c6
...
...
@@ -11,6 +11,4 @@ import org.springframework.stereotype.Service;
*/
@Service
public
class
AttachmentService
extends
CrudService
<
AttachmentMapper
,
Attachment
>
{
}
service-api-impl/user-service/src/main/java/com/github/tangyi/user/service/MenuService.java
View file @
4a5971c6
...
...
@@ -34,12 +34,26 @@ public class MenuService extends CrudService<MenuMapper, Menu> {
* @author tangyi
* @date 2018/8/27 16:00
*/
@Cacheable
(
value
=
"menu"
,
key
=
"#role
+ '_menu'
"
)
@Cacheable
(
value
=
"menu"
,
key
=
"#role"
)
public
List
<
Menu
>
findMenuByRole
(
String
role
)
{
return
menuMapper
.
findByRole
(
role
);
}
/**
* 查询全部菜单
*
* @param menu menu
* @return List
* @author tangyi
* @date 2019/04/10 17:58
*/
@Cacheable
(
value
=
"menu"
,
key
=
"#menu.applicationCode"
)
@Override
public
List
<
Menu
>
findAllList
(
Menu
menu
)
{
return
menuMapper
.
findAllList
(
menu
);
}
/**
* 新增菜单
*
* @param menu menu
...
...
@@ -50,11 +64,6 @@ public class MenuService extends CrudService<MenuMapper, Menu> {
@Transactional
@Override
public
int
insert
(
Menu
menu
)
{
// 初始化权限
/*if (MenuConstant.MENU_TYPE_MENU.equals(menu.getType())) {
List<Menu> menus = MenuUtil.initMenuPermission(menu);
menus.forEach(super::insert);
}*/
return
super
.
insert
(
menu
);
}
...
...
service-api-impl/user-service/src/main/java/com/github/tangyi/user/service/UserService.java
View file @
4a5971c6
...
...
@@ -4,20 +4,18 @@ import com.github.tangyi.common.core.constant.CommonConstant;
import
com.github.tangyi.common.core.service.CrudService
;
import
com.github.tangyi.common.core.utils.IdGen
;
import
com.github.tangyi.common.core.utils.SysUtil
;
import
com.github.tangyi.common.core.vo.Role
;
import
com.github.tangyi.common.core.vo.UserVo
;
import
com.github.tangyi.common.security.constant.SecurityConstant
;
import
com.github.tangyi.common.security.utils.SecurityUtil
;
import
com.github.tangyi.user.api.constant.MenuConstant
;
import
com.github.tangyi.user.api.dto.UserDto
;
import
com.github.tangyi.user.api.dto.UserInfoDto
;
import
com.github.tangyi.user.api.module.Menu
;
import
com.github.tangyi.user.api.module.User
;
import
com.github.tangyi.user.api.module.UserRole
;
import
com.github.tangyi.user.mapper.MenuMapper
;
import
com.github.tangyi.user.mapper.UserMapper
;
import
com.github.tangyi.user.mapper.UserRoleMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
...
...
@@ -27,9 +25,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
/**
...
...
@@ -48,7 +44,7 @@ public class UserService extends CrudService<UserMapper, User> {
private
UserRoleMapper
userRoleMapper
;
@Autowired
private
Menu
Mapper
menuMapper
;
private
Menu
Service
menuService
;
@Autowired
private
RedisTemplate
redisTemplate
;
...
...
@@ -92,28 +88,31 @@ public class UserService extends CrudService<UserMapper, User> {
UserInfoDto
user
=
new
UserInfoDto
();
if
(
userVo
!=
null
)
{
user
.
setUser
(
userVo
);
// 用户角色列表
List
<
Role
>
roleList
=
userVo
.
getRoleList
();
List
<
String
>
roleCodes
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
roleList
))
{
roleList
.
forEach
(
role
->
{
if
(!
SecurityConstant
.
BASE_ROLE
.
equals
(
role
.
getRoleName
()))
roleCodes
.
add
(
role
.
getRoleCode
());
});
// 用户角色
List
<
String
>
roles
=
new
ArrayList
<>();
// 用户权限
List
<
String
>
permissions
=
new
ArrayList
<>();
// 根据角色获取权限
if
(
CollectionUtils
.
isNotEmpty
(
userVo
.
getRoleList
()))
{
userVo
.
getRoleList
().
stream
()
// 过滤普通用户角色
.
filter
(
role
->
!
SecurityConstant
.
BASE_ROLE
.
equals
(
role
.
getRoleName
()))
.
forEach
(
role
->
{
// 根据角色查找菜单
List
<
Menu
>
menuList
=
menuService
.
findMenuByRole
(
role
.
getRoleCode
());
if
(
CollectionUtils
.
isNotEmpty
(
menuList
))
{
menuList
.
stream
()
// 获取权限菜单
.
filter
(
menu
->
MenuConstant
.
MENU_TYPE_PERMISSION
.
equals
(
menu
.
getType
()))
// 获取权限
.
forEach
(
menu
->
permissions
.
add
(
menu
.
getPermission
()));
}
// 保存角色code
roles
.
add
(
role
.
getRoleCode
());
});
}
String
[]
roleCodeArray
=
roleCodes
.
toArray
(
new
String
[
roleCodes
.
size
()]);
user
.
setRoles
(
roleCodeArray
);
// 菜单列表
Set
<
Menu
>
menuSet
=
new
HashSet
<>();
for
(
String
role
:
roleCodeArray
)
menuSet
.
addAll
(
menuMapper
.
findByRole
(
role
));
// 权限列表
Set
<
String
>
permissions
=
new
HashSet
<>();
menuSet
.
forEach
(
menu
->
{
if
(
StringUtils
.
isNotEmpty
(
menu
.
getPermission
()))
permissions
.
add
(
menu
.
getPermission
());
});
user
.
setPermissions
(
permissions
.
toArray
(
new
String
[
permissions
.
size
()]));
user
.
setRoles
(
roles
.
toArray
(
new
String
[
0
]));
user
.
setPermissions
(
permissions
.
toArray
(
new
String
[
0
]));
}
return
user
;
}
...
...
service-api-impl/user-service/src/main/resources/mapper/AttachmentMapper.xml
View file @
4a5971c6
...
...
@@ -19,7 +19,7 @@
</resultMap>
<sql
id=
"attachmentColumns"
>
a.id
as "id"
,
a.id,
a.attach_name,
a.attach_size,
a.group_name,
...
...
service-api-impl/user-service/src/main/resources/mapper/DeptMapper.xml
View file @
4a5971c6
...
...
@@ -18,7 +18,7 @@
</resultMap>
<sql
id=
"deptColumns"
>
a.id
as "id"
,
a.id,
a.dept_name,
a.dept_desc,
a.dept_leader,
...
...
service-api-impl/user-service/src/main/resources/mapper/LogMapper.xml
View file @
4a5971c6
...
...
@@ -22,7 +22,7 @@
</resultMap>
<sql
id=
"logColumns"
>
a.id
as "id"
,
a.id,
a.type,
a.title,
a.ip,
...
...
service-api-impl/user-service/src/main/resources/mapper/MenuMapper.xml
View file @
4a5971c6
...
...
@@ -23,7 +23,7 @@
</resultMap>
<sql
id=
"menuColumns"
>
a.id
as "id"
,
a.id,
a.name,
a.permission,
a.url,
...
...
@@ -113,6 +113,14 @@
<include
refid=
"whereColumnList"
/>
</select>
<select
id=
"findAllList"
resultMap=
"menuResultMap"
>
SELECT
<include
refid=
"menuColumns"
/>
FROM sys_menu a
WHERE a.del_flag = 0
<include
refid=
"whereColumnList"
/>
</select>
<select
id=
"findListById"
resultMap=
"menuResultMap"
>
SELECT
<include
refid=
"menuColumns"
/>
...
...
service-api-impl/user-service/src/main/resources/mapper/RoleDeptMapper.xml
View file @
4a5971c6
...
...
@@ -8,9 +8,9 @@
</resultMap>
<sql
id=
"roleDeptColumns"
>
a.id
as "id"
,
a.role_id
as "role_id"
,
a.dept_id
as "dept_id"
a.id,
a.role_id,
a.dept_id
</sql>
<select
id=
"get"
resultMap=
"roleDeptResultMap"
>
...
...
service-api-impl/user-service/src/main/resources/mapper/RoleMapper.xml
View file @
4a5971c6
...
...
@@ -17,7 +17,7 @@
</resultMap>
<sql
id=
"roleColumns"
>
a.id
as "id"
,
a.id,
a.role_name,
a.role_code,
a.role_desc,
...
...
service-api-impl/user-service/src/main/resources/mapper/RoleMenuMapper.xml
View file @
4a5971c6
...
...
@@ -8,9 +8,9 @@
</resultMap>
<sql
id=
"roleMenuColumns"
>
a.id
as "id"
,
a.role_id
as "role_id"
,
a.menu_id
as "menu_id"
a.id,
a.role_id,
a.menu_id
</sql>
<insert
id=
"insert"
>
...
...
service-api-impl/user-service/src/main/resources/mapper/RouteMapper.xml
View file @
4a5971c6
...
...
@@ -19,7 +19,7 @@
</resultMap>
<sql
id=
"routeColumns"
>
a.id
as "id"
,
a.id,
a.route_id,
a.route_name,
a.predicates,
...
...
service-api-impl/user-service/src/main/resources/mapper/UserMapper.xml
View file @
4a5971c6
...
...
@@ -60,7 +60,7 @@
</resultMap>
<sql
id=
"userColumns"
>
a.id
as "id"
,
a.id,
a.name,
a.username,
a.password,
...
...
service-api-impl/user-service/src/main/resources/mapper/UserRoleMapper.xml
View file @
4a5971c6
...
...
@@ -8,9 +8,9 @@
</resultMap>
<sql
id=
"userRoleColumns"
>
a.id
as "id"
,
a.user_id
as "userId"
,
a.role_id
as "roleId"
a.id,
a.user_id,
a.role_id
</sql>
<select
id=
"getByUserId"
resultMap=
"userResultMap"
>
...
...
service-api-impl/user-service/src/main/resources/mybatis-config.xml
deleted
100644 → 0
View file @
8a2ca63e
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- 驼峰转换 -->
<setting
name=
"mapUnderscoreToCamelCase"
value=
"true"
/>
<!-- 延迟加载 -->
<setting
name=
"lazyLoadingEnabled"
value=
"true"
/>
</settings>
<typeAliases>
<package
name=
"com.tangyi.module"
/>
</typeAliases>
</configuration>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment