作者 朱兆平

组织结构和权限列表重构采用树形

#上传文件的路径,要带斜杠
web:
upload-path: upload/
... ... @@ -13,11 +14,6 @@ spring:
mvc:
#静态资源,设置上传文件的访问,
static-path-pattern: /**
boot:
admin:
client:
url: http://192.168.1.63:16666
password: vmvnv1v2
zipkin:
base-url: http://192.168.1.63:9411
sleuth:
... ... @@ -27,10 +23,10 @@ spring:
static-locations: classpath:/META-INF/resources/,classpath:/static,classpath:/resources/,file:${web.upload-path}
application:
name: cloud-user-centerV2
name: cloud-user-center
redis:
# host: 127.0.0.1
host: 192.168.1.53
# host: 192.168.43.78
port: 6379
jackson:
serialization:
... ... @@ -61,7 +57,7 @@ spring:
#username=CGOETL
#password=1q2w3e4r
#spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码
url: jdbc:mysql://118.31.66.166:3306/HQPT_USER?useUnicode=true&characterEncoding=utf8
url: jdbc:mysql://118.31.66.166:3306/statistics?useUnicode=true&characterEncoding=utf8
username: 110
password: QAHqCJf2kFYCLirM
driver-class-name: com.mysql.cj.jdbc.Driver
... ... @@ -93,12 +89,17 @@ spring:
eureka:
instance:
#eureka服务器页面中status的请求路径
status-page-url: http://${eureka.instance.hostname}:${server.port}/index
# status-page-url: http://${eureka.instance.hostname}:${server.port}/index
prefer-ip-address: true
instance-id: ${spring.cloud.client.ip-address}:${server.port}
hostname: ${spring.cloud.client.ip-address}
lease-renewal-interval-in-seconds: 15
lease-expiration-duration-in-seconds: 45
health-check-url-path: /actuator/health
metadata-map:
user:
name: "admin" #These two are needed so that the server
password: "123456"
client:
#eureka注册中心服务器地址
service-url:
... ... @@ -113,7 +114,7 @@ management:
enabled-by-default: true
web:
exposure:
include: ["*"]
include: "*"
endpoint:
health:
show-details: always
... ... @@ -150,3 +151,7 @@ logging:
#Java Web Token 时效时间,单位秒
jwt:
max-alive: 30000
info:
version: 2.0
description: "具有公司及部门管理级别的用户管理中心"
... ...
#登录账号
loginname = KAKO
#登录密码
loginpass = KAKO
#发送报文目录,相对程序目录
readDirectory = /Users/mrz/Documents/java项目/test
#接收存储报文目录
bakDirectory = kakoRevice
#是否需要发送报文,默认N不发,Y将发送readDirectory下的XML扩展名的报文
isNeedSend = Y
#本地要保存的styp类型,用英文逗号分隔,注意中英文字符
saveStyp = DFDL,ARRE,ONRE,STLS
#IMF MEAT报头配置
RCVR=
TYPE=KAKO
STYP=CARM
AppId=warehouse
\ No newline at end of file
#log4j=log_api.xml
isneedlog=N
#psip=218.28.199.134
psip=10.50.3.74
psport=7484
encoding=UTF-8
########Log4j configuration#####################################
log4j.rootLogger=INFO, stdout, fileout
log4j.logger.com.fiscal = INFO
#*******************************
log4j.logger.com.system = INFO
#*******************************
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{MM-dd HH:mm:ss,SSSS}[%p] %m%n
#yyyy-MM-dd HH:mm:ss
log4j.appender.fileout=org.apache.log4j.RollingFileAppender
log4j.appender.fileout.File=logs/imf.log
log4j.appender.fileout.MaxFileSize=50MB
log4j.appender.fileout.MaxBackupIndex=10
log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.ConversionPattern=%d{MM-dd HH:mm:ss,SSSS}[%p] %m%n
... ... @@ -25,7 +25,7 @@
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
<level>info</level>
</filter>
<encoder>
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
... ... @@ -172,14 +172,14 @@
<!--开发环境:打印控制台-->
<springProfile name="dev">
<logger name="org.springframework.security" level="trace"/>
<logger name="org.springframework.security" level="debug"/>
<logger name="org.apache.tomcat" level="info" />
<logger name="com.tianbo.warehouse.dao" level="DEBUG" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
<!--<appender-ref ref="DEBUG_FILE" />-->
<!--<appender-ref ref="INFO_FILE" />-->
<!--<appender-ref ref="WARN_FILE" />-->
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="WARN_FILE" />
<appender-ref ref="ERROR_FILE" />
</root>
</springProfile>
... ...
... ... @@ -11,7 +11,7 @@
</parent>
<groupId>com.tianbo</groupId>
<artifactId>warehouse</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>2.0Beta</version>
<name>warehouse</name>
<description>warehouse for Spring Boot</description>
... ...
Manifest-Version: 1.0
Class-Path: thymeleaf-extras-java8time-3.0.4.RELEASE.jar springfox-swa
gger-common-2.9.2.jar commons-math-2.2.jar attoparser-2.0.5.RELEASE.j
ar spring-cloud-netflix-eureka-client-2.1.5.BUILD-20191219.032215-243
.jar netty-buffer-4.1.42.Final.jar bcpkix-jdk15on-1.64.jar aspectjwea
ver-1.9.4.jar spring-cloud-starter-netflix-eureka-client-2.1.5.BUILD-
20191219.032239-243.jar logback-core-1.2.3.jar slf4j-api-1.7.28.jar s
pring-context-5.2.0.RELEASE.jar mybatis-3.4.6.jar classmate-1.5.0.jar
jackson-datatype-jsr310-2.10.0.jar spring-security-crypto-5.2.0.RELE
ASE.jar mapstruct-1.2.0.Final.jar antlr-2.7.7.jar jboss-logging-3.4.1
.Final.jar springfox-schema-2.9.2.jar spring-aop-5.2.0.RELEASE.jar sp
ring-plugin-core-1.2.0.RELEASE.jar tomcat-embed-core-9.0.27.jar thyme
leaf-spring5-3.0.11.RELEASE.jar spring-jcl-5.2.0.RELEASE.jar HikariCP
-3.4.1.jar jersey-core-1.19.1.jar commons-jxpath-1.3.jar spring-boot-
starter-validation-2.2.0.BUILD-20191016.163457-711.jar jettison-1.3.7
.jar spring-boot-starter-tomcat-2.2.0.BUILD-20191016.163456-712.jar g
uice-4.1.0.jar commons-codec-1.11.jar jackson-module-parameter-names-
2.10.0.jar lettuce-core-5.2.0.RELEASE.jar spring-websocket-5.2.0.RELE
ASE.jar spring-data-keyvalue-2.2.0.RELEASE.jar spring-boot-starter-2.
2.0.BUILD-20191016.163501-711.jar netflix-commons-util-0.3.0.jar xmlp
ull-1.1.3.1.jar stax-api-1.0.1.jar netty-codec-4.1.42.Final.jar druid
-1.1.9.jar spring-oxm-5.2.0.RELEASE.jar jsr311-api-1.1.1.jar spring-b
oot-starter-thymeleaf-2.2.0.BUILD-20191016.163455-712.jar ribbon-tran
sport-2.3.0.jar commons-lang-2.6.jar commons-io-2.6.jar spring-data-c
ommons-2.2.0.RELEASE.jar jackson-annotations-2.10.0.jar logback-class
ic-1.2.3.jar pagehelper-spring-boot-autoconfigure-1.2.5.jar dom4j-2.1
.0.jar servo-core-0.12.21.jar springfox-core-2.9.2.jar mysql-connecto
r-java-8.0.18.jar log4j-to-slf4j-2.12.1.jar ribbon-loadbalancer-2.3.0
.jar spring-cloud-starter-netflix-archaius-2.1.5.BUILD-20191219.03222
9-243.jar jsqlparser-1.0.jar netty-handler-4.1.42.Final.jar antlr-run
time-3.4.jar springfox-swagger-ui-2.9.2.jar mybatis-spring-boot-start
er-1.3.2.jar pagehelper-5.1.4.jar tomcat-embed-websocket-9.0.27.jar s
pring-boot-starter-json-2.2.0.BUILD-20191016.163444-713.jar jackson-c
ore-2.10.0.jar bcprov-jdk15on-1.64.jar springfox-spi-2.9.2.jar mybati
s-spring-1.3.2.jar netflix-infix-0.3.0.jar reactor-core-3.3.0.RELEASE
.jar snakeyaml-1.25.jar jakarta.validation-api-2.0.1.jar spring-secur
ity-core-5.2.0.RELEASE.jar spring-security-config-5.2.0.RELEASE.jar c
ommons-collections-3.2.2.jar jackson-databind-2.10.0.jar ribbon-core-
2.3.0.jar spring-boot-starter-websocket-2.2.0.BUILD-20191016.163500-7
11.jar eureka-core-1.9.13.jar eureka-client-1.9.13.jar netty-common-4
.1.42.Final.jar rxnetty-servo-0.4.9.jar unbescape-1.1.6.RELEASE.jar r
xjava-1.3.8.jar gson-2.8.6.jar mybatis-spring-boot-autoconfigure-1.3.
2.jar druid-spring-boot-starter-1.1.9.jar ribbon-eureka-2.3.0.jar spr
ing-boot-starter-data-redis-2.2.0.BUILD-20191016.163436-713.jar sprin
g-cloud-commons-2.1.5.BUILD-20191219.033001-243.jar spring-boot-confi
guration-processor-2.2.0.BUILD-20191016.163408-713.jar spring-cloud-c
ontext-2.1.5.BUILD-20191219.032901-243.jar spring-boot-starter-jdbc-2
.2.0.BUILD-20191016.163441-713.jar httpcore-4.4.12.jar commons-config
uration-1.8.jar xpp3_min-1.1.4c.jar spring-plugin-metadata-1.2.0.RELE
ASE.jar jackson-datatype-jdk8-2.10.0.jar reactive-streams-1.0.3.jar j
ersey-apache-client4-1.19.1.jar httpclient-4.5.10.jar spring-cloud-ne
tflix-ribbon-2.1.5.BUILD-20191219.031914-243.jar spring-boot-autoconf
igure-2.2.0.BUILD-20191016.163400-713.jar HdrHistogram-2.1.9.jar spri
ng-security-rsa-1.0.9.RELEASE.jar jjwt-0.7.0.jar spring-core-5.2.0.RE
LEASE.jar netflix-eventbus-0.3.0.jar spring-cloud-starter-netflix-rib
bon-2.1.5.BUILD-20191219.032234-243.jar spring-cloud-netflix-archaius
-2.1.5.BUILD-20191219.031847-243.jar spring-context-support-5.2.0.REL
EASE.jar spring-boot-starter-logging-2.2.0.BUILD-20191016.163447-713.
jar hystrix-core-1.5.18.jar ojdbc6-11.2.0.4.0-atlassian-hosted.jar sp
ring-boot-starter-web-2.2.0.BUILD-20191016.163459-711.jar spring-clou
d-netflix-hystrix-2.1.5.BUILD-20191219.031954-243.jar stax2-api-4.2.j
ar pagehelper-spring-boot-starter-1.2.5.jar stringtemplate-3.2.1.jar
spring-expression-5.2.0.RELEASE.jar javax.inject-1.jar spring-cloud-s
tarter-2.1.5.BUILD-20191219.033020-243.jar spring-boot-starter-aop-2.
2.0.BUILD-20191016.163422-713.jar spring-messaging-5.2.0.RELEASE.jar
spring-security-web-5.2.0.RELEASE.jar spring-web-5.2.0.RELEASE.jar je
rsey-client-1.19.1.jar netty-transport-4.1.42.Final.jar ribbon-2.3.0.
jar woodstox-core-5.2.1.jar springfox-swagger2-2.9.2.jar xstream-1.4.
11.1.jar guava-20.0.jar hibernate-validator-6.0.17.Final.jar jakarta.
annotation-api-1.3.5.jar aopalliance-1.0.jar jaxen-1.2.0.jar jul-to-s
lf4j-1.7.28.jar spring-tx-5.2.0.RELEASE.jar spring-webmvc-5.2.0.RELEA
SE.jar byte-buddy-1.10.1.jar fastjson-1.2.28.jar swagger-annotations-
1.5.20.jar thymeleaf-3.0.11.RELEASE.jar log4j-api-2.12.1.jar spring-b
eans-5.2.0.RELEASE.jar tomcat-embed-el-9.0.27.jar rxnetty-0.4.9.jar r
ibbon-httpclient-2.3.0.jar springfox-spring-web-2.9.2.jar archaius-co
re-0.7.6.jar swagger-models-1.5.20.jar spring-boot-2.2.0.BUILD-201910
16.163506-711.jar spring-data-redis-2.2.0.RELEASE.jar spring-jdbc-5.2
.0.RELEASE.jar spring-boot-starter-security-2.2.0.BUILD-20191016.1634
54-713.jar netty-resolver-4.1.42.Final.jar rxnetty-contexts-0.4.9.jar
joda-time-2.10.4.jar netflix-statistics-0.1.1.jar
Class-Path: thymeleaf-3.0.11.RELEASE.jar stringtemplate-3.2.1.jar mysq
l-connector-java-8.0.17.jar brave-instrumentation-servlet-5.7.0.jar j
avax.inject-1.jar thymeleaf-spring5-3.0.11.RELEASE.jar jul-to-slf4j-1
.7.28.jar spring-boot-starter-websocket-2.1.9.RELEASE.jar spring-secu
rity-config-5.1.6.RELEASE.jar jettison-1.3.7.jar brave-5.7.0.jar reac
tor-core-3.2.12.RELEASE.jar commons-lang-2.6.jar tomcat-embed-core-9.
0.26.jar spring-security-web-5.1.6.RELEASE.jar jackson-annotations-2.
9.0.jar spring-boot-starter-logging-2.1.9.RELEASE.jar lettuce-core-5.
1.8.RELEASE.jar hibernate-validator-6.0.17.Final.jar springfox-schema
-2.9.2.jar spring-plugin-core-1.2.0.RELEASE.jar netty-handler-4.1.39.
Final.jar spring-boot-starter-data-redis-2.1.9.RELEASE.jar mybatis-sp
ring-boot-starter-1.3.2.jar springfox-swagger-common-2.9.2.jar druid-
spring-boot-starter-1.1.9.jar stax-api-1.0.1.jar jboss-logging-3.3.3.
Final.jar spring-cloud-starter-netflix-archaius-2.1.3.RELEASE.jar dru
id-1.1.9.jar reactive-streams-1.0.3.jar jersey-apache-client4-1.19.1.
jar netty-resolver-4.1.39.Final.jar rxjava-1.3.8.jar xpp3_min-1.1.4c.
jar woodstox-core-5.0.3.jar snakeyaml-1.23.jar springfox-swagger2-2.9
.2.jar spring-plugin-metadata-1.2.0.RELEASE.jar springfox-swagger-ui-
2.9.2.jar spring-cloud-netflix-hystrix-2.1.3.RELEASE.jar HikariCP-3.2
.0.jar spring-security-crypto-5.1.6.RELEASE.jar bcprov-jdk15on-1.60.j
ar zipkin-sender-amqp-client-2.10.2.jar unbescape-1.1.6.RELEASE.jar s
pring-messaging-5.1.10.RELEASE.jar netflix-statistics-0.1.1.jar sprin
g-data-keyvalue-2.1.11.RELEASE.jar spring-expression-5.1.10.RELEASE.j
ar brave-instrumentation-jms-5.7.0.jar zipkin-reporter-2.10.2.jar com
mons-configuration-1.8.jar springfox-spring-web-2.9.2.jar mapstruct-1
.2.0.Final.jar spring-context-5.1.10.RELEASE.jar spring-boot-starter-
2.1.9.RELEASE.jar swagger-models-1.5.20.jar netty-transport-4.1.39.Fi
nal.jar guava-20.0.jar aspectjweaver-1.9.4.jar attoparser-2.0.5.RELEA
SE.jar springfox-spi-2.9.2.jar jersey-client-1.19.1.jar spring-aop-5.
1.10.RELEASE.jar spring-boot-2.1.9.RELEASE.jar jersey-core-1.19.1.jar
commons-io-2.6.jar ribbon-transport-2.3.0.jar validation-api-2.0.1.F
inal.jar commons-collections-3.2.2.jar spring-boot-starter-tomcat-2.1
.9.RELEASE.jar spring-boot-autoconfigure-2.1.9.RELEASE.jar rxnetty-co
ntexts-0.4.9.jar rxnetty-0.4.9.jar javax.annotation-api-1.3.2.jar spr
ing-data-redis-2.1.11.RELEASE.jar commons-codec-1.11.jar brave-instru
mentation-http-5.7.0.jar spring-boot-configuration-processor-2.1.9.RE
LEASE.jar slf4j-api-1.7.28.jar thymeleaf-extras-java8time-3.0.4.RELEA
SE.jar spring-boot-starter-thymeleaf-2.1.9.RELEASE.jar spring-cloud-n
etflix-archaius-2.1.3.RELEASE.jar zipkin-sender-kafka-2.10.2.jar spri
ng-cloud-sleuth-core-2.1.3.RELEASE.jar gson-2.8.5.jar jackson-datatyp
e-jdk8-2.9.9.jar spring-boot-starter-json-2.1.9.RELEASE.jar ribbon-2.
3.0.jar spring-boot-actuator-autoconfigure-2.1.9.RELEASE.jar LatencyU
tils-2.0.3.jar classmate-1.4.0.jar spring-security-core-5.1.6.RELEASE
.jar spring-cloud-starter-zipkin-2.1.3.RELEASE.jar spring-cloud-sleut
h-zipkin-2.1.3.RELEASE.jar antlr-2.7.7.jar json-simple-1.1.1.jar xmlp
ull-1.1.3.1.jar brave-instrumentation-kafka-clients-5.7.0.jar jaxen-1
.1.6.jar antlr-runtime-3.4.jar spring-oxm-5.1.10.RELEASE.jar spring-j
cl-5.1.10.RELEASE.jar xstream-1.4.11.1.jar httpcore-4.4.12.jar spring
fox-core-2.9.2.jar spring-boot-starter-web-2.1.9.RELEASE.jar spring-b
oot-starter-security-2.1.9.RELEASE.jar spring-cloud-starter-netflix-e
ureka-client-2.1.3.RELEASE.jar jackson-datatype-jsr310-2.9.9.jar spri
ng-boot-admin-client-2.1.6.jar netty-common-4.1.39.Final.jar spring-c
ontext-support-5.1.10.RELEASE.jar hystrix-core-1.5.18.jar spring-tx-5
.1.10.RELEASE.jar spring-cloud-starter-2.1.3.RELEASE.jar jackson-core
-2.9.9.jar logback-core-1.2.3.jar spring-cloud-netflix-ribbon-2.1.3.R
ELEASE.jar tomcat-embed-websocket-9.0.26.jar ribbon-httpclient-2.3.0.
jar micrometer-core-1.1.7.jar spring-cloud-starter-netflix-ribbon-2.1
.3.RELEASE.jar spring-cloud-netflix-eureka-client-2.1.3.RELEASE.jar c
ommons-math-2.2.jar aspectjrt-1.9.4.jar netflix-commons-util-0.3.0.ja
r spring-cloud-commons-2.1.3.RELEASE.jar jolokia-core-1.6.2.jar sprin
g-jdbc-5.1.10.RELEASE.jar rxnetty-servo-0.4.9.jar spring-webmvc-5.1.1
0.RELEASE.jar brave-instrumentation-spring-rabbit-5.7.0.jar spring-be
ans-5.1.10.RELEASE.jar jjwt-0.7.0.jar pagehelper-spring-boot-starter-
1.2.5.jar jackson-databind-2.9.9.3.jar brave-instrumentation-httpclie
nt-5.7.0.jar commons-jxpath-1.3.jar netflix-infix-0.3.0.jar spring-bo
ot-starter-actuator-2.1.9.RELEASE.jar ribbon-loadbalancer-2.3.0.jar s
pring-boot-admin-starter-client-2.1.6.jar spring-boot-starter-jdbc-2.
1.9.RELEASE.jar spring-websocket-5.1.10.RELEASE.jar log4j-to-slf4j-2.
11.2.jar mybatis-spring-boot-autoconfigure-1.3.2.jar zipkin-2.16.0.ja
r spring-boot-starter-aop-2.1.9.RELEASE.jar bcpkix-jdk15on-1.60.jar l
og4j-api-2.11.2.jar tomcat-embed-el-9.0.26.jar eureka-core-1.9.13.jar
servo-core-0.12.21.jar logback-classic-1.2.3.jar spring-boot-actuato
r-2.1.9.RELEASE.jar brave-instrumentation-spring-webmvc-5.7.0.jar bra
ve-instrumentation-httpasyncclient-5.7.0.jar httpclient-4.5.10.jar js
qlparser-1.0.jar eureka-client-1.9.13.jar joda-time-2.10.4.jar spring
-security-rsa-1.0.7.RELEASE.jar guice-4.1.0.jar mybatis-spring-1.3.2.
jar spring-cloud-context-2.1.3.RELEASE.jar mybatis-3.4.6.jar spring-c
ore-5.1.10.RELEASE.jar ribbon-core-2.3.0.jar netty-codec-4.1.39.Final
.jar HdrHistogram-2.1.9.jar dom4j-2.1.0.jar pagehelper-5.1.4.jar fast
json-1.2.28.jar spring-data-commons-2.1.11.RELEASE.jar swagger-annota
tions-1.5.20.jar ribbon-eureka-2.3.0.jar jackson-module-parameter-nam
es-2.9.9.jar stax2-api-3.1.4.jar aopalliance-1.0.jar byte-buddy-1.9.1
6.jar archaius-core-0.7.6.jar pagehelper-spring-boot-autoconfigure-1.
2.5.jar netty-buffer-4.1.39.Final.jar spring-web-5.1.10.RELEASE.jar b
rave-context-log4j2-5.7.0.jar netflix-eventbus-0.3.0.jar jsr311-api-1
.1.1.jar spring-cloud-starter-sleuth-2.1.3.RELEASE.jar brave-instrume
ntation-spring-web-5.7.0.jar
Main-Class: com.tianbo.warehouse.WarehouseApplication
... ...
... ... @@ -100,8 +100,8 @@ public class UserController {
@PutMapping("/roleset")
public ResultJson roleSet(@RequestBody Map<String,Object> map){
Integer id = (Integer) map.get("id");
List<Integer> roles = (List<Integer>) map.get("setRole");
Integer id = (Integer) map.get("userId");
List<Integer> roles = (List<Integer>) map.get("roleIds");
UserRole userRole = new UserRole();
userRole.setUserId(id);
userRole.setRoleIds(roles);
... ...
... ... @@ -20,6 +20,8 @@ public interface PERMISSIONMapper {
List<PERMISSION> findAll(@Param("name") String name);
List<PERMISSION> selectByParentId(Integer permissionId);
List<PERMISSION> getAllMenus();
List<PERMISSION> findByUserId(Integer userId);
... ...
... ... @@ -16,6 +16,8 @@ public interface ROLEMapper {
List<ROLE> findRolesByUserId(Integer userId);
List<ROLE> selectByParentId(Integer roleId);
List<ROLE> findAll(@Param("roleName") String roleName);
int updateByPrimaryKeySelective(ROLE record);
... ...
package com.tianbo.warehouse.model;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import java.util.List;
@Data
public class ROLE implements GrantedAuthority {
private static final long serialVersionUID = 1L;
private Integer roleId;
private Integer parentid;
private String roleName;
private String roleSign;
... ... @@ -18,17 +22,20 @@ public class ROLE implements GrantedAuthority {
private String departmentId;
private String departmentName;
private String type;
private List<PERMISSION> permissions;
public String getDepartmentName() {
return departmentName;
}
private Integer rsort;
private String customsRegCode;
private String businessLicense;
private String departmentid;
private List<ROLE> children;
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public Integer getRoleId() {
return roleId;
... ... @@ -62,21 +69,14 @@ public class ROLE implements GrantedAuthority {
this.description = description == null ? null : description.trim();
}
public String getDepartmentId() {
return departmentId;
public String getType() {
return type;
}
public void setDepartmentId(String departmentId) {
this.departmentId = departmentId == null ? null : departmentId.trim();
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public List<PERMISSION> getPermissions() {
return permissions;
}
public void setPermissions(List<PERMISSION> permissions) {
this.permissions = permissions;
}
@Override
public String getAuthority(){
... ...
... ... @@ -26,4 +26,8 @@ public class UserRole {
this.roleId=roleId;
this.userId = userId;
}
public UserRole(Integer userId,Integer roleId){
this.roleId=roleId;
this.userId = userId;
}
}
... ...
... ... @@ -28,7 +28,7 @@ public class MyInvocationSecurityMetadataSourceService implements FilterInvocati
private HashMap<String, Collection<ConfigAttribute>> map =null;
/**
* 加载权限表中所有权限,还是加载URL所需要的权限
* 加载权限表URL所需要的权限
*/
public void loadResourceDefine(String requestUrl){
map = new HashMap<>();
... ... @@ -41,17 +41,14 @@ public class MyInvocationSecurityMetadataSourceService implements FilterInvocati
//此处只添加了用户的名字,其实还可以添加更多权限的信息,
// 例如请求方法到ConfigAttribute的集合中去。
// 此处添加的信息将会作为MyAccessDecisionManager类的decide的第三个参数。
//CFG存储访问的URL需要的权限"ROLE_??"LIST
String pUrl = permission.getUrl();
List<String> urlOfRoles = permissionMapper.findRoleListByUrl(pUrl);
//路径适配,这个很重要,是配上后会包含其他适配的所有权限,比如/**与/user/List是可以适配上的,
// 那么/**这个通用适配是要有/user/list这个路径所对应的角色信息的
if(pathMatcher.match(pUrl,requestUrl)){
}
List<String> urlOfRoles = permissionMapper.findRoleListByUrl(pUrl);
for (String roleName:urlOfRoles) {
if(null!=roleName) {
... ... @@ -59,6 +56,9 @@ public class MyInvocationSecurityMetadataSourceService implements FilterInvocati
array.add(cfg);
}
}
}
//用权限的getUrl() 作为map的key,用ConfigAttribute的集合作为 value,
map.put(pUrl, array);
... ... @@ -136,8 +136,8 @@ public class MyInvocationSecurityMetadataSourceService implements FilterInvocati
*/
@Override
public Collection<ConfigAttribute> getAllConfigAttributes() {
// return loadResourceDefine();
return null;
return loadResourceDefine();
// return null;
}
@Override
... ...
... ... @@ -7,6 +7,8 @@ import com.tianbo.warehouse.security.handel.*;
import com.tianbo.warehouse.security.MyFilterSecurityInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
... ... @@ -75,6 +77,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
//静态文件允许访问
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
//跨域配置
.requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
//管理页面只允许管理员角色访问
... ...
... ... @@ -27,7 +27,7 @@ public class PermissionServiceImp implements PermissionService {
PageInfo<PERMISSION> result = new PageInfo<>(getPermissionList(list, 0));
return result;
}
@Override
public List<PERMISSION> findByRoleId(Integer roleId) {
List<PERMISSION> list = getPermissionList(permissionMapper.findByRoleId(roleId), 0);
return list;
... ... @@ -38,7 +38,7 @@ public class PermissionServiceImp implements PermissionService {
return permissionMapper.insertSelective(record);
}
@Override
public List<PERMISSION> getPermissionList(List<PERMISSION> permissions, Integer pid) {
List<PERMISSION> permissionList = new ArrayList<>();
for (PERMISSION permission : permissions) {
... ...
... ... @@ -36,17 +36,6 @@ public class RoleServiceImp implements RoleService{
public PageInfo<ROLE> findAll(int pageNum, int pageSize, String roleName){
Page<ROLE> page = PageHelper.startPage(pageNum,pageSize);
List<ROLE> list = roleMapper.findAll(roleName);
for (ROLE role: list){
if(role.getPermissions().size()>1){
role.setPermissions(permissionService.getPermissionList(role.getPermissions(),0));
}
Department department = departmentMapper.selectByPrimaryKey(role.getDepartmentId());
if (department == null){
role.setDepartmentName("无");
}else {
role.setDepartmentName(department.getDepartmentName());
}
}
PageInfo<ROLE> result = new PageInfo<ROLE>(list);
return result;
... ...
... ... @@ -68,9 +68,6 @@ public class UserServiceImpl implements UserService{
// user.setPermissions(permissionList);
List<ROLE> roleList = roleMapper.findRolesByUserId(user.getUserId());
user.setRoles(roleList);
if(user.getUserId() == 27){
System.out.println(users.getRoles());
}
}
PageInfo<USERS> result = new PageInfo<USERS>(list);
return result;
... ... @@ -119,7 +116,7 @@ public class UserServiceImpl implements UserService{
userRoleMapper.deleteByUserId(userId);
if (null!=ids && !ids.isEmpty()){
for (Integer id:ids) {
UserRole ur = new UserRole(new Random().nextInt(10000000)+1,userId,id);
UserRole ur = new UserRole(userId,id);
userRoleMapper.insertSelective(ur);
}
}
... ...
... ... @@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
<classPathEntry location="/Users/shenhailong/.m2/repository/mysql/mysql-connector-java/5.1.30/mysql-connector-java-5.1.30.jar"/>
<classPathEntry location="/Users/mrz/Documents/maven/mysql-connector-java-5.1.7-bin.jar"/>
<!--<classPathEntry location="/Users/mrz/Documents/maven/ojdbc6.jar"/>-->
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
... ... @@ -14,7 +14,7 @@
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://118.31.66.166:3306/HQPT_USER"
connectionURL="jdbc:mysql://118.31.66.166:3306/statistics"
userId="110"
password="QAHqCJf2kFYCLirM">
</jdbcConnection>
... ... @@ -45,6 +45,6 @@
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<table tableName="staff_aparment_come_car" domainObjectName="StaffApartmentComeCar" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="role" domainObjectName="ROLE" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
\ No newline at end of file
... ...
... ... @@ -29,10 +29,20 @@
select
<include refid="Base_Column_List" />
from permission
<if test="name != '' and name !=null" >
where name = #{name, jdbcType=VARCHAR}
</if>
ORDER BY permission_order
where 1=1
<choose>
<when test="name != '' and name !=null" >
and name = #{name, jdbcType=VARCHAR}
</when>
</choose>
ORDER BY parent_id,permission_order
</select>
<select id="selectByParentId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from permission
where parent_id = #{permissionId, jdbcType=INTEGER}
ORDER BY parent_id,permission_order
</select>
<select id="getRolePermisson" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select p.*
... ...
<?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="com.tianbo.warehouse.dao.ROLEMapper" >
<resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.ROLE" >
<id column="role_id" property="roleId" jdbcType="INTEGER" />
<result column="role_name" property="roleName" jdbcType="VARCHAR" />
<result column="role_sign" property="roleSign" jdbcType="VARCHAR" />
<result column="description" property="description" jdbcType="VARCHAR" />
<result column="department_id" property="departmentId" jdbcType="VARCHAR" />
<collection property="permissions" ofType="com.tianbo.warehouse.model.PERMISSION" javaType="java.util.ArrayList" select="com.tianbo.warehouse.dao.PERMISSIONMapper.getRolePermisson" column="role_id"></collection>
<?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="com.tianbo.warehouse.dao.ROLEMapper">
<resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.ROLE">
<id column="role_id" jdbcType="INTEGER" property="roleId" />
<result column="role_name" jdbcType="VARCHAR" property="roleName" />
<result column="role_sign" jdbcType="VARCHAR" property="roleSign" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="parentId" jdbcType="INTEGER" property="parentid" />
<result column="rsort" jdbcType="INTEGER" property="rsort" />
<result column="customs_reg_code" jdbcType="VARCHAR" property="customsRegCode" />
<result column="business_license" jdbcType="VARCHAR" property="businessLicense" />
<result column="departmentId" jdbcType="VARCHAR" property="departmentid" />
<collection column="role_id" javaType="java.util.ArrayList" ofType="com.tianbo.warehouse.model.PERMISSION" property="permissions" select="com.tianbo.warehouse.dao.PERMISSIONMapper.getRolePermisson" />
<collection column="role_id" property="children" select="selectByParentId" />
</resultMap>
<sql id="Base_Column_List" >
role_id, role_name, role_sign, description, department_id
<sql id="Base_Column_List">
role_id, role_name, role_sign, description, type, parentId, rsort, customs_reg_code,
business_license, departmentId
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from role
where role_id = #{roleId,jdbcType=INTEGER}
</select>
<select id="findAll" resultMap="BaseResultMap" parameterType="java.lang.String">
SELECT
<select id="selectByParentId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
FROM role
<if test="roleName != '' and roleName !=null" >
where role_name = #{roleName, jdbcType=VARCHAR}
</if>
</select>
<select id="findRolesByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT
R.*
FROM
users U
LEFT JOIN user_role UR ON U.user_id = UR.user_id
LEFT JOIN role R ON R.role_id= UR.role_id
where U.user_id = #{userId,jdbcType=INTEGER}
from role
where parentId = #{roleId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from role
where role_id = #{roleId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.tianbo.warehouse.model.ROLE" >
<insert id="insert" parameterType="com.tianbo.warehouse.model.ROLE">
insert into role (role_id, role_name, role_sign,
description, department_id)
description, type, parentId,
rsort, customs_reg_code, business_license,
departmentId)
values (#{roleId,jdbcType=INTEGER}, #{roleName,jdbcType=VARCHAR}, #{roleSign,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{departmentId,jdbcType=VARCHAR})
#{description,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{parentid,jdbcType=INTEGER},
#{rsort,jdbcType=INTEGER}, #{customsRegCode,jdbcType=VARCHAR}, #{businessLicense,jdbcType=VARCHAR},
#{departmentid,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tianbo.warehouse.model.ROLE" >
<insert id="insertSelective" parameterType="com.tianbo.warehouse.model.ROLE">
insert into role
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="roleId != null" >
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="roleId != null">
role_id,
</if>
<if test="roleName != null" >
<if test="roleName != null">
role_name,
</if>
<if test="roleSign != null" >
<if test="roleSign != null">
role_sign,
</if>
<if test="description != null" >
<if test="description != null">
description,
</if>
<if test="departmentId != null" >
department_id,
<if test="type != null">
type,
</if>
<if test="parentid != null">
parentId,
</if>
<if test="rsort != null">
rsort,
</if>
<if test="customsRegCode != null">
customs_reg_code,
</if>
<if test="businessLicense != null">
business_license,
</if>
<if test="departmentid != null">
departmentId,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="roleId != null" >
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="roleId != null">
#{roleId,jdbcType=INTEGER},
</if>
<if test="roleName != null" >
<if test="roleName != null">
#{roleName,jdbcType=VARCHAR},
</if>
<if test="roleSign != null" >
<if test="roleSign != null">
#{roleSign,jdbcType=VARCHAR},
</if>
<if test="description != null" >
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
<if test="departmentId != null" >
#{departmentId,jdbcType=VARCHAR},
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="parentid != null">
#{parentid,jdbcType=INTEGER},
</if>
<if test="rsort != null">
#{rsort,jdbcType=INTEGER},
</if>
<if test="customsRegCode != null">
#{customsRegCode,jdbcType=VARCHAR},
</if>
<if test="businessLicense != null">
#{businessLicense,jdbcType=VARCHAR},
</if>
<if test="departmentid != null">
#{departmentid,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.ROLE" >
<update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.ROLE">
update role
<set >
<if test="roleName != null" >
<set>
<if test="roleName != null">
role_name = #{roleName,jdbcType=VARCHAR},
</if>
<if test="roleSign != null" >
<if test="roleSign != null">
role_sign = #{roleSign,jdbcType=VARCHAR},
</if>
<if test="description != null" >
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="departmentId != null" >
department_id = #{departmentId,jdbcType=VARCHAR},
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
<if test="parentid != null">
parentId = #{parentid,jdbcType=INTEGER},
</if>
<if test="rsort != null">
rsort = #{rsort,jdbcType=INTEGER},
</if>
<if test="customsRegCode != null">
customs_reg_code = #{customsRegCode,jdbcType=VARCHAR},
</if>
<if test="businessLicense != null">
business_license = #{businessLicense,jdbcType=VARCHAR},
</if>
<if test="departmentid != null">
departmentId = #{departmentid,jdbcType=VARCHAR},
</if>
</set>
where role_id = #{roleId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.ROLE" >
<update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.ROLE">
update role
set role_name = #{roleName,jdbcType=VARCHAR},
role_sign = #{roleSign,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
department_id = #{departmentId,jdbcType=VARCHAR}
type = #{type,jdbcType=VARCHAR},
parentId = #{parentid,jdbcType=INTEGER},
rsort = #{rsort,jdbcType=INTEGER},
customs_reg_code = #{customsRegCode,jdbcType=VARCHAR},
business_license = #{businessLicense,jdbcType=VARCHAR},
departmentId = #{departmentid,jdbcType=VARCHAR}
where role_id = #{roleId,jdbcType=INTEGER}
</update>
<select id="findAll" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM role
where parentId=0
and 1=1
<if test="roleName != '' and roleName !=null">
and role_name = #{roleName, jdbcType=VARCHAR}
</if>
</select>
<select id="findRolesByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT
R.*
FROM
users U
LEFT JOIN user_role UR ON U.user_id = UR.user_id
LEFT JOIN role R ON R.role_id= UR.role_id
where U.user_id = #{userId,jdbcType=INTEGER}
</select>
</mapper>
\ No newline at end of file
... ...