REM:
1. 增加清洗设备数据库添加,删除功能
2. 增加清洗设备管理服务
This commit is contained in:
huangxin 2020-04-10 19:24:02 +08:00
parent 7bc29f42c9
commit 9f354c1cb8
32 changed files with 599 additions and 422 deletions

18
.idea/checkstyle-idea.xml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CheckStyle-IDEA">
<option name="configuration">
<map>
<entry key="active-configuration" value="LOCAL_FILE:C:/Users/xajhu/Documents/checkstyle.xml:hyCheckStyle" />
<entry key="checkstyle-version" value="8.23" />
<entry key="copy-libs" value="true" />
<entry key="location-0" value="BUNDLED:(bundled):Sun Checks" />
<entry key="location-1" value="BUNDLED:(bundled):Google Checks" />
<entry key="location-2" value="LOCAL_FILE:C:/Users/xajhu/Documents/checkstyle.xml:hyCheckStyle" />
<entry key="scan-before-checkin" value="false" />
<entry key="scanscope" value="JavaOnly" />
<entry key="suppress-errors" value="false" />
</map>
</option>
</component>
</project>

View File

@ -0,0 +1,6 @@
This folder contains libraries copied from the "phoenix_ddos_handle" project.
It is managed by the CheckStyle-IDEA IDE plugin.
Do not modify this folder while the IDE is running.
When the IDE is stopped, you may delete this folder at any time. It will be recreated as needed.
In order to prevent the CheckStyle-IDEA IDE plugin from creating this folder,
uncheck the "Copy libraries from project directory" option in the CheckStyle-IDEA settings dialog.

11
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@172.28.72.118" uuid="9e091392-bdd9-4edc-aa76-e9c49c1953c4">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://172.28.72.118:33061/</jdbc-url>
</data-source>
</component>
</project>

View File

@ -3,6 +3,6 @@
<component name="Encoding"> <component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="PROJECT" charset="GBK" /> <file url="PROJECT" charset="UTF-8" />
</component> </component>
</project> </project>

30
.idea/jarRepositories.xml Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="aqbrel" />
<option name="name" value="aqbrel" />
<option name="url" value="http://nexus.komect.net/nexus/content/repositories/aqb/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="aliyun" />
<option name="name" value="aliyun" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/src/main/resources/mappers/DisposeDeviceManager.xml" dialect="GenericSQL" />
</component>
</project>

View File

@ -1,263 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>
</facet>
</component>
<component name="MavenCustomPomFilePath">
<option name="mavenPomFileUrl" value="file://$MODULE_DIR$/data-pom.xml" />
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$/src/main/java">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
</content>
<content url="file://$MODULE_DIR$/src/main/resources">
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
</content>
<content url="file://$MODULE_DIR$/src/test/java">
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.springframework.boot:spring-boot-starter-actuator:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.12.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.12.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.30" level="project" />
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.springframework.boot:spring-boot-actuator-autoconfigure:2.2.4.RELEASE" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.springframework.boot:spring-boot-actuator:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.micrometer:micrometer-core:1.3.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.hdrhistogram:HdrHistogram:2.1.11" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.latencyutils:LatencyUtils:2.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.31" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.5" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.springframework.boot:spring-boot-devtools:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-configuration-processor:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.20" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.20" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.9.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.9.2" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.19" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.2.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.0" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-dbcp2:2.7.0" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.10" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.2.4.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.2.4.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.2.4.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
<orderEntry type="library" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.2" level="project" />
<orderEntry type="library" name="Maven: jakarta.activation:jakarta.activation-api:1.2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.5.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.5.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.5.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.5.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.5.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.vintage:junit-vintage-engine:5.5.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.5.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:3.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.13.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.6" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.2.3.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.2.3.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.2.3.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.6.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
<orderEntry type="library" name="Maven: oro:oro:2.0.8" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:28.2-jre" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.10.0" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.4" level="project" />
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.10.5" level="project" />
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.0.0" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-spring-boot-starter:2.0.4" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-core:1.0.5" level="project" />
<orderEntry type="library" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-base:1.0.5" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-weekend:1.1.4.1" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-spring:1.0.5" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-extra:1.0.5" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-spring-boot-autoconfigure:2.0.4" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.2.9" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.2.9" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.1.7" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:1.2" level="project" />
<orderEntry type="library" name="Maven: com.cmcc:enc.dec:1.3.1" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.13" level="project" />
<orderEntry type="library" name="Maven: redis.clients:jedis:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.objenesis:objenesis:2.6" level="project" />
<orderEntry type="library" name="Maven: io.protostuff:protostuff-core:1.4.4" level="project" />
<orderEntry type="library" name="Maven: io.protostuff:protostuff-api:1.4.4" level="project" />
<orderEntry type="library" name="Maven: io.protostuff:protostuff-runtime:1.4.4" level="project" />
<orderEntry type="library" name="Maven: io.protostuff:protostuff-collectionschema:1.4.4" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.7.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.powermock:powermock-api-mockito2:2.0.5" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.powermock:powermock-api-support:2.0.5" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.powermock:powermock-reflect:2.0.5" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.powermock:powermock-core:2.0.5" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.powermock:powermock-module-junit4:2.0.5" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.powermock:powermock-module-junit4-common:2.0.5" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:2.1" level="project" />
<orderEntry type="library" name="Maven: org.redisson:redisson:3.12.1" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.45.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.45.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.45.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.45.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.45.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver-dns:4.1.45.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-dns:4.1.45.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.45.Final" level="project" />
<orderEntry type="library" name="Maven: javax.cache:cache-api:1.1.1" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.3.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.3" level="project" />
<orderEntry type="library" name="Maven: io.reactivex.rxjava2:rxjava:2.2.17" level="project" />
<orderEntry type="library" name="Maven: de.ruedigermoeller:fst:2.57" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.10.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.2" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.6" level="project" />
<orderEntry type="library" name="Maven: org.jodd:jodd-bean:5.0.13" level="project" />
<orderEntry type="library" name="Maven: org.jodd:jodd-core:5.0.13" level="project" />
<orderEntry type="library" name="Maven: javax.el:javax.el-api:3.0.0" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.web:javax.el:2.2.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.axis2:axis2-adb:1.7.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.axis2:axis2-kernel:1.7.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-api:1.2.21" level="project" />
<orderEntry type="library" name="Maven: jaxen:jaxen:1.2.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:1.0.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.james:apache-mime4j-core:0.7.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.ws.commons.axiom:axiom-impl:1.2.21" level="project" />
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-ws-metadata_2.0_spec:1.1.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.3" level="project" />
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.3.3" level="project" />
<orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.ws.xmlschema:xmlschema-core:2.2.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.neethi:neethi:3.0.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.woden:woden-core:1.0M10" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
<orderEntry type="library" name="Maven: javax.ws.rs:jsr311-api:1.1.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.ws.commons.axiom:axiom-dom:1.2.21" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.woodstox:woodstox-core-asl:4.2.0" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.woodstox:stax2-api:3.1.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.0.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-spring-boot-starter-jaxws:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-spring-boot-autoconfigure:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-transports-http:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-jaxws:3.3.6" level="project" />
<orderEntry type="library" name="Maven: xml-resolver:xml-resolver:1.2" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm:7.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-xml:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-simple:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-addr:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-policy:3.3.6" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-security:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-core:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jaxb:jaxb-runtime:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jaxb:txw2:2.3.2" level="project" />
<orderEntry type="library" name="Maven: com.sun.istack:istack-commons-runtime:3.0.8" level="project" />
<orderEntry type="library" name="Maven: org.jvnet.staxex:stax-ex:1.8.1" level="project" />
<orderEntry type="library" name="Maven: com.sun.xml.fastinfoset:FastInfoset:1.2.16" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.woodstox:woodstox-core:5.0.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-soap:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-wsdl:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-databinding-jaxb:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-security-saml:3.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-security:3.3.6" level="project" />
<orderEntry type="library" name="Maven: net.sf.ehcache:ehcache:2.10.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.wss4j:wss4j-ws-security-dom:2.2.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.wss4j:wss4j-ws-security-common:2.2.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.santuario:xmlsec:2.1.5" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-saml-impl:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-profile-api:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-core:3.3.1" level="project" />
<orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-core:4.1.2" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-saml-api:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-xmlsec-api:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-soap-api:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-security-impl:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-security-api:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-xmlsec-impl:3.3.1" level="project" />
<orderEntry type="library" name="Maven: net.shibboleth.utilities:java-support:7.3.0" level="project" />
<orderEntry type="library" name="Maven: org.cryptacular:cryptacular:1.2.4" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.64" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-xacml-impl:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-xacml-api:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-xacml-saml-impl:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.opensaml:opensaml-xacml-saml-api:3.3.1" level="project" />
<orderEntry type="library" name="Maven: org.jasypt:jasypt:1.9.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:1.8.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.wss4j:wss4j-policy:2.2.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.wss4j:wss4j-ws-security-stax:2.2.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.wss4j:wss4j-bindings:2.2.5" level="project" />
<orderEntry type="library" name="Maven: org.apache.wss4j:wss4j-ws-security-policy-stax:2.2.5" level="project" />
</component>
</module>

View File

@ -7,6 +7,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import tk.mybatis.spring.annotation.MapperScan; import tk.mybatis.spring.annotation.MapperScan;
/** /**
@ -19,6 +20,7 @@ import tk.mybatis.spring.annotation.MapperScan;
@EnableAsync @EnableAsync
@EnableScheduling @EnableScheduling
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@EnableTransactionManagement
@MapperScan(basePackages = { "com.cmcc.hy.phoenix.mapper" }) @MapperScan(basePackages = { "com.cmcc.hy.phoenix.mapper" })
@Slf4j @Slf4j
public class PhoenixBootApplication { public class PhoenixBootApplication {

View File

@ -7,8 +7,8 @@ public class ConstValue {
} }
public class SOAPWrapperConst { public class SOAPWrapperConst {
public static final String NAMESPACE_URI = "http://10.88.77.15/UMC/service/AbnormalFlowCleaningService"; public static final String NAMESPACE_URI = "http://%s/UMC/service/AbnormalFlowCleaningService";
public static final String SERVICE_ADDRESS = "http://10.88.77.15/UMC/service/AbnormalFlowCleaningService?wsdl"; //public static final String SERVICE_ADDRESS = "http://10.88.77.15/UMC/service/AbnormalFlowCleaningService?wsdl";
public static final String USER_NAME = "admin"; public static final String USER_NAME = "admin";
public static final String PASSWORD = "UMCAdministrator"; public static final String PASSWORD = "UMCAdministrator";
} }
@ -26,8 +26,21 @@ public class ConstValue {
public static final int AUTH_LOGOUT = 11; public static final int AUTH_LOGOUT = 11;
} }
public enum DisposeDevice { public enum DisposeDeviceType {
DPTECH_UMC, HAOHAN_PLATFORM; DPTECH_UMC (0, "集中能力管理平台"),
HAOHAN_PLATFORM (1, "处置设备");
private int code;
private String readme;
DisposeDeviceType(int code, String readme) {
this.code = code;
this.readme = readme;
}
public int getCode() {return this.code;}
public String getReadme() {return this.readme;}
} }
public class UserAccountStatus { public class UserAccountStatus {
@ -35,53 +48,4 @@ public class ConstValue {
public static final int LOCKED = 1; public static final int LOCKED = 1;
} }
/**
* @brief 错误码常量定义
*/
public enum ErrorCode {
ERR_OK (0, "成功"),
ERR_PASSWORD (1, "密码错误"),
ERR_USERNOTFOUND (2, "用户不存在"),
ERR_PASSWORDMORE (3, "连续密码错误达上限,再次输入错误将锁定用户"),
ERR_USERLOCK (4, "密码错误达上限,用户被锁定"),
ERR_ACCOUNT (5, "用户账户异常"),
ERR_USEREXIST (6, "该用户已经存在"),
ERR_PASSWORDSIMPLE (7, "用户密码强度不符合要求"),
ERR_INPUTFORMAT (8, "输入信息格式有误"),
ERR_INPUTMISS (9, "缺少必要输入信息"),
ERR_PERMISSION (10, "操作员权限不足"),
ERR_REQTIMEOUT (11, "请求超时"),
ERR_PARAMS (12, "参数错误"),
ERR_EXCEPTION (13, "系统异常"),
ERR_UNKNOWNCMD (14, "未知命令"),
ERR_LOGOUT (15, "用户未登录"),
ERR_TOKENTIMEOUT (16, "Token超时"),
ERR_TOKENNOTFOUND (17, "非法Token"),
ERR_MISSAUTHHEAD (18, "Http 请求缺少认证头部"),
;
private int errno;
private String errMsg;
ErrorCode(int err, String msg) {
this.errno = err;
this.errMsg = msg;
}
public int getCode(){
return errno;
}
public int getHttpCode() {
if(this.errno == 0) {
return 200;
} else {
return 500 + this.errno;
}
}
public String getMsg() {
return errMsg;
}
}
} }

View File

@ -0,0 +1,53 @@
package com.cmcc.hy.phoenix.common;
/**
* @brief 错误码常量定义
*/
public enum ErrorCode {
ERR_OK (0, "成功"),
ERR_PASSWORD (1, "密码错误"),
ERR_USERNOTFOUND (2, "用户不存在"),
ERR_PASSWORDMORE (3, "连续密码错误达上限,再次输入错误将锁定用户"),
ERR_USERLOCK (4, "密码错误达上限,用户被锁定"),
ERR_ACCOUNT (5, "用户账户异常"),
ERR_USEREXIST (6, "该用户已经存在"),
ERR_PASSWORDSIMPLE (7, "用户密码强度不符合要求"),
ERR_INPUTFORMAT (8, "输入信息格式有误"),
ERR_INPUTMISS (9, "缺少必要输入信息"),
ERR_PERMISSION (10, "操作员权限不足"),
ERR_REQTIMEOUT (11, "请求超时"),
ERR_PARAMS (12, "参数错误"),
ERR_EXCEPTION (13, "系统异常"),
ERR_UNKNOWNCMD (14, "未知命令"),
ERR_LOGOUT (15, "用户未登录"),
ERR_TOKENTIMEOUT (16, "Token超时"),
ERR_TOKENNOTFOUND (17, "非法Token"),
ERR_MISSAUTHHEAD (18, "Http 请求缺少认证头部"),
ERR_NOSUCHDEVICE (19, "没有这个设备"),
ERR_DEVICEEXISTS (20, "设备已经存在"),
;
private int errno;
private String errMsg;
ErrorCode(int err, String msg) {
this.errno = err;
this.errMsg = msg;
}
public int getCode(){
return errno;
}
public int getHttpCode() {
if(this.errno == 0) {
return 200;
} else {
return 500 + this.errno;
}
}
public String getMsg() {
return errMsg;
}
}

View File

@ -1,6 +1,6 @@
package com.cmcc.hy.phoenix.config; package com.cmcc.hy.phoenix.config;
import com.cmcc.hy.phoenix.pojo.po.UserAccountCache; import com.cmcc.hy.phoenix.service.DisposeDeviceManager;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -10,14 +10,16 @@ import javax.annotation.Resource;
@Component @Component
@Slf4j @Slf4j
public class SetupInit implements CommandLineRunner { public class SetupInit implements CommandLineRunner {
@Resource
private DisposeDeviceManager disposeDevMgr;
//@Resource
//private UserAccountCache userAccount;
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
// TODO Auto-generated method stub // TODO Auto-generated method stub
log.info("System Setup................................................"); log.info("System Setup................................................");
//fileLoadService.mailFileRefresh(); //fileLoadService.mailFileRefresh();
disposeDevMgr.loadDisposeFromDB();
} }
} }

View File

@ -1,11 +1,9 @@
package com.cmcc.hy.phoenix.controller; package com.cmcc.hy.phoenix.controller;
import cn.hutool.core.convert.Convert;
import com.cmcc.hy.phoenix.annotation.bodyencdec.ReqDec; import com.cmcc.hy.phoenix.annotation.bodyencdec.ReqDec;
import com.cmcc.hy.phoenix.common.ConstValue; import com.cmcc.hy.phoenix.common.ConstValue;
import com.cmcc.hy.phoenix.mapper.UserAccountMapper; import com.cmcc.hy.phoenix.common.ErrorCode;
import com.cmcc.hy.phoenix.pojo.dto.ProtocolDTO; import com.cmcc.hy.phoenix.pojo.dto.ProtocolDTO;
import com.cmcc.hy.phoenix.pojo.entity.UserAccount;
import com.cmcc.hy.phoenix.pojo.vo.*; import com.cmcc.hy.phoenix.pojo.vo.*;
import com.cmcc.hy.phoenix.service.LoginService; import com.cmcc.hy.phoenix.service.LoginService;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
@ -14,21 +12,15 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.Builder; import lombok.Builder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Hex;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.MissingRequestHeaderException;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.*; import java.util.*;
import static com.sun.corba.se.impl.util.RepositoryId.cache;
@Controller @Controller
@RequestMapping(value = "/handle") @RequestMapping(value = "/handle")
@Slf4j @Slf4j
@ -49,25 +41,25 @@ public class AuthController {
public ProtocolResp UserLogin(@RequestBody(required = true) ProtocolDTO mr, public ProtocolResp UserLogin(@RequestBody(required = true) ProtocolDTO mr,
@RequestHeader HttpHeaders headers) { @RequestHeader HttpHeaders headers) {
String msgCtx = ""; String msgCtx = "";
ConstValue.ErrorCode err = ConstValue.ErrorCode.ERR_OK; ErrorCode err = ErrorCode.ERR_OK;
log.info("请求token: {}", headers.get("Authorization")); log.info("请求token: {}", headers.get("Authorization"));
log.info("请求参数 {}", mr); log.info("请求参数 {}", mr);
if(mr == null) { if(mr == null) {
err = ConstValue.ErrorCode.ERR_PARAMS; err = ErrorCode.ERR_PARAMS;
return ProtocolResp.result(err, -1, msgCtx); return ProtocolResp.result(err, -1, msgCtx);
} else if (mr.IsRequestTimeout()) { } else if (mr.IsRequestTimeout()) {
err = ConstValue.ErrorCode.ERR_REQTIMEOUT; err = ErrorCode.ERR_REQTIMEOUT;
} else { } else {
try { try {
if(mr.getCmdId() == ConstValue.ProtocolCmdId.AUTH_LOGIN) { if(mr.getCmdId() == ConstValue.ProtocolCmdId.AUTH_LOGIN) {
EnumMap<ConstValue.ErrorCode, String> loginMap = userLogin(mr); EnumMap<ErrorCode, String> loginMap = userLogin(mr);
err = loginMap.keySet().iterator().next(); err = loginMap.keySet().iterator().next();
msgCtx = loginMap.get(err); msgCtx = loginMap.get(err);
} else if (mr.getCmdId() == ConstValue.ProtocolCmdId.AUTH_LOGOUT) { } else if (mr.getCmdId() == ConstValue.ProtocolCmdId.AUTH_LOGOUT) {
if(headers.get("Authorization") == null) { if(headers.get("Authorization") == null) {
err = ConstValue.ErrorCode.ERR_MISSAUTHHEAD; err = ErrorCode.ERR_MISSAUTHHEAD;
} else { } else {
String token = Objects. String token = Objects.
requireNonNull(headers.get("Authorization")) requireNonNull(headers.get("Authorization"))
@ -75,28 +67,28 @@ public class AuthController {
err = loginService.authTokenCheck(token); err = loginService.authTokenCheck(token);
if(err == ConstValue.ErrorCode.ERR_OK) { if(err == ErrorCode.ERR_OK) {
EnumMap<ConstValue.ErrorCode, String> loginMap = userLogout(mr, token); EnumMap<ErrorCode, String> loginMap = userLogout(mr, token);
err = loginMap.keySet().iterator().next(); err = loginMap.keySet().iterator().next();
msgCtx = loginMap.get(err); msgCtx = loginMap.get(err);
} }
} }
}else { }else {
err = ConstValue.ErrorCode.ERR_UNKNOWNCMD; err = ErrorCode.ERR_UNKNOWNCMD;
} }
} catch (JsonProcessingException | NoSuchAlgorithmException ex) { } catch (JsonProcessingException | NoSuchAlgorithmException ex) {
log.error(ex.getMessage()); log.error(ex.getMessage());
err = ConstValue.ErrorCode.ERR_EXCEPTION; err = ErrorCode.ERR_EXCEPTION;
} }
} }
return ProtocolResp.result(err, mr.getCmdId(), msgCtx); return ProtocolResp.result(err, mr.getCmdId(), msgCtx);
} }
private EnumMap<ConstValue.ErrorCode, String> userLogout(ProtocolDTO mr, String token) private EnumMap<ErrorCode, String> userLogout(ProtocolDTO mr, String token)
throws JsonProcessingException { throws JsonProcessingException {
EnumMap<ConstValue.ErrorCode, String> retMap = new EnumMap<>(ConstValue.ErrorCode.class); EnumMap<ErrorCode, String> retMap = new EnumMap<>(ErrorCode.class);
ConstValue.ErrorCode err = ConstValue.ErrorCode.ERR_OK; ErrorCode err = ErrorCode.ERR_OK;
UserLogoutRsp rspInfo = UserLogoutRsp.builder() UserLogoutRsp rspInfo = UserLogoutRsp.builder()
.userName("") .userName("")
@ -116,10 +108,10 @@ public class AuthController {
return retMap; return retMap;
} }
private EnumMap<ConstValue.ErrorCode, String> userLogin(ProtocolDTO mr) private EnumMap<ErrorCode, String> userLogin(ProtocolDTO mr)
throws NoSuchAlgorithmException, JsonProcessingException { throws NoSuchAlgorithmException, JsonProcessingException {
EnumMap<ConstValue.ErrorCode, String> retMap = new EnumMap<>(ConstValue.ErrorCode.class); EnumMap<ErrorCode, String> retMap = new EnumMap<>(ErrorCode.class);
ConstValue.ErrorCode err = ConstValue.ErrorCode.ERR_OK; ErrorCode err = ErrorCode.ERR_OK;
UserLoginRsp rspInfo = UserLoginRsp.builder() UserLoginRsp rspInfo = UserLoginRsp.builder()
.userName("") .userName("")
@ -133,11 +125,11 @@ public class AuthController {
rspInfo.setUserName(reqInfo.getUserName()); rspInfo.setUserName(reqInfo.getUserName());
EnumMap<ConstValue.ErrorCode, String> logMap = loginService.loginService(reqInfo.getUserName(), EnumMap<ErrorCode, String> logMap = loginService.loginService(reqInfo.getUserName(),
reqInfo.getPassword()); reqInfo.getPassword());
if(logMap.isEmpty()) { if(logMap.isEmpty()) {
err = ConstValue.ErrorCode.ERR_USERNOTFOUND; err = ErrorCode.ERR_USERNOTFOUND;
} else { } else {
err = logMap.keySet().iterator().next(); err = logMap.keySet().iterator().next();
rspInfo.setToken(logMap.get(err)); rspInfo.setToken(logMap.get(err));

View File

@ -1,19 +1,23 @@
package com.cmcc.hy.phoenix.controller; package com.cmcc.hy.phoenix.controller;
import com.cmcc.hy.phoenix.annotation.bodyencdec.ReqDec; import com.cmcc.hy.phoenix.annotation.bodyencdec.ReqDec;
import com.cmcc.hy.phoenix.common.ConstValue; import com.cmcc.hy.phoenix.common.ErrorCode;
import com.cmcc.hy.phoenix.pojo.dto.ProtocolDTO; import com.cmcc.hy.phoenix.pojo.dto.ProtocolDTO;
import com.cmcc.hy.phoenix.pojo.vo.ProtocolResp; import com.cmcc.hy.phoenix.pojo.vo.ProtocolResp;
import com.cmcc.hy.phoenix.service.DisposeDeviceManager;
import com.cmcc.hy.phoenix.service.UserAccountCacheService; import com.cmcc.hy.phoenix.service.UserAccountCacheService;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.Builder; import lombok.Builder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -23,18 +27,36 @@ import javax.annotation.Resource;
@Api(value = "抗DDoS处置平台调试接口", tags = "抗DDoS处置平台调试接口") @Api(value = "抗DDoS处置平台调试接口", tags = "抗DDoS处置平台调试接口")
@Component @Component
public class DebugController { public class DebugController {
@Resource
private ObjectMapper objectMapper;
@Resource @Resource
private UserAccountCacheService userAccountService; private UserAccountCacheService userAccountService;
@Resource
private DisposeDeviceManager disposeDevMgr;
@GetMapping("/cacheuser") @GetMapping("/cacheuser")
@ResponseBody @ResponseBody
@ApiOperation("获取缓存用户") @ApiOperation("获取缓存用户")
@ReqDec @ReqDec
@Builder @Builder
public ProtocolResp UserLogin(@RequestBody(required = true) ProtocolDTO mr) throws JsonProcessingException { public ProtocolResp getCacheUsers(@RequestBody(required = true) ProtocolDTO mr) throws JsonProcessingException {
return ProtocolResp.result(ConstValue.ErrorCode.ERR_OK, -1, userAccountService.getCacheUser()); return ProtocolResp.result(ErrorCode.ERR_OK, -1, userAccountService.getCacheUser());
}
@GetMapping("/devs")
@ResponseBody
@ApiOperation("获取所有处置设备")
@ReqDec
@Builder
public ProtocolResp getDisposeDevs(@RequestBody(required = true) ProtocolDTO mr) throws JsonProcessingException {
return ProtocolResp.result(ErrorCode.ERR_OK,
-1,
objectMapper.writeValueAsString(disposeDevMgr.getAllDisposeDevs()));
} }
} }

View File

@ -2,7 +2,7 @@ package com.cmcc.hy.phoenix.controller;
import javax.annotation.Resource; import javax.annotation.Resource;
import com.cmcc.hy.phoenix.common.ConstValue; import com.cmcc.hy.phoenix.common.ErrorCode;
import com.cmcc.hy.phoenix.help.GitInformation; import com.cmcc.hy.phoenix.help.GitInformation;
import com.cmcc.hy.phoenix.pojo.dto.ProtocolDTO; import com.cmcc.hy.phoenix.pojo.dto.ProtocolDTO;
import com.cmcc.hy.phoenix.pojo.vo.Resp; import com.cmcc.hy.phoenix.pojo.vo.Resp;
@ -52,9 +52,9 @@ public class ProtocolController {
log.info("请求参数 {}", mr); log.info("请求参数 {}", mr);
if(mr == null) { if(mr == null) {
return ProtocolResp.result(ConstValue.ErrorCode.ERR_PARAMS); return ProtocolResp.result(ErrorCode.ERR_PARAMS);
} else if (mr.IsRequestTimeout()) { } else if (mr.IsRequestTimeout()) {
return ProtocolResp.result(ConstValue.ErrorCode.ERR_REQTIMEOUT); return ProtocolResp.result(ErrorCode.ERR_REQTIMEOUT);
} }
try { try {
@ -70,6 +70,6 @@ public class ProtocolController {
return ProtocolResp.result(Resp.SYSTEM_ERROR); return ProtocolResp.result(Resp.SYSTEM_ERROR);
} }
return ProtocolResp.result(ConstValue.ErrorCode.ERR_OK, mr.getCmdId(), msgCtx); return ProtocolResp.result(ErrorCode.ERR_OK, mr.getCmdId(), msgCtx);
} }
} }

View File

@ -4,9 +4,9 @@ import com.cmcc.hy.phoenix.common.ConstValue;
public class DeviceRouter { public class DeviceRouter {
public static DisposeProcess DeviceRouterFactory(ConstValue.DisposeDevice devType) { public static DisposeProcess deviceRouterFactory(int devType, String ipAddr) {
if(devType.equals(ConstValue.DisposeDevice.DPTECH_UMC)){ if(devType == ConstValue.DisposeDeviceType.DPTECH_UMC.getCode()){
return new DptechUMC(); return new DptechUMC(ipAddr);
} }
return null; return null;

View File

@ -1,13 +1,13 @@
package com.cmcc.hy.phoenix.dispose; package com.cmcc.hy.phoenix.dispose;
import com.fasterxml.jackson.core.JsonProcessingException;
public interface DisposeProcess { public interface DisposeProcess {
public int RunDispose(String ip); public int runDispose(String ip);
public <T> T GetDetectionObjectDevices(); public <T> T getAllDetectionObject();
public String GetDetectionDevices(); public <T> T getAllProtectionObject();
public String GetProtectDevices(); public String getDetectionDevices();
public String getProtectDevices();
} }

View File

@ -17,15 +17,20 @@ import java.util.Map;
public class DptechUMC implements DisposeProcess { public class DptechUMC implements DisposeProcess {
@Override @Override
public int RunDispose(String ip) { public int runDispose(String ip) {
return 0; return 0;
} }
@Override @Override
public <T> T GetDetectionObjectDevices() { public <T> T getAllDetectionObject() {
return (T) (cleanTypePort.getAllDetectionObjectFromUMC().getDetectionObjectDataForService()); return (T) (cleanTypePort.getAllDetectionObjectFromUMC().getDetectionObjectDataForService());
} }
@Override
public <T> T getAllProtectionObject() {
return (T) (cleanTypePort.getAllProtectionObjectFromUMC().getProtectionObjectDataForService());
}
public String GetDetectionObjectDeviceJson() throws JsonProcessingException { public String GetDetectionObjectDeviceJson() throws JsonProcessingException {
ArrayOfDetectionObjectDataForService typePort = cleanTypePort.getAllDetectionObjectFromUMC(); ArrayOfDetectionObjectDataForService typePort = cleanTypePort.getAllDetectionObjectFromUMC();
@ -34,21 +39,21 @@ public class DptechUMC implements DisposeProcess {
} }
@Override @Override
public String GetProtectDevices() { public String getProtectDevices() {
return cleanTypePort.getAllProtectDevices(); return cleanTypePort.getAllProtectDevices();
} }
@Override @Override
public String GetDetectionDevices() { public String getDetectionDevices() {
return cleanTypePort.getAllDetectDevices(); return cleanTypePort.getAllDetectDevices();
} }
AbnormalFlowCleaningServicePortType cleanTypePort; AbnormalFlowCleaningServicePortType cleanTypePort;
public DptechUMC() { public DptechUMC(String ipAddr) {
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean(); JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
jaxWsProxyFactoryBean.setServiceClass(AbnormalFlowCleaningServicePortType.class); jaxWsProxyFactoryBean.setServiceClass(AbnormalFlowCleaningServicePortType.class);
jaxWsProxyFactoryBean.setAddress(ConstValue.SOAPWrapperConst.NAMESPACE_URI); jaxWsProxyFactoryBean.setAddress(String.format(ConstValue.SOAPWrapperConst.NAMESPACE_URI, ipAddr));
//WS-Security Head //WS-Security Head
Map<String, Object> outProps = new HashMap<String, Object>(); Map<String, Object> outProps = new HashMap<String, Object>();

View File

@ -1,7 +1,6 @@
package com.cmcc.hy.phoenix.mapper; package com.cmcc.hy.phoenix.mapper;
import com.cmcc.hy.phoenix.pojo.entity.DisposeDevice; import com.cmcc.hy.phoenix.pojo.entity.DisposeDevice;
import com.cmcc.hy.phoenix.pojo.entity.User;
import tk.mybatis.mapper.common.IdsMapper; import tk.mybatis.mapper.common.IdsMapper;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper; import tk.mybatis.mapper.common.MySqlMapper;
@ -21,7 +20,11 @@ public interface DisposeDeviceMapper extends Mapper<DisposeDevice>,
*/ */
List<DisposeDevice> getAllDisposeDevice(); List<DisposeDevice> getAllDisposeDevice();
int addNewDisposeDevice(DisposeDevice dev); DisposeDevice getDisposeDisposeDevByIp(String ipv4);
int updateDisposeDeviceById(); void addNewDisposeDevice(DisposeDevice dev);
void updateDisposeDeviceByIp(String ipv4);
void removeDisposeDevice(String ipAddr);
} }

View File

@ -45,4 +45,13 @@ public class DeviceCapacity implements Serializable {
* 处置设备储备能力(MB) * 处置设备储备能力(MB)
*/ */
private Integer tolFlowCapacity; private Integer tolFlowCapacity;
public DeviceCapacity(Integer capacity, Integer tolFlowCapacity) {
this.capacity = capacity;
this.tolFlowCapacity = tolFlowCapacity;
}
public DeviceCapacity(Integer capacity) {
this.capacity = capacity;
}
} }

View File

@ -33,7 +33,7 @@ public class DisposeDevice implements Serializable {
* 设备唯一标识符 * 设备唯一标识符
*/ */
@Id @Id
@KeySql(useGeneratedKeys = true) //@KeySql(useGeneratedKeys = true)
private Long id; private Long id;
/** /**

View File

@ -1,6 +1,7 @@
package com.cmcc.hy.phoenix.pojo.vo; package com.cmcc.hy.phoenix.pojo.vo;
import com.cmcc.hy.phoenix.common.ConstValue; import com.cmcc.hy.phoenix.common.ConstValue;
import com.cmcc.hy.phoenix.common.ErrorCode;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
@ -51,7 +52,7 @@ public class ProtocolResp {
return ProtocolResp.builder().code(resp.getCode()).msgContent(resp.getMsg()).build(); return ProtocolResp.builder().code(resp.getCode()).msgContent(resp.getMsg()).build();
} }
public static ProtocolResp result(ConstValue.ErrorCode err) { public static ProtocolResp result(ErrorCode err) {
return ProtocolResp.builder() return ProtocolResp.builder()
.ver(ConstValue.Protocol.VERSION) .ver(ConstValue.Protocol.VERSION)
.cryptoType(ConstValue.Protocol.CRYPTO_NONE) .cryptoType(ConstValue.Protocol.CRYPTO_NONE)
@ -60,11 +61,11 @@ public class ProtocolResp {
.msgContent(err.getMsg()).build(); .msgContent(err.getMsg()).build();
} }
public static ProtocolResp result(ConstValue.ErrorCode err, Integer cmdId, String respMsg) { public static ProtocolResp result(ErrorCode err, Integer cmdId, String respMsg) {
return result(err, cmdId, respMsg, ConstValue.Protocol.CRYPTO_NONE); return result(err, cmdId, respMsg, ConstValue.Protocol.CRYPTO_NONE);
} }
public static ProtocolResp result(ConstValue.ErrorCode err, Integer cmdId, String respMsg, Integer crypto) { public static ProtocolResp result(ErrorCode err, Integer cmdId, String respMsg, Integer crypto) {
return ProtocolResp.builder() return ProtocolResp.builder()
.cmdId(cmdId + ConstValue.Protocol.RESP_CMD_BASE) .cmdId(cmdId + ConstValue.Protocol.RESP_CMD_BASE)

View File

@ -0,0 +1,15 @@
package com.cmcc.hy.phoenix.service;
import com.cmcc.hy.phoenix.common.ErrorCode;
import com.cmcc.hy.phoenix.pojo.entity.DisposeDevice;
import java.util.EnumMap;
import java.util.Map;
public interface DisposeDeviceManager {
void loadDisposeFromDB();
EnumMap<ErrorCode, Long> addNewDisposeDevice(DisposeDevice dev);
Map<String, DisposeDevice> getAllDisposeDevs();
}

View File

@ -0,0 +1,4 @@
package com.cmcc.hy.phoenix.service;
public interface DisposeService {
}

View File

@ -1,12 +1,12 @@
package com.cmcc.hy.phoenix.service; package com.cmcc.hy.phoenix.service;
import com.cmcc.hy.phoenix.common.ConstValue; import com.cmcc.hy.phoenix.common.ErrorCode;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.EnumMap; import java.util.EnumMap;
public interface LoginService { public interface LoginService {
public EnumMap<ConstValue.ErrorCode, String> loginService(String username, String password) throws NoSuchAlgorithmException; public EnumMap<ErrorCode, String> loginService(String username, String password) throws NoSuchAlgorithmException;
public ConstValue.ErrorCode logoutService(String username, String token); public ErrorCode logoutService(String username, String token);
ConstValue.ErrorCode authTokenCheck(String token); ErrorCode authTokenCheck(String token);
} }

View File

@ -1,6 +1,6 @@
package com.cmcc.hy.phoenix.service; package com.cmcc.hy.phoenix.service;
import com.cmcc.hy.phoenix.common.ConstValue; import com.cmcc.hy.phoenix.common.ErrorCode;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@ -10,8 +10,8 @@ public interface UserAccountCacheService {
int getUsrPwdErrTimes(String username); int getUsrPwdErrTimes(String username);
void setUserPwdErrTimes(String username, Integer errTimes); void setUserPwdErrTimes(String username, Integer errTimes);
void cleanUserToken(String username); void cleanUserToken(String username);
ConstValue.ErrorCode verifyUserLogin(String username, String token); ErrorCode verifyUserLogin(String username, String token);
ConstValue.ErrorCode verifyToken(String token); ErrorCode verifyToken(String token);
String getCacheUser() throws JsonProcessingException; String getCacheUser() throws JsonProcessingException;
} }

View File

@ -0,0 +1,128 @@
package com.cmcc.hy.phoenix.service.impl;
import com.cmcc.hy.phoenix.common.ErrorCode;
import com.cmcc.hy.phoenix.dispose.DeviceRouter;
import com.cmcc.hy.phoenix.dispose.DisposeProcess;
import com.cmcc.hy.phoenix.mapper.DisposeDeviceMapper;
import com.cmcc.hy.phoenix.pojo.entity.DisposeDevice;
import com.cmcc.hy.phoenix.service.DisposeDeviceManager;
import com.dptech.umc.DetectionObjectDataForService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
@Service
@Slf4j
public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
@Resource
private ObjectMapper objectMapper;
@Resource
private DataSourceTransactionManager dataSourceTransactionManager;
@Resource
private TransactionDefinition transactionDefinition;
@Resource
private DisposeDeviceMapper disposeDeviceMapper;
private final ConcurrentHashMap<String, DisposeDevice> disposeDevMap = new ConcurrentHashMap<>();
@Override
public EnumMap<ErrorCode, Long> addNewDisposeDevice(DisposeDevice dev) {
TransactionStatus transactionStatus = null;
EnumMap<ErrorCode, Long> retMap = new EnumMap<>(ErrorCode.class);
if(isDisposeDeviceExists(dev.getIpv4())){
retMap.put(ErrorCode.ERR_DEVICEEXISTS, -1L);
return retMap;
}
List<String> disposeIp = getDisposeIpFromDevice(dev.getType(), dev.getIpv4());
if(disposeIp == null) {
retMap.put(ErrorCode.ERR_NOSUCHDEVICE, -1L);
return retMap;
}
if(dev.getDisposeIp() == null) {
dev.setDisposeIp(disposeIp);
} else {
dev.getDisposeIp().addAll(disposeIp);
}
try {
transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
disposeDeviceMapper.addNewDisposeDevice(dev);
dataSourceTransactionManager.commit(transactionStatus);
retMap.put(ErrorCode.ERR_OK, dev.getId());
addDisposeDeviceToCache(dev);
} catch (Exception ex) {
assert transactionStatus != null;
dataSourceTransactionManager.rollback(transactionStatus);
retMap.put(ErrorCode.ERR_EXCEPTION, -1L);
}
return retMap;
}
@Override
public void loadDisposeFromDB() {
List<DisposeDevice> dp = disposeDeviceMapper.getAllDisposeDevice();
dp.forEach(v -> {
disposeDevMap.put(v.getIpv4(), v);
});
}
@Override
public Map<String, DisposeDevice> getAllDisposeDevs() {
return disposeDevMap;
}
private Boolean isDisposeDeviceExists(String ipv4) {
return disposeDevMap.containsKey(ipv4);
}
private void addDisposeDeviceToCache(DisposeDevice dev) {
disposeDevMap.put(dev.getIpv4(), dev);
}
private List<String> getDisposeIpFromDevice(int devType, String ipAddr) {
DisposeProcess dptechUMC = DeviceRouter.deviceRouterFactory(devType, ipAddr);
if(dptechUMC == null) {
return null;
}
try {
List<DetectionObjectDataForService> detDevs = dptechUMC.getAllDetectionObject();
List<String> ipList = new ArrayList<>();
detDevs.forEach(v -> {
String ipSegment = v.getIpSegment().getValue();
if(ipSegment.length() > 0) {
log.info("Ip: {}", v.getIpSegment().getValue());
ipList.addAll(Arrays.asList(v.getIpSegment().getValue().split(",")));
}
});
return ipList;
} catch(Exception ex) {
return null;
}
}
}

View File

@ -1,6 +1,7 @@
package com.cmcc.hy.phoenix.service.impl; package com.cmcc.hy.phoenix.service.impl;
import com.cmcc.hy.phoenix.common.ConstValue; import com.cmcc.hy.phoenix.common.ConstValue;
import com.cmcc.hy.phoenix.common.ErrorCode;
import com.cmcc.hy.phoenix.mapper.UserAccountMapper; import com.cmcc.hy.phoenix.mapper.UserAccountMapper;
import com.cmcc.hy.phoenix.pojo.entity.UserAccount; import com.cmcc.hy.phoenix.pojo.entity.UserAccount;
import com.cmcc.hy.phoenix.service.LoginService; import com.cmcc.hy.phoenix.service.LoginService;
@ -11,7 +12,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List;
@Service @Service
@Slf4j @Slf4j
@ -23,13 +23,13 @@ public class LoginServiceImpl implements LoginService {
private UserAccountMapper userAccountMapper; private UserAccountMapper userAccountMapper;
@Override @Override
public ConstValue.ErrorCode authTokenCheck(String token) { public ErrorCode authTokenCheck(String token) {
return userAccountService.verifyToken(token); return userAccountService.verifyToken(token);
} }
@Override @Override
public EnumMap<ConstValue.ErrorCode, String> loginService(String username, String password) throws NoSuchAlgorithmException { public EnumMap<ErrorCode, String> loginService(String username, String password) throws NoSuchAlgorithmException {
EnumMap<ConstValue.ErrorCode, String> retMap = new EnumMap<>(ConstValue.ErrorCode.class); EnumMap<ErrorCode, String> retMap = new EnumMap<>(ErrorCode.class);
// Example exp = new Example(UserAccount.class); // Example exp = new Example(UserAccount.class);
// exp.createCriteria().andEqualTo("username", username); // exp.createCriteria().andEqualTo("username", username);
@ -38,10 +38,10 @@ public class LoginServiceImpl implements LoginService {
// 用户为空 // 用户为空
if(loginUser == null) { if(loginUser == null) {
retMap.put(ConstValue.ErrorCode.ERR_USERNOTFOUND, ""); retMap.put(ErrorCode.ERR_USERNOTFOUND, "");
} else { } else {
if(loginUser.getStatus() == ConstValue.UserAccountStatus.LOCKED) { if(loginUser.getStatus() == ConstValue.UserAccountStatus.LOCKED) {
retMap.put(ConstValue.ErrorCode.ERR_USERLOCK, ""); retMap.put(ErrorCode.ERR_USERLOCK, "");
} else if(!loginUser.getPassword().equals(password)) { } else if(!loginUser.getPassword().equals(password)) {
// 密码错误 // 密码错误
int errTimes = userAccountService.getUsrPwdErrTimes(username) + 1; int errTimes = userAccountService.getUsrPwdErrTimes(username) + 1;
@ -51,16 +51,16 @@ public class LoginServiceImpl implements LoginService {
if(errTimes == ConstValue.GlobalConfigure.ALLOW_PWD_ERR_TIMES - 1) { if(errTimes == ConstValue.GlobalConfigure.ALLOW_PWD_ERR_TIMES - 1) {
// 提示用户即将锁定账户 // 提示用户即将锁定账户
retMap.put(ConstValue.ErrorCode.ERR_PASSWORDMORE, ""); retMap.put(ErrorCode.ERR_PASSWORDMORE, "");
} else if(errTimes >= ConstValue.GlobalConfigure.ALLOW_PWD_ERR_TIMES) { } else if(errTimes >= ConstValue.GlobalConfigure.ALLOW_PWD_ERR_TIMES) {
// 锁定账户 // 锁定账户
retMap.put(ConstValue.ErrorCode.ERR_USERLOCK, ""); retMap.put(ErrorCode.ERR_USERLOCK, "");
userAccountMapper.lockUserAccount(username); userAccountMapper.lockUserAccount(username);
} else { } else {
retMap.put(ConstValue.ErrorCode.ERR_PASSWORD, ""); retMap.put(ErrorCode.ERR_PASSWORD, "");
} }
} else { } else {
retMap.put(ConstValue.ErrorCode.ERR_OK, userAccountService.getUserToken(username)); retMap.put(ErrorCode.ERR_OK, userAccountService.getUserToken(username));
userAccountService.setUserPwdErrTimes(username, 0); userAccountService.setUserPwdErrTimes(username, 0);
} }
} }
@ -69,19 +69,19 @@ public class LoginServiceImpl implements LoginService {
} }
@Override @Override
public ConstValue.ErrorCode logoutService(String username, String token) { public ErrorCode logoutService(String username, String token) {
ConstValue.ErrorCode err = ConstValue.ErrorCode.ERR_OK; ErrorCode err = ErrorCode.ERR_OK;
UserAccount loginUser = userAccountMapper.getUserByName(username); UserAccount loginUser = userAccountMapper.getUserByName(username);
// 用户为空 // 用户为空
if(loginUser == null) { if(loginUser == null) {
err = ConstValue.ErrorCode.ERR_USERNOTFOUND; err = ErrorCode.ERR_USERNOTFOUND;
} else { } else {
err = userAccountService.verifyUserLogin(username, token); err = userAccountService.verifyUserLogin(username, token);
if(err == ConstValue.ErrorCode.ERR_OK) { if(err == ErrorCode.ERR_OK) {
userAccountService.cleanUserToken(username); userAccountService.cleanUserToken(username);
} }
} }

View File

@ -2,6 +2,7 @@ package com.cmcc.hy.phoenix.service.impl;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import com.cmcc.hy.phoenix.common.ConstValue; import com.cmcc.hy.phoenix.common.ConstValue;
import com.cmcc.hy.phoenix.common.ErrorCode;
import com.cmcc.hy.phoenix.pojo.po.UserAccountCache; import com.cmcc.hy.phoenix.pojo.po.UserAccountCache;
import com.cmcc.hy.phoenix.service.UserAccountCacheService; import com.cmcc.hy.phoenix.service.UserAccountCacheService;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
@ -16,7 +17,6 @@ import java.security.NoSuchAlgorithmException;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
@ -28,50 +28,50 @@ public class UserAccountCacheServiceImpl implements UserAccountCacheService {
private ConcurrentHashMap<String, UserAccountCache> userAccountMap = new ConcurrentHashMap<>(); private ConcurrentHashMap<String, UserAccountCache> userAccountMap = new ConcurrentHashMap<>();
@Override @Override
public ConstValue.ErrorCode verifyToken(String token) { public ErrorCode verifyToken(String token) {
//userAccountMap //userAccountMap
if(!userAccountMap.containsKey(token)){ if(!userAccountMap.containsKey(token)){
return ConstValue.ErrorCode.ERR_LOGOUT; return ErrorCode.ERR_LOGOUT;
} else { } else {
UserAccountCache uc = userAccountMap.get(token); UserAccountCache uc = userAccountMap.get(token);
if((System.currentTimeMillis() - uc.getLastAccess()) if((System.currentTimeMillis() - uc.getLastAccess())
>= ConstValue.GlobalConfigure.TOKEN_TIMEOUT_MS) { >= ConstValue.GlobalConfigure.TOKEN_TIMEOUT_MS) {
return ConstValue.ErrorCode.ERR_TOKENTIMEOUT; return ErrorCode.ERR_TOKENTIMEOUT;
} }
return ConstValue.ErrorCode.ERR_OK; return ErrorCode.ERR_OK;
} }
} }
@Override @Override
public ConstValue.ErrorCode verifyUserLogin(String username, String token) { public ErrorCode verifyUserLogin(String username, String token) {
Optional<UserAccountCache> findRet = userAccountMap.values().stream() Optional<UserAccountCache> findRet = userAccountMap.values().stream()
.filter(userAccountCache -> username.equals(userAccountCache.getUsername())) .filter(userAccountCache -> username.equals(userAccountCache.getUsername()))
.findFirst(); .findFirst();
if(!findRet.isPresent()) { if(!findRet.isPresent()) {
return ConstValue.ErrorCode.ERR_USERNOTFOUND; return ErrorCode.ERR_USERNOTFOUND;
} }
UserAccountCache uc = findRet.get(); UserAccountCache uc = findRet.get();
if(uc.getToken().length() == 0) { if(uc.getToken().length() == 0) {
return ConstValue.ErrorCode.ERR_LOGOUT; return ErrorCode.ERR_LOGOUT;
} }
if((System.currentTimeMillis() - uc.getLastAccess()) if((System.currentTimeMillis() - uc.getLastAccess())
>= ConstValue.GlobalConfigure.TOKEN_TIMEOUT_MS) >= ConstValue.GlobalConfigure.TOKEN_TIMEOUT_MS)
{ {
return ConstValue.ErrorCode.ERR_TOKENTIMEOUT; return ErrorCode.ERR_TOKENTIMEOUT;
} }
if(!uc.getToken().equals(token)) { if(!uc.getToken().equals(token)) {
return ConstValue.ErrorCode.ERR_TOKENNOTFOUND; return ErrorCode.ERR_TOKENNOTFOUND;
} }
return ConstValue.ErrorCode.ERR_OK; return ErrorCode.ERR_OK;
} }
@Override @Override

View File

@ -43,4 +43,57 @@
ON ON
d.id = c.deviceId d.id = c.deviceId
</select> </select>
<select id="getDisposeDisposeDevByIp" resultMap="getAllDisposeDevicesMap">
SELECT
d.id,
d.ipv4,
d.ipv6,
d.type,
d.areaCode,
d.name,
d.manufacturer,
d.model,
d.version,
d.readme,
c.id AS c_id,
c.deviceId AS c_deviceId,
c.capacity AS c_capacity,
c.tolFlowCapacity AS c_tolFlowCapacity
FROM
dispose_device d
LEFT JOIN
device_capacity c
ON
d.id = c.deviceId
WHERE
d.ipv4 = #{ipv4}
</select>
<insert id="addNewDisposeDevice" useGeneratedKeys="true" keyProperty="id" parameterType="com.cmcc.hy.phoenix.pojo.entity.DisposeDevice">
INSERT INTO
dispose_device(ipv4, ipv6, type,
areaCode, name, manufacturer,
model, version, readme)
VALUES
(#{ipv4}, #{ipv6}, #{type},
#{areaCode}, #{name}, #{manufacturer},
#{model}, #{version}, #{readme});
INSERT INTO
device_capacity(deviceId, capacity, tolFlowCapacity)
VALUES
<foreach collection="devCaps" item="devCaps" separator=",">
(last_insert_id(), #{devCaps.capacity}, #{devCaps.tolFlowCapacity})
</foreach>
</insert>
<delete id="removeDisposeDevice" parameterType="java.lang.String">
DELETE
dispose_device
FROM
dispose_device
WHERE
dispose_device.ipv4 = #{ipAddr}
</delete>
</mapper> </mapper>

View File

@ -14,14 +14,14 @@ public class DPTechInterfaceTestCase {
public void getAllDetectionObjectFromUMC(){ public void getAllDetectionObjectFromUMC(){
try { try {
DisposeProcess dp = DeviceRouter.DeviceRouterFactory(ConstValue.DisposeDevice.DPTECH_UMC); DisposeProcess dp = DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15");
List<DetectionObjectDataForService> detDevs = dp.GetDetectionObjectDevices(); List<DetectionObjectDataForService> detDevs = dp.getAllDetectionObject();
Assert.assertNotEquals(detDevs.size(), 0); Assert.assertNotEquals(detDevs.size(), 0);
} catch (Exception ex){ } catch (Exception ex){
Assert.assertTrue(false); Assert.fail();
} }
} }
@ -29,14 +29,14 @@ public class DPTechInterfaceTestCase {
public void getAllProtectDevices(){ public void getAllProtectDevices(){
try { try {
DisposeProcess dp = DeviceRouter.DeviceRouterFactory(ConstValue.DisposeDevice.DPTECH_UMC); DisposeProcess dp = DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15");
String proDevs = dp.GetProtectDevices(); String proDevs = dp.getProtectDevices();
Assert.assertNotEquals(proDevs.length(), 0); Assert.assertNotEquals(proDevs.length(), 0);
} catch (Exception ex){ } catch (Exception ex){
Assert.assertTrue(false); Assert.fail();
} }
} }
@ -44,14 +44,14 @@ public class DPTechInterfaceTestCase {
public void getAllDetectDevices(){ public void getAllDetectDevices(){
try { try {
DisposeProcess dp = DeviceRouter.DeviceRouterFactory(ConstValue.DisposeDevice.DPTECH_UMC); DisposeProcess dp = DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15");
String detDevs = dp.GetDetectionDevices(); String detDevs = dp.getDetectionDevices();
Assert.assertNotEquals(detDevs.length(), 0); Assert.assertNotEquals(detDevs.length(), 0);
} catch (Exception ex){ } catch (Exception ex){
Assert.assertTrue(false); Assert.fail();
} }
} }
} }

View File

@ -1,5 +1,7 @@
package com.cmcc.hy.phoenix.mapper; package com.cmcc.hy.phoenix.mapper;
import com.cmcc.hy.phoenix.common.ConstValue;
import com.cmcc.hy.phoenix.pojo.entity.DeviceCapacity;
import com.cmcc.hy.phoenix.pojo.entity.DisposeDevice; import com.cmcc.hy.phoenix.pojo.entity.DisposeDevice;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@ -10,12 +12,15 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.*;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
@EnableTransactionManagement
@Slf4j @Slf4j
public class DisposeDeviceMapperTest { public class DisposeDeviceMapperTest {
@ -32,7 +37,7 @@ public class DisposeDeviceMapperTest {
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dp)); log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dp));
Assert.assertEquals(dp.size(), 1); Assert.assertNotEquals(dp.size(), 0);
} }
@Test @Test
@ -41,8 +46,55 @@ public class DisposeDeviceMapperTest {
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dp)); log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dp));
Assert.assertEquals(dp.size(), 1); Assert.assertNotEquals(dp.size(), 0);
} }
@Test
public void getDisposeDisposeDevByIp() throws JsonProcessingException {
DisposeDevice dev = disposeDeviceMapper.getDisposeDisposeDevByIp("10.88.77.15");
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dev));
Assert.assertNotNull(dev);
}
@Test
@Transactional
public void addNewDisposeDevice() throws JsonProcessingException {
Long devId = -1L;
DisposeDevice dev = new DisposeDevice();
List<DeviceCapacity> devCaps = new ArrayList<>();
dev.setId(devId);
dev.setIpv4("192.168.88.1");
dev.setType(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode());
dev.setName("默认路由器");
dev.setManufacturer("MERCURY");
dev.setModel("MV305R");
dev.setVersion("1.0.120");
dev.setReadme("数据库测试垃圾数据");
dev.setAreaCode(0);
dev.setDevCaps(devCaps);
devCaps.add(new DeviceCapacity(0, 2048));
devCaps.add(new DeviceCapacity(2));
disposeDeviceMapper.addNewDisposeDevice(dev);
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dev));
Assert.assertNotEquals(devId, dev.getId());
}
@Test
public void removeDisposeDevice() throws JsonProcessingException {
String ipAddr = "192.168.30.6";
disposeDeviceMapper.removeDisposeDevice(ipAddr);
List<DisposeDevice> dp = disposeDeviceMapper.selectAll();
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dp));
dp.forEach(v->{
if(v.getIpv4().equals(ipAddr)) {
Assert.fail();
}
});
}
} }

View File

@ -0,0 +1,64 @@
package com.cmcc.hy.phoenix.service;
import com.cmcc.hy.phoenix.common.ConstValue;
import com.cmcc.hy.phoenix.common.ErrorCode;
import com.cmcc.hy.phoenix.pojo.entity.DeviceCapacity;
import com.cmcc.hy.phoenix.pojo.entity.DisposeDevice;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
@EnableTransactionManagement
@Slf4j
public class DisposeServiceTest {
@Autowired
private ObjectMapper objMapper;
@Resource
private DisposeDeviceManager dispDevMgr;
@Test
public void addNewDisposeDevice() throws JsonProcessingException {
Long devId = -1L;
DisposeDevice dev = new DisposeDevice();
List<DeviceCapacity> devCaps = new ArrayList<>();
dev.setId(devId);
dev.setIpv4("192.168.88.1");
dev.setType(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode());
dev.setName("默认路由器");
dev.setManufacturer("MERCURY");
dev.setModel("MV305R");
dev.setVersion("1.0.120");
dev.setReadme("数据库测试垃圾数据");
dev.setAreaCode(0);
dev.setDevCaps(devCaps);
devCaps.add(new DeviceCapacity(0, 2048));
devCaps.add(new DeviceCapacity(2));
EnumMap<ErrorCode, Long> retMap = dispDevMgr.addNewDisposeDevice(dev);
ErrorCode err = retMap.keySet().iterator().next();
Assert.assertEquals(ErrorCode.ERR_OK, err);
Assert.assertNotEquals(devId, dev.getId());
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dev));
}
}