修改目录结构
redstar-lab 实验性工程 redstar-cloud 红星微服务云版本 redstar-standlone 红星微服务单体版本
This commit is contained in:
parent
dac16cdfd8
commit
5f9ccfff47
|
|
@ -1,38 +0,0 @@
|
|||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# eclipse
|
||||
workspace
|
||||
|
||||
/redstar-doc/redstar-web-doc/node_modules
|
||||
/redstar-doc/redstar-java-doc/node_modules
|
||||
redstar-api/.project
|
||||
redstar-api/.settings/org.eclipse.core.resources.prefs
|
||||
redstar-api/.settings/org.eclipse.jdt.core.prefs
|
||||
redstar-api/.settings/org.eclipse.m2e.core.prefs
|
||||
redstar-api/.classpath
|
||||
.gitignore
|
||||
redstar-api/.gitignore
|
||||
.gitignore
|
||||
208
LICENSE
208
LICENSE
|
|
@ -1,208 +0,0 @@
|
|||
Apache License
|
||||
|
||||
Version 2.0, January 2004
|
||||
|
||||
http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION,
|
||||
AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution
|
||||
as defined by Sections 1 through 9 of this document.
|
||||
|
||||
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||
owner that is granting the License.
|
||||
|
||||
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||
that control, are controlled by, or are under common control with that entity.
|
||||
For the purposes of this definition, "control" means (i) the power, direct
|
||||
or indirect, to cause the direction or management of such entity, whether
|
||||
by contract or otherwise, or (ii) ownership of fifty percent (50%) or more
|
||||
of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions
|
||||
granted by this License.
|
||||
|
||||
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including
|
||||
but not limited to software source code, documentation source, and configuration
|
||||
files.
|
||||
|
||||
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation
|
||||
or translation of a Source form, including but not limited to compiled object
|
||||
code, generated documentation, and conversions to other media types.
|
||||
|
||||
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form,
|
||||
made available under the License, as indicated by a copyright notice that
|
||||
is included in or attached to the work (an example is provided in the Appendix
|
||||
below).
|
||||
|
||||
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form,
|
||||
that is based on (or derived from) the Work and for which the editorial revisions,
|
||||
annotations, elaborations, or other modifications represent, as a whole, an
|
||||
original work of authorship. For the purposes of this License, Derivative
|
||||
Works shall not include works that remain separable from, or merely link (or
|
||||
bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version
|
||||
of the Work and any modifications or additions to that Work or Derivative
|
||||
Works thereof, that is intentionally submitted to Licensor for inclusion in
|
||||
the Work by the copyright owner or by an individual or Legal Entity authorized
|
||||
to submit on behalf of the copyright owner. For the purposes of this definition,
|
||||
"submitted" means any form of electronic, verbal, or written communication
|
||||
sent to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor
|
||||
for the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as "Not a Contribution."
|
||||
|
||||
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently incorporated
|
||||
within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this
|
||||
License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable copyright license to reproduce, prepare
|
||||
Derivative Works of, publicly display, publicly perform, sublicense, and distribute
|
||||
the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
||||
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
||||
license to make, have made, use, offer to sell, sell, import, and otherwise
|
||||
transfer the Work, where such license applies only to those patent claims
|
||||
licensable by such Contributor that are necessarily infringed by their Contribution(s)
|
||||
alone or by combination of their Contribution(s) with the Work to which such
|
||||
Contribution(s) was submitted. If You institute patent litigation against
|
||||
any entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||
that the Work or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses granted to You
|
||||
under this License for that Work shall terminate as of the date such litigation
|
||||
is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or
|
||||
Derivative Works thereof in any medium, with or without modifications, and
|
||||
in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy
|
||||
of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that
|
||||
You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source
|
||||
form of the Work, excluding those notices that do not pertain to any part
|
||||
of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
||||
then any Derivative Works that You distribute must include a readable copy
|
||||
of the attribution notices contained within such NOTICE file, excluding those
|
||||
notices that do not pertain to any part of the Derivative Works, in at least
|
||||
one of the following places: within a NOTICE text file distributed as part
|
||||
of the Derivative Works; within the Source form or documentation, if provided
|
||||
along with the Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and do not modify the
|
||||
License. You may add Your own attribution notices within Derivative Works
|
||||
that You distribute, alongside or as an addendum to the NOTICE text from the
|
||||
Work, provided that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide
|
||||
additional or different license terms and conditions for use, reproduction,
|
||||
or distribution of Your modifications, or for any such Derivative Works as
|
||||
a whole, provided Your use, reproduction, and distribution of the Work otherwise
|
||||
complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
||||
Contribution intentionally submitted for inclusion in the Work by You to the
|
||||
Licensor shall be under the terms and conditions of this License, without
|
||||
any additional terms or conditions. Notwithstanding the above, nothing herein
|
||||
shall supersede or modify the terms of any separate license agreement you
|
||||
may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names,
|
||||
trademarks, service marks, or product names of the Licensor, except as required
|
||||
for reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to
|
||||
in writing, Licensor provides the Work (and each Contributor provides its
|
||||
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied, including, without limitation, any warranties
|
||||
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness
|
||||
of using or redistributing the Work and assume any risks associated with Your
|
||||
exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether
|
||||
in tort (including negligence), contract, or otherwise, unless required by
|
||||
applicable law (such as deliberate and grossly negligent acts) or agreed to
|
||||
in writing, shall any Contributor be liable to You for damages, including
|
||||
any direct, indirect, special, incidental, or consequential damages of any
|
||||
character arising as a result of this License or out of the use or inability
|
||||
to use the Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all other commercial
|
||||
damages or losses), even if such Contributor has been advised of the possibility
|
||||
of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work
|
||||
or Derivative Works thereof, You may choose to offer, and charge a fee for,
|
||||
acceptance of support, warranty, indemnity, or other liability obligations
|
||||
and/or rights consistent with this License. However, in accepting such obligations,
|
||||
You may act only on Your own behalf and on Your sole responsibility, not on
|
||||
behalf of any other Contributor, and only if You agree to indemnify, defend,
|
||||
and hold each Contributor harmless for any liability incurred by, or claims
|
||||
asserted against, such Contributor by reason of your accepting any such warranty
|
||||
or additional liability. END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate
|
||||
notice, with the fields enclosed by brackets "[]" replaced with your own identifying
|
||||
information. (Don't include the brackets!) The text should be enclosed in
|
||||
the appropriate comment syntax for the file format. We also recommend that
|
||||
a file or class name and description of purpose be included on the same "printed
|
||||
page" as the copyright notice for easier identification within third-party
|
||||
archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
See the License for the specific language governing permissions and
|
||||
|
||||
limitations under the License.
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
[.ShellClassInfo]
|
||||
IconResource=C:\WINDOWS\System32\SHELL32.dll,193
|
||||
217
pom.xml
217
pom.xml
|
|
@ -1,217 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>redstar</groupId>
|
||||
<artifactId>redstar-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>redstar</name>
|
||||
<packaging>pom</packaging>
|
||||
<description>红星微服务框架</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.5.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring.cloud.version>Hoxton.SR3</spring.cloud.version>
|
||||
<spring.cloud.alibaba.version>2.2.1.RELEASE</spring.cloud.alibaba.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>redstar-api</module>
|
||||
<module>redstar-example-provider</module>
|
||||
<module>redstar-example-consumer</module>
|
||||
<module>redstar-gateway</module>
|
||||
</modules>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nexus-aliyun</id>
|
||||
<name>Nexus aliyun</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring.cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>${spring.cloud.alibaba.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ibeetl</groupId>
|
||||
<artifactId>beetl-framework-starter</artifactId>
|
||||
<version>1.2.35.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>p6spy</groupId>
|
||||
<artifactId>p6spy</artifactId>
|
||||
<version>3.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.60</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark</artifactId>
|
||||
<version>0.12.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark-ext-gfm-tables</artifactId>
|
||||
<version>0.12.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark-ext-autolink</artifactId>
|
||||
<version>0.12.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark-ext-gfm-strikethrough</artifactId>
|
||||
<version>0.12.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark-ext-heading-anchor</artifactId>
|
||||
<version>0.12.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark-ext-ins</artifactId>
|
||||
<version>0.12.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark-ext-yaml-front-matter</artifactId>
|
||||
<version>0.12.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-configuration</groupId>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
<version>1.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Commons Collections -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Commons Codec -->
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.10</version>
|
||||
</dependency>
|
||||
|
||||
<!-- github上开源的关于excel导入导出工具项目 -->
|
||||
<dependency>
|
||||
<groupId>com.github.andyczy</groupId>
|
||||
<artifactId>java-excel-utils</artifactId>
|
||||
<version>4.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.google.guava</groupId>-->
|
||||
<!-- <artifactId>guava</artifactId>-->
|
||||
<!-- <version>16.0.1</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-api</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,258 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.4.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>redstar</groupId>
|
||||
<artifactId>auth</artifactId>
|
||||
<version>1.00</version>
|
||||
<name>redstar-auth</name>
|
||||
<description>红星微服务认证框架</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<swagger2.version>2.9.2</swagger2.version>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
<mybatisplus.version>3.3.1</mybatisplus.version>
|
||||
<spring-boot.version>2.3.4.RELEASE</spring-boot.version>
|
||||
<spring.cloud.version>Hoxton.SR11</spring.cloud.version>
|
||||
<nacos.version>2.1.1.RELEASE</nacos.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>alimaven</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>alimaven</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring.cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>${nacos.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>redstar</groupId>
|
||||
<artifactId>redstar-common</artifactId>
|
||||
<version>1.00</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- mybatis-plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatisplus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>${mybatisplus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- DataBase -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>p6spy</groupId>
|
||||
<artifactId>p6spy</artifactId>
|
||||
<version>3.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.whvcse</groupId>
|
||||
<artifactId>easy-captcha</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.logstash.logback</groupId>
|
||||
<artifactId>logstash-logback-encoder</artifactId>
|
||||
<version>6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xkcoding</groupId>
|
||||
<artifactId>justauth-spring-boot-starter</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-oauth2</artifactId>
|
||||
</dependency>
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- 1. nacos-配置管理功能依赖-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 2. nacos-服务发现功能依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Feign依赖,声明式开发 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<!-- swagger2 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${swagger2.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||
<version>1.9.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.5.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>1.5.22</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.github.shalousun</groupId>
|
||||
<artifactId>smart-doc-maven-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<configuration>
|
||||
<!--指定生成文档的使用的配置文件,配置文件放在自己的项目中-->
|
||||
<configFile>./src/main/resources/smart-doc.json</configFile>
|
||||
<!--指定项目名称-->
|
||||
<projectName>redstar-auth</projectName>
|
||||
<!--自1.0.8版本开始,插件提供includes支持-->
|
||||
<!--smart-doc能自动分析依赖树加载所有依赖源码,原则上会影响文档构建效率,因此你可以使用includes来让插件加载你配置的组件-->
|
||||
<includes>
|
||||
<!--格式为:groupId:artifactId;参考如下-->
|
||||
<include>com.alibaba:fastjson</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<!--如果不需要在执行编译时启动smart-doc,则将phase注释掉-->
|
||||
<!--<phase>compile</phase>-->
|
||||
<!--<goals>
|
||||
<!–smart-doc提供了html、openapi、markdown等goal,可按需配置–>
|
||||
<goal>html</goal>
|
||||
</goals>-->
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.redstar.auth.Feign;
|
||||
|
||||
import com.redstar.auth.Feign.hystrix.AuthServiceHystrix;
|
||||
import com.redstar.common.vo.result.JWT;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* Created by fangzhipeng on 2017/5/27.
|
||||
*/
|
||||
|
||||
@FeignClient(value = "pumkin-auth", fallback = AuthServiceHystrix.class)
|
||||
public interface AuthServiceClient {
|
||||
|
||||
@PostMapping(value = "/oauth/token")
|
||||
JWT getToken(@RequestHeader(value = "Authorization") String authorization, @RequestParam("grant_type") String type,
|
||||
@RequestParam("username") String username, @RequestParam("password") String password);
|
||||
|
||||
@PostMapping(value = "/oauth/token")
|
||||
JWT getToken(@RequestParam(value = "code") String code, @RequestParam(value = "grant_type") String grant_type,
|
||||
@RequestParam("client_id") String client_id, @RequestParam("client_secret") String client_secret, @RequestParam("redirect_uri") String redirect_uri);
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package com.redstar.auth.Feign.hystrix;
|
||||
|
||||
import com.redstar.auth.Feign.AuthServiceClient;
|
||||
import com.redstar.common.vo.result.JWT;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
*/
|
||||
@Component
|
||||
public class AuthServiceHystrix implements AuthServiceClient {
|
||||
@Override
|
||||
public JWT getToken(String authorization, String type, String username, String password) {
|
||||
System.out.println("--------opps getToken hystrix---------");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JWT getToken(String code, String grant_type, String client_id, String client_secret, String redirect_uri) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
package com.redstar.auth;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients
|
||||
@ComponentScan(basePackages = {"com.redstar.auth", "com.redstar"})
|
||||
public class RedstarAuthApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RedstarAuthApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
RestTemplate restTemplate(){
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
package com.redstar.auth.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.parser.ISqlParser;
|
||||
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.apache.ibatis.plugin.Interceptor;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@MapperScan({"com.redstar.auth.**.mapper"})
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
@Autowired
|
||||
DataSource datasource;
|
||||
|
||||
List<ISqlParser> sqlParserList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* mybatis-plus分页插件<br>
|
||||
* 文档:http://mp.baomidou.com<br>
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
return paginationInterceptor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OptimisticLockerInterceptor optimisticLockerInterceptor() {
|
||||
return new OptimisticLockerInterceptor();
|
||||
}
|
||||
|
||||
@Bean("sqlSessionFactory")
|
||||
public SqlSessionFactory sqlSessionFactory() throws Exception {
|
||||
MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
|
||||
sqlSessionFactory.setDataSource(datasource);
|
||||
sqlSessionFactory.setMapperLocations(
|
||||
new PathMatchingResourcePatternResolver().getResources("classpath:/mapper/**/*Mapper.xml"));
|
||||
MybatisConfiguration configuration = new MybatisConfiguration();
|
||||
configuration.setJdbcTypeForNull(JdbcType.NULL);
|
||||
configuration.setMapUnderscoreToCamelCase(true);
|
||||
configuration.setCacheEnabled(true);
|
||||
// 开启sql打印
|
||||
configuration.setLogImpl(StdOutImpl.class);
|
||||
sqlSessionFactory.setConfiguration(configuration);
|
||||
sqlSessionFactory
|
||||
.setPlugins(new Interceptor[] {this.paginationInterceptor(), this.optimisticLockerInterceptor()});
|
||||
return sqlSessionFactory.getObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
package com.redstar.auth.config;
|
||||
|
||||
import com.redstar.auth.service.impl.UserServiceDetailImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
|
||||
import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
|
||||
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
|
||||
import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory;
|
||||
|
||||
/**
|
||||
*/
|
||||
@Configuration
|
||||
@EnableAuthorizationServer
|
||||
@RefreshScope
|
||||
public class OAuth2Config extends AuthorizationServerConfigurerAdapter {
|
||||
|
||||
@Value("${auth.type.trustie.client-id}")
|
||||
private String clientId;
|
||||
@Value("${auth.type.trustie.redirect-uri}")
|
||||
private String redirectUri;
|
||||
@Value("${auth.type.trustie.client-secret}")
|
||||
private String clientSecret;
|
||||
|
||||
@Autowired
|
||||
UserServiceDetailImpl userServiceDetailImpl;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("cusAuthenticationManager")
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
|
||||
@Override
|
||||
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
|
||||
String finalPassword = "{bcrypt}" + new BCryptPasswordEncoder().encode("123456");
|
||||
clients.inMemory()
|
||||
.withClient("user-service")
|
||||
.secret(new BCryptPasswordEncoder().encode("123456"))
|
||||
.authorizedGrantTypes("authorization_code", "refresh_token", "implicit","password")
|
||||
.accessTokenValiditySeconds(60 * 60 * 2)
|
||||
.scopes("all")
|
||||
.autoApprove(true)
|
||||
|
||||
.and()
|
||||
.withClient(clientId)
|
||||
.authorizedGrantTypes("authorization_code", "refresh_token")
|
||||
.accessTokenValiditySeconds(60 * 60 * 2)
|
||||
.scopes("all")
|
||||
.secret(new BCryptPasswordEncoder().encode(clientSecret))
|
||||
.redirectUris(redirectUri)
|
||||
.autoApprove(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
|
||||
endpoints.tokenStore(tokenStore()).tokenEnhancer(JwtAccessTokenConverter())
|
||||
.authenticationManager(authenticationManager).userDetailsService(userServiceDetailImpl)
|
||||
.allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
|
||||
|
||||
//允许表单认证
|
||||
oauthServer.allowFormAuthenticationForClients();
|
||||
|
||||
//允许 check_token 访问
|
||||
oauthServer.checkTokenAccess("permitAll()");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public TokenStore tokenStore() {
|
||||
return new JwtTokenStore(JwtAccessTokenConverter());
|
||||
}
|
||||
|
||||
|
||||
/* @Bean
|
||||
public PasswordEncoder asswordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}*/
|
||||
|
||||
@Bean
|
||||
protected JwtAccessTokenConverter JwtAccessTokenConverter() {
|
||||
KeyStoreKeyFactory keyStoreKeyFactory =
|
||||
new KeyStoreKeyFactory(new ClassPathResource("fzp-jwt.jks"), "fzp123".toCharArray());
|
||||
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
|
||||
converter.setKeyPair(keyStoreKeyFactory.getKeyPair("fzp-jwt"));
|
||||
return converter;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
package com.redstar.auth.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* Redis配置
|
||||
*
|
||||
* @author zhuyd
|
||||
* @date 2019/09/29
|
||||
*/
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class RedisConfig extends CachingConfigurerSupport {
|
||||
|
||||
/**
|
||||
* 重写RedisTemplate的Bean
|
||||
*
|
||||
* @param redisConnectionFactory
|
||||
* @return
|
||||
* @throws UnknownHostException
|
||||
* @author Zhuyd
|
||||
* @date 2019-09-29 12:34:10
|
||||
*/
|
||||
@Bean
|
||||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory)
|
||||
throws UnknownHostException {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>();
|
||||
template.setConnectionFactory(redisConnectionFactory);
|
||||
|
||||
/**
|
||||
* TODO 如果将redisTemplate的ValueSerializer设置成了
|
||||
* StringRedisSerializer,StringRedisSerializer参数是String类型的,会出现了类型转化错误。2019-11-18
|
||||
*/
|
||||
template.setKeySerializer(jackson2JsonRedisSerializer());
|
||||
template.setValueSerializer(jackson2JsonRedisSerializer());
|
||||
template.setHashKeySerializer(jackson2JsonRedisSerializer());
|
||||
template.setHashValueSerializer(jackson2JsonRedisSerializer());
|
||||
return template;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过自定义配置构建Redis的Json序列化器
|
||||
*
|
||||
* @return Jackson2JsonRedisSerializer对象
|
||||
* @author Zhuyd
|
||||
* @date 2019-09-30 10:27:16
|
||||
*/
|
||||
private Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer() {
|
||||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer =
|
||||
new Jackson2JsonRedisSerializer<>(Object.class);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
objectMapper.configure(MapperFeature.USE_ANNOTATIONS, false);
|
||||
// 如果json中有新增的字段并且是实体类类中不存在的,不报错
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
// 此项必须配置,否则会报java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to xxx
|
||||
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
|
||||
return jackson2JsonRedisSerializer;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
package com.redstar.auth.config;
|
||||
|
||||
import com.redstar.auth.filter.LoginAuthenticationFilter;
|
||||
import com.redstar.auth.service.impl.UserServiceDetailImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
|
||||
/**
|
||||
* Created by fangzhipeng on 2017/5/27.
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Value("${auth.loginpage}")
|
||||
private String loginpage;
|
||||
@Autowired
|
||||
UserServiceDetailImpl userServiceDetailImpl;
|
||||
|
||||
WebSecurityConfig() {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManagerBean() throws Exception {
|
||||
return super.authenticationManagerBean();
|
||||
}
|
||||
@Autowired
|
||||
private LoginAuthenticationFilter loginAuthenticationFilter;
|
||||
@Bean
|
||||
PasswordEncoder passwordEncoder(){
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.
|
||||
requestMatchers()
|
||||
// 必须登录过的用户才可以进行 oauth2 的授权码申请
|
||||
.antMatchers( "/oauth/**", "/login","/oauth/authorize")
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.anyRequest().permitAll()
|
||||
.and()
|
||||
.formLogin()
|
||||
.loginPage(loginpage)
|
||||
//指定自定义form表单请求的路径
|
||||
.loginProcessingUrl("/login")
|
||||
.and()
|
||||
.httpBasic()
|
||||
.disable()
|
||||
.exceptionHandling()
|
||||
.accessDeniedPage("/login?authorization_error=true")
|
||||
.and()
|
||||
.csrf()
|
||||
.requireCsrfProtectionMatcher(new AntPathRequestMatcher("/oauth/authorize"))
|
||||
.disable();
|
||||
|
||||
// 自定义过滤器认证用户名密码
|
||||
http.addFilterAt(loginAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* AuthenticationManagerBuilder 是用来构建 AuthenticationManager(处理登录操作)的 需要两个东西:userDetailsService 、passwordEncoder
|
||||
*
|
||||
* @param auth
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.userDetailsService(userServiceDetailImpl).passwordEncoder(passwordEncoder());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
|
||||
*
|
||||
* https://www.gz-yami.com/
|
||||
*
|
||||
* 未经允许,不可做商业用途!
|
||||
*
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
|
||||
package com.redstar.auth.filter;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.redstar.auth.form.UserLoginForm;
|
||||
import com.redstar.auth.login.AdminAuthenticationFailureHandler;
|
||||
import com.redstar.auth.login.AdminAuthenticationSuccessHandler;
|
||||
import com.redstar.auth.login.AdminAuthenticationToken;
|
||||
import com.redstar.auth.login.CusAuthenticationManager;
|
||||
import com.redstar.auth.service.UserService;
|
||||
import com.redstar.auth.vo.AuthUser;
|
||||
import com.redstar.common.constant.UserConstants;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 管理员登陆:
|
||||
* post: http://127.0.0.1:8085/login
|
||||
* {principal:username,credentials:password}
|
||||
*/
|
||||
@Component
|
||||
public class LoginAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
|
||||
@Autowired
|
||||
UserService UserServiceImpl;
|
||||
|
||||
@Autowired
|
||||
public LoginAuthenticationFilter(CusAuthenticationManager authenticationManager, AdminAuthenticationSuccessHandler adminAuthenticationSuccessHandler, AdminAuthenticationFailureHandler adminAuthenticationFailureHandler) {
|
||||
super("/login");
|
||||
this.setAuthenticationManager(authenticationManager);
|
||||
this.setAuthenticationSuccessHandler(adminAuthenticationSuccessHandler);
|
||||
this.setAuthenticationFailureHandler(adminAuthenticationFailureHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
|
||||
|
||||
Map<String,String> parmMap=new HashMap<>();
|
||||
Map<String,String[]> map= request.getParameterMap();
|
||||
//参数名称
|
||||
Set<String> key=map.keySet();
|
||||
//参数迭代器
|
||||
Iterator<String> iterator = key.iterator();
|
||||
while(iterator.hasNext()){
|
||||
String k=iterator.next();
|
||||
parmMap.put(k, map.get(k)[0]);
|
||||
}
|
||||
System.out.println("parmMap====="+parmMap.toString());
|
||||
UserLoginForm userLoginForm=new UserLoginForm();
|
||||
userLoginForm= JSONObject.parseObject(JSONObject.toJSONString(parmMap), UserLoginForm.class);
|
||||
if(userLoginForm.getLoginType()==null){
|
||||
userLoginForm.setLoginType(UserConstants.LOGIN_TYPE.MOBILE);
|
||||
}
|
||||
AuthUser authUser= UserServiceImpl.checkLogin(userLoginForm);
|
||||
final AdminAuthenticationToken adminAuthenticationToken =
|
||||
new AdminAuthenticationToken(userLoginForm.getMobile()+ userLoginForm.getUserType(), userLoginForm.getPassword(),authUser.getLoginType(),authUser.getUserType(),authUser.getEnterpriseId());
|
||||
adminAuthenticationToken.setPrincipal(userLoginForm.getMobile()+ userLoginForm.getUserType());
|
||||
return this.getAuthenticationManager().authenticate(adminAuthenticationToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
package com.redstar.auth.form;
|
||||
|
||||
import com.redstar.common.constant.UserConstants;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author xingkong
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "用户登录form", description = "用户登录form")
|
||||
public class UserLoginForm {
|
||||
|
||||
@NotBlank(message = "用户名不能为空")
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private String mobile;
|
||||
|
||||
@NotBlank(message = "密码不能为空")
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 用户类型 USER_TYPE_ADMIN = 1 平台 USER_TYPE_NORMAL=2 门户 USER_TYPE_ENTERPRISE=3 企业
|
||||
*/
|
||||
@ApiModelProperty(value = " 用户类型")
|
||||
private Integer userType;
|
||||
@ApiModelProperty(value = " 登录类型")
|
||||
private Integer loginType= UserConstants.LOGIN_TYPE.MOBILE;
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
@ApiModelProperty(value = " 企业ID")
|
||||
private Long enterpriseId;
|
||||
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
package com.redstar.auth.login;
|
||||
|
||||
import com.redstar.common.utils.ResponseTool;
|
||||
import com.redstar.common.utils.ResponseUtils;
|
||||
import com.redstar.common.vo.result.ResponseVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.authentication.*;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <p> 认证失败处理 - 前后端分离情况下返回json数据格式 </p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AdminAuthenticationFailureHandler implements AuthenticationFailureHandler {
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
|
||||
ResponseVo result;
|
||||
if (e instanceof UsernameNotFoundException || e instanceof BadCredentialsException) {
|
||||
result = ResponseTool.error(e.getMessage());
|
||||
} else if (e instanceof LockedException) {
|
||||
result = ResponseTool.error("账户被锁定,请联系管理员!");
|
||||
} else if (e instanceof CredentialsExpiredException) {
|
||||
result = ResponseTool.error("证书过期,请联系管理员!");
|
||||
} else if (e instanceof AccountExpiredException) {
|
||||
result = ResponseTool.error("账户过期,请联系管理员!");
|
||||
} else if (e instanceof DisabledException) {
|
||||
result = ResponseTool.error("账户被禁用,请联系管理员!");
|
||||
} else {
|
||||
log.error("登录失败:", e);
|
||||
result = ResponseTool.error("登录失败!");
|
||||
}
|
||||
ResponseUtils.out(response, result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
package com.redstar.auth.login;
|
||||
|
||||
import com.redstar.auth.service.impl.UserServiceDetailImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p> 自定义认证处理 </p>
|
||||
*
|
||||
* @description :
|
||||
* @author : zhengqing
|
||||
* @date : 2019/10/12 14:49
|
||||
*/
|
||||
@Component
|
||||
public class AdminAuthenticationProvider implements AuthenticationProvider {
|
||||
@Autowired
|
||||
private UserServiceDetailImpl UserServiceDetailImpl;
|
||||
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
// 获取前端表单中输入后返回的用户名、密码
|
||||
String principal = (String) authentication.getPrincipal();
|
||||
String password = (String) authentication.getCredentials();
|
||||
UserDetails userDetails= UserServiceDetailImpl.loadUserByUsername(principal);
|
||||
final AdminAuthenticationToken adminAuthenticationToken =
|
||||
new AdminAuthenticationToken(principal, password, userDetails.getAuthorities());
|
||||
adminAuthenticationToken.setPrincipal(principal);
|
||||
return adminAuthenticationToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> aClass) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
package com.redstar.auth.login;
|
||||
|
||||
|
||||
import com.redstar.auth.Feign.AuthServiceClient;
|
||||
import com.redstar.auth.vo.AuthSession;
|
||||
import com.redstar.auth.vo.AuthUser;
|
||||
import com.redstar.common.exception.BusinessException;
|
||||
import com.redstar.common.service.RedisService;
|
||||
import com.redstar.common.utils.ResponseTool;
|
||||
import com.redstar.common.utils.ResponseUtils;
|
||||
import com.redstar.common.utils.UserIdTool;
|
||||
import com.redstar.common.vo.result.JWT;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
import org.springframework.security.web.savedrequest.DefaultSavedRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p> 认证成功处理 </p>
|
||||
*
|
||||
* @description :
|
||||
*/
|
||||
@Component
|
||||
public class AdminAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
@Resource
|
||||
AuthServiceClient client;
|
||||
@Value("${auth.serverUrl}")
|
||||
private String serverUrl;
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||
try {
|
||||
AuthSession authSession = (AuthSession) redisService.get(authentication.getPrincipal());
|
||||
AuthUser authUser = new AuthUser();
|
||||
BeanUtils.copyProperties(authSession, authUser);
|
||||
if (UserIdTool.isNumber((String) authentication.getPrincipal())) {
|
||||
authUser.setMobile(((String) authentication.getPrincipal()).substring(0, 11));
|
||||
}
|
||||
List<String> authorities = (List<String>) redisService.get(authentication.getPrincipal() + "AUTH");
|
||||
authUser.setAuthoritiesList(authorities);
|
||||
JWT jwt = client.getToken("Basic dXNlci1zZXJ2aWNlOjEyMzQ1Ng==", "password",
|
||||
(String)authentication.getPrincipal(), (String)authentication.getCredentials());
|
||||
|
||||
if (jwt == null) {
|
||||
throw new BusinessException("error internal");
|
||||
}
|
||||
DefaultSavedRequest savedRequest = (DefaultSavedRequest)httpServletRequest.getSession().getAttribute("SPRING_SECURITY_SAVED_REQUEST");
|
||||
authUser.setJwt(jwt);
|
||||
if(savedRequest!=null &&savedRequest.getQueryString().indexOf("response_type=code")!=-1){
|
||||
//response.setStatus(302);
|
||||
//response.setHeader("Location", serverUrl+"?"+savedRequest.getQueryString());//设置新请求的URL
|
||||
authUser.setUrl(serverUrl+"?"+savedRequest.getQueryString());
|
||||
ResponseUtils.out(response, ResponseTool.success(authUser));
|
||||
}else {
|
||||
ResponseUtils.out(response, ResponseTool.success(authUser));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
package com.redstar.auth.login;
|
||||
|
||||
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AdminAuthenticationToken extends AbstractAuthenticationToken {
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 登录类型 短信,账户,
|
||||
*/
|
||||
private Integer loginType;
|
||||
|
||||
/**
|
||||
* 用户类型 USER_TYPE_ADMIN 1 后台管理员 USER_TYPE_NORMAL 2 门户 USER_TYPE_ENTERPRISE 3 企业
|
||||
*/
|
||||
private Integer userType;
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
private Long enterpriseId;
|
||||
|
||||
/**
|
||||
* 主体
|
||||
*/
|
||||
private Object principal;
|
||||
|
||||
public AdminAuthenticationToken(String account, String password, Integer loginType, Integer userType,
|
||||
Long enterpriseId) {
|
||||
super(null);
|
||||
this.mobile = account;
|
||||
this.password = password;
|
||||
this.loginType = loginType;
|
||||
this.userType = userType;
|
||||
this.enterpriseId = enterpriseId;
|
||||
}
|
||||
|
||||
public AdminAuthenticationToken(String account, String password, Integer userType,
|
||||
Long enterpriseId) {
|
||||
super(null);
|
||||
this.mobile = account;
|
||||
this.password = password;
|
||||
this.userType = userType;
|
||||
this.enterpriseId = enterpriseId;
|
||||
}
|
||||
|
||||
|
||||
public AdminAuthenticationToken(String mobile, String password, Collection<? extends GrantedAuthority> authorities) {
|
||||
super(authorities);
|
||||
super.setAuthenticated(true);
|
||||
setPrincipal(mobile);
|
||||
this.mobile = mobile;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCredentials() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPrincipal() {
|
||||
return this.principal;
|
||||
}
|
||||
|
||||
public void setPrincipal(Object principal) {
|
||||
this.principal = principal;
|
||||
}
|
||||
|
||||
public Integer getLoginType() {
|
||||
return loginType;
|
||||
}
|
||||
|
||||
public void setLoginType(Integer type) {
|
||||
this.loginType = type;
|
||||
}
|
||||
|
||||
public Long getEnterpriseId() {
|
||||
return enterpriseId;
|
||||
}
|
||||
|
||||
public void setEnterpriseId(Long enterpriseId) {
|
||||
this.enterpriseId = enterpriseId;
|
||||
}
|
||||
|
||||
public Integer getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(Integer userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package com.redstar.auth.login;
|
||||
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.ProviderNotFoundException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p> 自定义认证管理器 </p>
|
||||
*
|
||||
* @author : zhengqing
|
||||
* @description :
|
||||
* @date : 2019/10/12 14:49
|
||||
*/
|
||||
@Component
|
||||
public class CusAuthenticationManager implements AuthenticationManager {
|
||||
|
||||
private final AdminAuthenticationProvider adminAuthenticationProvider;
|
||||
|
||||
public CusAuthenticationManager(AdminAuthenticationProvider adminAuthenticationProvider) {
|
||||
this.adminAuthenticationProvider = adminAuthenticationProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
Authentication result = adminAuthenticationProvider.authenticate(authentication);
|
||||
if (Objects.nonNull(result)) {
|
||||
return result;
|
||||
}
|
||||
throw new ProviderNotFoundException("Authentication failed!");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package com.redstar.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.redstar.auth.mo.OauthClientDetails;
|
||||
|
||||
/**
|
||||
* @author Yuuki
|
||||
*/
|
||||
public interface OauthClientDetailsMapper extends BaseMapper<OauthClientDetails> {
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
package com.redstar.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.redstar.auth.mo.UserMo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author xingkong
|
||||
*/
|
||||
@Repository
|
||||
public interface UserMapper extends BaseMapper<UserMo> {
|
||||
|
||||
/**
|
||||
* 根据uid查询用户所有角色
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Set<String> selectRoleByUid(@Param(Constants.WRAPPER) QueryWrapper wrapper);
|
||||
|
||||
/**
|
||||
* 根据uid查询用户组所有角色
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Set<String> selectRoleByGroup(@Param("uid") Long uid, @Param("enterpriseId") Long enterpriseId, @Param("sysType") Integer sysType);
|
||||
|
||||
/**
|
||||
* 根据uid查询用户所有权限
|
||||
*
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
Set<String> selectAuthorityByUid(@Param("uid") Long uid, @Param("enterpriseId") Long enterpriseId,
|
||||
@Param("sysType") Integer sysType);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
package com.redstar.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.redstar.auth.mo.UserMenuMo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @desc 用户菜单DAO类
|
||||
*/
|
||||
@Repository
|
||||
public interface UserMenuMapper extends BaseMapper<UserMenuMo> {
|
||||
|
||||
/**
|
||||
* 根据uid查询用户菜单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<UserMenuMo> listByUser(@Param(Constants.WRAPPER) QueryWrapper wrapper);
|
||||
|
||||
/**
|
||||
* 根据uid 对应的用户组菜单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<UserMenuMo> listByGroupUser(@Param("uid") Long uid, @Param("enterpriseId") Long enterpriseId, @Param("sysType") Integer sysType);
|
||||
|
||||
/**
|
||||
* 获取企业对应的菜单列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<UserMenuMo> listByEnterprise(@Param("enterpriseId") Long enterpriseId, @Param("sysType") Integer sysType);
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package com.redstar.auth.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.redstar.auth.mo.UserRoleMo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @desc 用户角色DAO类
|
||||
*/
|
||||
@Repository
|
||||
public interface UserRoleMapper extends BaseMapper<UserRoleMo> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据企业ID获取角色列表
|
||||
* @return
|
||||
*/
|
||||
List<UserRoleMo> listEnterpriseRole(@Param("enterpriseId") Long enterpriseId, @Param("sysType") Integer sysType);
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
package com.redstar.auth.mo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Yuuki
|
||||
*/
|
||||
@Data
|
||||
@TableName("oauth_client_details")
|
||||
public class OauthClientDetails implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 421783821058285802L;
|
||||
|
||||
@TableId(value = "client_id")
|
||||
@NotBlank(message = "{required}")
|
||||
@Size(max = 255, message = "{noMoreThan}")
|
||||
private String clientId;
|
||||
|
||||
@TableField("resource_ids")
|
||||
@Size(max = 255, message = "{noMoreThan}")
|
||||
private String resourceIds;
|
||||
|
||||
@TableField("client_secret")
|
||||
@NotBlank(message = "{required}")
|
||||
@Size(max = 255, message = "{noMoreThan}")
|
||||
private String clientSecret;
|
||||
|
||||
@TableField("scope")
|
||||
@NotBlank(message = "{required}")
|
||||
@Size(max = 255, message = "{noMoreThan}")
|
||||
private String scope;
|
||||
|
||||
@TableField("authorized_grant_types")
|
||||
@NotBlank(message = "{required}")
|
||||
@Size(max = 255, message = "{noMoreThan}")
|
||||
private String authorizedGrantTypes;
|
||||
|
||||
@TableField("web_server_redirect_uri")
|
||||
@Size(max = 255, message = "{noMoreThan}")
|
||||
private String webServerRedirectUri;
|
||||
|
||||
@TableField("authorities")
|
||||
@Size(max = 255, message = "{noMoreThan}")
|
||||
private String authorities;
|
||||
|
||||
@TableField("access_token_validity")
|
||||
@NotNull(message = "{required}")
|
||||
private Integer accessTokenValidity;
|
||||
|
||||
@TableField("refresh_token_validity")
|
||||
private Integer refreshTokenValidity;
|
||||
|
||||
@TableField("autoapprove")
|
||||
private Byte autoapprove;
|
||||
|
||||
@TableField("origin_secret")
|
||||
private String originSecret;
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
package com.redstar.auth.mo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @desc 管理员额外信息模型类
|
||||
*/
|
||||
@TableName("user_admin_extra_info")
|
||||
@Data
|
||||
@ToString
|
||||
public class UserAdminExtraInfoMo implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* user.uid
|
||||
*/
|
||||
@TableField("uid")
|
||||
private Long uid;
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
@TableField("real_name")
|
||||
private String realName;
|
||||
/**
|
||||
* 性别: 1=男性,2=女性
|
||||
*/
|
||||
@TableField("sex")
|
||||
private Integer sex;
|
||||
/**
|
||||
* 邮箱地址
|
||||
*/
|
||||
@TableField("email")
|
||||
private String email;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableField("qq")
|
||||
private String qq;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
package com.redstar.auth.mo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @desc 用户权限模型类
|
||||
*/
|
||||
@TableName("user_authority")
|
||||
@Data
|
||||
@ToString
|
||||
@ApiModel(value = "UserAuthorityMo对象", description = "用户权限")
|
||||
public class UserAuthorityMo implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Long id;
|
||||
/**
|
||||
* 权限字符串,小写,冒号分割,参考:book:create, book:read, book:update, book:delete 或者book作粗粒度控制(代表图书模块所有权限)
|
||||
*/
|
||||
@TableField("authority")
|
||||
@ApiModelProperty(
|
||||
value = "权限字符串,小写,冒号分割,参考:book:create, book:read, book:update, book:delete 或者book作粗粒度控制(代表图书模块所有权限)")
|
||||
private String authority;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 系统类型 0 后台 1 门户 2 企业
|
||||
*/
|
||||
@TableField(value = "sys_type")
|
||||
@ApiModelProperty(value = "系统类型 0 后台 1 门户 2 企业")
|
||||
private Integer sysType;
|
||||
|
||||
@TableField(value = "menu_button_id")
|
||||
@ApiModelProperty(value = "菜单按钮的id")
|
||||
private Long menuButtonId;
|
||||
|
||||
}
|
||||
|
|
@ -1,117 +0,0 @@
|
|||
package com.redstar.auth.mo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @desc 用户菜单模型类
|
||||
*/
|
||||
@TableName("user_menu")
|
||||
@Data
|
||||
@ToString
|
||||
@ApiModel(value = "UserMenuMo对象", description = "用户菜单")
|
||||
public class UserMenuMo implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Long id;
|
||||
/**
|
||||
* 资源名
|
||||
*/
|
||||
@TableField("name")
|
||||
@ApiModelProperty(value = "资源名")
|
||||
private String name;
|
||||
/**
|
||||
* 资源URL
|
||||
*/
|
||||
@TableField("default_url")
|
||||
@ApiModelProperty(value = "资源URL")
|
||||
private String defaultUrl;
|
||||
/**
|
||||
* 权限
|
||||
*/
|
||||
@TableField("authority")
|
||||
@ApiModelProperty(value = "权限")
|
||||
private String authority;
|
||||
/**
|
||||
* 父ID
|
||||
*/
|
||||
@TableField(value = "parent_id", updateStrategy = FieldStrategy.IGNORED)
|
||||
@ApiModelProperty(value = "父ID")
|
||||
private Long parentId;
|
||||
/**
|
||||
* 显示到菜单(1,显示,0 ,不显示)
|
||||
*/
|
||||
@TableField("is_enabled")
|
||||
@ApiModelProperty(value = "显示到菜单(1,显示,0 ,不显示)")
|
||||
private Integer isEnabled;
|
||||
/**
|
||||
* 是否有子节点(1有,0 ,无)
|
||||
*/
|
||||
@TableField("has_children")
|
||||
@ApiModelProperty(value = "是否有子节点(1有,0 ,无)")
|
||||
private Integer hasChildren;
|
||||
/**
|
||||
* 图标
|
||||
*/
|
||||
@TableField("icon")
|
||||
@ApiModelProperty(value = "图标")
|
||||
private String icon;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("sequence")
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sequence;
|
||||
/**
|
||||
* 是否打开新窗口
|
||||
*/
|
||||
@TableField("is_new_window")
|
||||
@ApiModelProperty(value = "是否打开新窗口")
|
||||
private Integer isNewWindow;
|
||||
/**
|
||||
* 是否全屏
|
||||
*/
|
||||
@TableField("is_full_screen")
|
||||
@ApiModelProperty(value = "是否全屏")
|
||||
private Integer isFullScreen;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 组件
|
||||
*/
|
||||
@TableField("component")
|
||||
@ApiModelProperty(value = "组件")
|
||||
private String component;
|
||||
/**
|
||||
* 类型 1 菜单 2 按钮
|
||||
*/
|
||||
@TableField("type")
|
||||
@ApiModelProperty(value = "类型 1 菜单 2 按钮")
|
||||
private Integer type;
|
||||
/**
|
||||
* 系统类型 1 后台 2 门户 3 企业
|
||||
*/
|
||||
@TableField("sys_type")
|
||||
@ApiModelProperty(value = "系统类型 1 后台 2 门户 3 企业")
|
||||
private Integer sysType;
|
||||
|
||||
/**
|
||||
* 是否自动赋予菜单
|
||||
*/
|
||||
@TableField("is_auto")
|
||||
@ApiModelProperty(value = "是否自动赋予菜单")
|
||||
private Integer isAuto;
|
||||
}
|
||||
|
|
@ -1,216 +0,0 @@
|
|||
package com.redstar.auth.mo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author xingkong
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("mapper/user")
|
||||
public class UserMo {
|
||||
|
||||
@TableId(value = "uid", type = IdType.AUTO)
|
||||
private Long uid;
|
||||
|
||||
/**
|
||||
* 微信Id
|
||||
*/
|
||||
@TableField("wx_open_id")
|
||||
private String wxOpenId;
|
||||
|
||||
/**
|
||||
* 用户真实姓名
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
@TableField("nick_name")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户手机号码
|
||||
*/
|
||||
@TableField("mobile")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
@TableField("password")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 加密盐
|
||||
*/
|
||||
@TableField("salt")
|
||||
private String salt;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
@TableField("avatar")
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 用户性别, 0 女 1 男 2 保密
|
||||
*/
|
||||
@TableField("sex")
|
||||
private Integer sex;
|
||||
|
||||
/**
|
||||
* 用户状态,0 正常 1 禁用
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 来源类型
|
||||
*/
|
||||
@TableField("source")
|
||||
private Integer source;
|
||||
|
||||
/**
|
||||
* 号码归属地 - 省份
|
||||
*/
|
||||
@TableField("province")
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 注册IP
|
||||
*/
|
||||
@TableField("ip")
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 号码归属地 - 城市
|
||||
*/
|
||||
@TableField("city")
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 最后登陆时间
|
||||
*/
|
||||
@TableField("last_login_time")
|
||||
private Date lastLoginTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField("creator_id")
|
||||
private Integer creatorId;
|
||||
|
||||
/**
|
||||
* 用户注册时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Date dateLeft;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Date dateRight;
|
||||
|
||||
/**
|
||||
* zstack账户密码
|
||||
*/
|
||||
@TableField("zstack_password")
|
||||
private String zstackPassword;
|
||||
|
||||
/**
|
||||
* zstackuid
|
||||
*/
|
||||
@TableField("zstack_uuid")
|
||||
private String zstackUuid;
|
||||
|
||||
/**
|
||||
* 用户注册时的的邀请码
|
||||
*/
|
||||
@TableField("invite_code")
|
||||
private String inviteCode;
|
||||
/**
|
||||
* 扩展字段
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Boolean isAdmin;
|
||||
|
||||
/**
|
||||
* 扩展查询字段
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Date startTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 个人简介
|
||||
*/
|
||||
@ApiModelProperty(value = "个人简介")
|
||||
@TableField("profile")
|
||||
private String profile;
|
||||
/**
|
||||
* 职位
|
||||
*/
|
||||
@ApiModelProperty(value = "职位")
|
||||
@TableField("position")
|
||||
private String position;
|
||||
/**
|
||||
* 用户身份Id
|
||||
*/
|
||||
@ApiModelProperty(value = "用户身份Id")
|
||||
@TableField("personal_id")
|
||||
private Long personalId;
|
||||
|
||||
/**
|
||||
* 用户身份认证状态
|
||||
*/
|
||||
@ApiModelProperty(value = "认证状态")
|
||||
@TableField("identitification_status")
|
||||
private Integer identitificationStatus;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@ApiModelProperty(value = "邮箱")
|
||||
@TableField("email")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 原始UID
|
||||
*/
|
||||
@ApiModelProperty(value = "原始UID")
|
||||
@TableField("original_uid")
|
||||
private Long originalUid;
|
||||
|
||||
/**
|
||||
* mac地址
|
||||
*/
|
||||
@ApiModelProperty(value = "mac地址")
|
||||
@TableField("mac")
|
||||
private String mac;
|
||||
|
||||
/**
|
||||
* 是否跳过
|
||||
*/
|
||||
@ApiModelProperty(value = "是否跳过")
|
||||
@TableField("keep_status")
|
||||
private Integer keepStatus;
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
package com.redstar.auth.mo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @desc 用户权限映射模型类
|
||||
*/
|
||||
@TableName("user_role_authority_mapping")
|
||||
@Data
|
||||
@ToString
|
||||
@ApiModel(value = "UserRoleAuthorityMappingMo对象", description = "用户权限映射")
|
||||
public class UserRoleAuthorityMappingMo implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Long id;
|
||||
/**
|
||||
* user_role.id
|
||||
*/
|
||||
@TableField("user_role_id")
|
||||
@ApiModelProperty(value = "user_role.id")
|
||||
private Long userRoleId;
|
||||
/**
|
||||
* user_authority.id
|
||||
*/
|
||||
@TableField("user_authority_id")
|
||||
@ApiModelProperty(value = "user_authority.id")
|
||||
private Long userAuthorityId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 企业ID 默认为平台
|
||||
*/
|
||||
@TableField(value = "enterprise_id")
|
||||
@ApiModelProperty(value = "企业ID 默认为平台")
|
||||
private Long enterpriseId;
|
||||
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
package com.redstar.auth.mo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @desc 用户角色映射模型类
|
||||
*/
|
||||
@TableName("user_role_mapping")
|
||||
@Data
|
||||
@ToString
|
||||
@ApiModel(value = "UserRoleMappingMo对象", description = "用户角色映射")
|
||||
public class UserRoleMappingMo implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Long id;
|
||||
/**
|
||||
* user.uid
|
||||
*/
|
||||
@TableField("uid")
|
||||
@ApiModelProperty(value = "user.uid")
|
||||
private Long uid;
|
||||
/**
|
||||
* user_role.id
|
||||
*/
|
||||
@TableField("user_role_id")
|
||||
@ApiModelProperty(value = "user_role.id")
|
||||
private Long userRoleId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 企业ID 默认为平台
|
||||
*/
|
||||
@TableField(value = "enterprise_id")
|
||||
@ApiModelProperty(value = "企业ID 默认为平台")
|
||||
private Long enterpriseId;
|
||||
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
package com.redstar.auth.mo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @desc 用户角色模型类
|
||||
*/
|
||||
@TableName("user_role")
|
||||
@Data
|
||||
@ToString
|
||||
@ApiModel(value = "UserRoleMo对象", description = "用户角色")
|
||||
public class UserRoleMo implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Long id;
|
||||
/**
|
||||
* 角色名称,Spring Security 强制 ROLE_ 开始并大写,参考:ROLE_ADMIN
|
||||
*/
|
||||
@TableField("role")
|
||||
@ApiModelProperty(value = "角色名称,Spring Security 强制 ROLE_ 开始并大写,参考:ROLE_ADMIN")
|
||||
private String role;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 企业ID 默认为平台
|
||||
*/
|
||||
@TableField(value = "enterprise_id")
|
||||
@ApiModelProperty(value = "企业ID 默认为平台")
|
||||
private Long enterpriseId;
|
||||
|
||||
/**
|
||||
* 角色备注
|
||||
*/
|
||||
@TableField("remark")
|
||||
@ApiModelProperty(value = "角色备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@TableField("name")
|
||||
@ApiModelProperty(value = "角色名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 系统类型 0 后台 1 门户 2 企业 门户、企业共用
|
||||
*/
|
||||
@TableField(value = "sys_type")
|
||||
@ApiModelProperty(value = "系统类型 0 后台 1 门户 2 企业")
|
||||
private Integer sysType;
|
||||
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package com.redstar.auth.service;
|
||||
|
||||
import com.redstar.auth.mo.UserMenuMo;
|
||||
import com.redstar.common.service.BaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserMenuService extends BaseService<UserMenuMo> {
|
||||
|
||||
List<UserMenuMo> listUserHasMenu(Long uid, Long enterpriseId, Integer sysType, Boolean isAdmin);
|
||||
|
||||
List<UserMenuMo> getCheckedChildList(List<UserMenuMo> allMenuList, List<UserMenuMo> userMenuList);
|
||||
|
||||
List<UserMenuMo> getCheckedParentList(List<UserMenuMo> allMenuList, List<UserMenuMo> userMenuList);
|
||||
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
package com.redstar.auth.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.redstar.auth.form.UserLoginForm;
|
||||
import com.redstar.auth.mo.UserMo;
|
||||
import com.redstar.auth.vo.AuthUser;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Description: 用户新增
|
||||
**/
|
||||
public interface UserService extends IService<UserMo> {
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
UserMo getUserMo(String userName);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 载入用户所有角色, 数据库存储约定 ROLE_ 开头,大写
|
||||
*
|
||||
* @param uid
|
||||
* @param enterpriseId
|
||||
* @param sysType
|
||||
* 1 运营平台 2 门户 3 企业
|
||||
* @return
|
||||
*/
|
||||
Set<GrantedAuthority> loadUserAuthority(final Long uid, Long enterpriseId, Integer sysType, Boolean isAdmin);
|
||||
|
||||
/**
|
||||
* 载入所有用户权限, 数据库存储
|
||||
*
|
||||
* @param uid
|
||||
* @param enterpriseId
|
||||
* @param sysType
|
||||
* 1 运营平台 2 门户 3 企业
|
||||
* @return
|
||||
*/
|
||||
Set<GrantedAuthority> loadUserRole(final Long uid, Long enterpriseId, Integer sysType);
|
||||
|
||||
/**
|
||||
* 检查用户登录
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public AuthUser checkLogin(final UserLoginForm userLoginForm);
|
||||
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
package com.greatwall.business.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.redstar.auth.mo.UserMo;
|
||||
import com.redstar.auth.service.UserService;
|
||||
import com.redstar.auth.vo.AuthSession;
|
||||
import com.redstar.auth.vo.AuthUser;
|
||||
import com.redstar.common.constant.PreSetRoleConstant;
|
||||
import com.redstar.common.constant.UserConstants;
|
||||
import com.redstar.common.service.RedisService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* Created by fangzhipeng on 2017/5/10.
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class UserServiceDetail implements UserDetailsService {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
Long loadStart = System.currentTimeMillis();
|
||||
AuthSession authSession = (AuthSession)redisService.get(username);
|
||||
AuthUser authUser = new AuthUser();
|
||||
authUser.setUserType(authSession.getUserType());
|
||||
UserMo userMo = userService.getUserMo(username);
|
||||
|
||||
BeanUtils.copyProperties(userMo, authUser);
|
||||
if(authUser.getMobile()==null){
|
||||
authUser.setMobile(username.substring(0,username.length()-1));
|
||||
}
|
||||
// 载入用户角色,权限
|
||||
Set<GrantedAuthority> roles =
|
||||
userService.loadUserRole(userMo.getUid(), authSession.getEnterpriseId(), authSession.getUserType());
|
||||
Boolean isAdmin = false;
|
||||
if (null != roles && roles.size() > 0) {
|
||||
for (GrantedAuthority grantedAuthority : roles) {
|
||||
if ((PreSetRoleConstant.ROLE_PREFIX + PreSetRoleConstant.ADMIN_ENTERPRISE)
|
||||
.equals(grantedAuthority.getAuthority())) {
|
||||
isAdmin = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<GrantedAuthority> roleAuthorities = new HashSet<>();
|
||||
List<String> authorities = new ArrayList<>();
|
||||
roles.stream().forEach(role -> {
|
||||
authorities.add(role.getAuthority());
|
||||
roleAuthorities.add(new SimpleGrantedAuthority(role.getAuthority()));
|
||||
});
|
||||
Long start = System.currentTimeMillis();
|
||||
if (!isAdmin || authSession.getUserType() != UserConstants.USER_TYPE_NORMAL.intValue()) {
|
||||
Set<GrantedAuthority> auths = userService.loadUserAuthority(userMo.getUid(), authSession.getEnterpriseId(),
|
||||
authSession.getUserType(), isAdmin);
|
||||
auths.stream().forEach(p -> {
|
||||
authorities.add(p.getAuthority());
|
||||
});
|
||||
}
|
||||
authUser.setAuthorities(roleAuthorities);
|
||||
authUser.setPassword(authSession.getPassword());
|
||||
redisService.put(username + "AUTH", authorities);
|
||||
return authUser;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
package com.redstar.auth.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.redstar.common.service.RedisService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.security.oauth2.common.exceptions.InvalidClientException;
|
||||
import org.springframework.security.oauth2.provider.ClientDetails;
|
||||
import org.springframework.security.oauth2.provider.client.BaseClientDetails;
|
||||
import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* @author Yuuki
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RedisClientDetailsService extends JdbcClientDetailsService {
|
||||
/**
|
||||
* 缓存 client的 redis key,这里是 hash结构存储
|
||||
*/
|
||||
private static final String CACHE_CLIENT_KEY = "client_details";
|
||||
|
||||
private final RedisService redisService;
|
||||
|
||||
public RedisClientDetailsService(DataSource dataSource, RedisService redisService) {
|
||||
super(dataSource);
|
||||
this.redisService = redisService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientDetails loadClientByClientId(String clientId) throws InvalidClientException {
|
||||
ClientDetails clientDetails = null;
|
||||
String value = (String) redisService.hget(CACHE_CLIENT_KEY, clientId);
|
||||
if (StringUtils.isBlank(value)) {
|
||||
clientDetails = cacheAndGetClient(clientId);
|
||||
} else {
|
||||
clientDetails = JSONObject.parseObject(value, BaseClientDetails.class);
|
||||
}
|
||||
|
||||
return clientDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存 client并返回 client
|
||||
*
|
||||
* @param clientId clientId
|
||||
*/
|
||||
public ClientDetails cacheAndGetClient(String clientId) {
|
||||
ClientDetails clientDetails = null;
|
||||
clientDetails = super.loadClientByClientId(clientId);
|
||||
if (clientDetails != null) {
|
||||
redisService.hset(CACHE_CLIENT_KEY, clientId, JSONObject.toJSONString(clientDetails));
|
||||
}
|
||||
return clientDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 redis缓存
|
||||
*
|
||||
* @param clientId clientId
|
||||
*/
|
||||
public void removeRedisCache(String clientId) {
|
||||
redisService.hdel(CACHE_CLIENT_KEY, clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 oauth_client_details全表刷入 redis
|
||||
*/
|
||||
public void loadAllClientToCache() {
|
||||
if (redisService.hasKey(CACHE_CLIENT_KEY)) {
|
||||
return;
|
||||
}
|
||||
log.info("将oauth_client_details全表刷入redis");
|
||||
|
||||
List<ClientDetails> list = super.listClientDetails();
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
log.error("oauth_client_details表数据为空,请检查");
|
||||
return;
|
||||
}
|
||||
list.forEach(client -> redisService.hset(CACHE_CLIENT_KEY, client.getClientId(), JSONObject.toJSONString(client)));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,214 +0,0 @@
|
|||
package com.redstar.auth.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import com.redstar.auth.mapper.UserMenuMapper;
|
||||
import com.redstar.auth.mo.UserMenuMo;
|
||||
import com.redstar.auth.service.UserMenuService;
|
||||
import com.redstar.common.constant.CommonConstants;
|
||||
import com.redstar.common.constant.UserConstants;
|
||||
import com.redstar.common.constant.UserMenuConstants;
|
||||
import com.redstar.common.service.impl.BaseServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class UserMenuServiceImpl extends BaseServiceImpl<UserMenuMapper, UserMenuMo> implements UserMenuService {
|
||||
|
||||
@Autowired
|
||||
UserMenuMapper userMenuMapper;
|
||||
|
||||
@Autowired
|
||||
UserMenuService userMenuService;
|
||||
|
||||
@Override
|
||||
public List<UserMenuMo> listUserHasMenu(Long uid, Long enterpriseId, Integer sysType, Boolean isAdmin) {
|
||||
// 先查询用户是不是adminroot
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("user_menu.sys_type", sysType);
|
||||
queryWrapper.eq("is_enabled", CommonConstants.BOOLEAN.TRUE);
|
||||
List<UserMenuMo> userMenuList = new ArrayList<>();
|
||||
List<UserMenuMo> resultMenuList = new ArrayList<>();
|
||||
List<UserMenuMo> allUserMenuList = new ArrayList<>();
|
||||
List<UserMenuMo> allMenuList = userMenuMapper.selectList(queryWrapper);
|
||||
if(sysType.intValue() != UserConstants.USER_TYPE_ADMIN) {
|
||||
allUserMenuList.addAll(listEnterpriseMenu(enterpriseId, sysType, allMenuList));
|
||||
}else{
|
||||
allUserMenuList.addAll(allMenuList);
|
||||
}
|
||||
// 如果不是管理员,则需要查询出用户拥有的菜单,并进行过滤
|
||||
if (isAdmin) {
|
||||
resultMenuList.addAll(allUserMenuList);
|
||||
} else {
|
||||
//获取用户对应的用户菜单
|
||||
userMenuList= findUserMenuListByUserAndGroup(uid,enterpriseId,sysType);
|
||||
// 用户所拥有的菜单权限,不能超过企业拥有的权限
|
||||
resultMenuList.addAll(userMenuList.stream().filter(item -> {
|
||||
for (UserMenuMo userMenuMo : allUserMenuList) {
|
||||
if (userMenuMo.getId().equals(item.getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
// 这里需要将父节点选中的所有子节点添加进来
|
||||
// 将只有子节点选中的父节点添加进来
|
||||
// 注意这里不能替换顺序
|
||||
List<UserMenuMo> canReturnList = new ArrayList<>();
|
||||
List<UserMenuMo> resultList = new ArrayList<>();
|
||||
canReturnList.addAll(getCheckedChildList(allUserMenuList, resultMenuList));
|
||||
canReturnList.addAll(getCheckedParentList(allUserMenuList, resultMenuList));
|
||||
for (UserMenuMo userMenuMo : allUserMenuList) {
|
||||
Boolean flag = false;
|
||||
for (UserMenuMo canReturnMo : canReturnList) {
|
||||
if (canReturnMo.getId().equals(userMenuMo.getId())) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
resultList.add(userMenuMo);
|
||||
}
|
||||
}
|
||||
resultList = resultList.stream()
|
||||
.collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(UserMenuMo::getId))), ArrayList::new));
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private List<UserMenuMo> findUserMenuListByUserAndGroup(Long uid, Long enterpriseId, Integer sysType){
|
||||
List<UserMenuMo> userMenuList = new ArrayList<>();
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("user_menu.sys_type", sysType);
|
||||
queryWrapper.eq("is_enabled", CommonConstants.BOOLEAN.TRUE);
|
||||
queryWrapper.eq(" user_role_mapping.uid", uid);
|
||||
if (sysType.intValue() == UserConstants.USER_TYPE_ADMIN) {
|
||||
queryWrapper.eq("user_role.sys_type", UserConstants.USER_TYPE_ADMIN);
|
||||
} else {
|
||||
queryWrapper.ne("user_role.sys_type", UserConstants.USER_TYPE_ADMIN);
|
||||
}
|
||||
queryWrapper.eq("user_role_mapping.enterprise_id", enterpriseId);
|
||||
queryWrapper.groupBy("user_menu.id");
|
||||
userMenuList.addAll(userMenuMapper.listByUser(queryWrapper));
|
||||
userMenuList.addAll(userMenuMapper.listByGroupUser(uid,enterpriseId,sysType));
|
||||
userMenuList = userMenuList.stream()
|
||||
.collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(UserMenuMo::getId))), ArrayList::new));
|
||||
return userMenuList;
|
||||
}
|
||||
|
||||
public List<UserMenuMo> listEnterpriseMenu ( Long enterpriseId, Integer sysType, List<UserMenuMo> allMenuList) {
|
||||
List<UserMenuMo> enterpriseCanAddMenuList = new ArrayList<>();
|
||||
// 获取企业对应的所有菜单
|
||||
List<UserMenuMo> enterpriseMenuMos = userMenuMapper.listByEnterprise(enterpriseId,sysType);
|
||||
//获取子菜单对应的父菜单
|
||||
enterpriseCanAddMenuList.addAll(userMenuService.getCheckedChildList(allMenuList, enterpriseMenuMos));
|
||||
enterpriseCanAddMenuList.addAll(userMenuService.getCheckedParentList(allMenuList, enterpriseMenuMos));
|
||||
enterpriseCanAddMenuList.addAll(enterpriseMenuMos);
|
||||
enterpriseCanAddMenuList = enterpriseCanAddMenuList.stream()
|
||||
.collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(UserMenuMo::getId))), ArrayList::new));
|
||||
return enterpriseCanAddMenuList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取选中节点的父节点
|
||||
*
|
||||
* @param allMenuList
|
||||
* @param userMenuList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<UserMenuMo> getCheckedParentList(List<UserMenuMo> allMenuList, List<UserMenuMo> userMenuList) {
|
||||
List<UserMenuMo> parentList = new ArrayList<>();
|
||||
for (UserMenuMo userMenuMo : userMenuList) {
|
||||
List<UserMenuMo> userMenuMos = getAllParentList(allMenuList, userMenuMo);
|
||||
parentList.addAll(userMenuMos);
|
||||
}
|
||||
parentList = parentList.stream()
|
||||
.collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(UserMenuMo::getId))), ArrayList::new));
|
||||
return parentList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子节点选中的节点
|
||||
*
|
||||
* @param allMenuList
|
||||
* @param userMenuList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<UserMenuMo> getCheckedChildList(List<UserMenuMo> allMenuList, List<UserMenuMo> userMenuList) {
|
||||
Set<UserMenuMo> resultSet = new LinkedHashSet<>();
|
||||
List<UserMenuMo> childList = new ArrayList<>();
|
||||
for (UserMenuMo userMenuMo : allMenuList) {
|
||||
for (UserMenuMo menuMo : userMenuList) {
|
||||
if (userMenuMo.getId().intValue() == menuMo.getId().intValue()) {
|
||||
resultSet.add(userMenuMo);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<UserMenuMo> parentList = resultSet.stream().filter(item -> {
|
||||
return item.getType().intValue() == UserMenuConstants.TYPE.MENU;
|
||||
}).collect(Collectors.toList());
|
||||
for (UserMenuMo userMenuMo : parentList) {
|
||||
List<UserMenuMo> userMenuMos = getAllChildList(allMenuList, userMenuMo.getId());
|
||||
childList.addAll(userMenuMos);
|
||||
}
|
||||
resultSet.addAll(childList);
|
||||
List<UserMenuMo> disctChildList= resultSet.stream().collect(Collectors.toList()).stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
|
||||
new TreeSet<>(Comparator.comparing(UserMenuMo::getId))), ArrayList::new));
|
||||
return disctChildList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定ID的所有子节点
|
||||
*
|
||||
* @param allMenuList
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private List<UserMenuMo> getAllChildList(List<UserMenuMo> allMenuList, Long id) {
|
||||
List<UserMenuMo> childMenuList = allMenuList.stream().filter(item -> {
|
||||
if (item.getParentId() == null) {
|
||||
return false;
|
||||
}
|
||||
return item.getParentId().intValue() == id;
|
||||
}).collect(Collectors.toList());
|
||||
List<UserMenuMo> childChildMenuList = new ArrayList<>();
|
||||
for (UserMenuMo userMenuMo : childMenuList) {
|
||||
childChildMenuList.addAll(getAllChildList(allMenuList, userMenuMo.getId()));
|
||||
}
|
||||
childMenuList.addAll(childChildMenuList);
|
||||
return childMenuList;
|
||||
}
|
||||
|
||||
private List<UserMenuMo> getAllParentList(List<UserMenuMo> allMenuList, UserMenuMo userMenuMo) {
|
||||
if (userMenuMo.getParentId() == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<UserMenuMo> parentList = new ArrayList<>();
|
||||
for (UserMenuMo menuMo : allMenuList) {
|
||||
if (menuMo.getType().intValue() == UserMenuConstants.TYPE.MENU
|
||||
&& userMenuMo.getParentId().equals(menuMo.getId())) {
|
||||
parentList.add(menuMo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<UserMenuMo> parentParentList = new ArrayList<>();
|
||||
for (UserMenuMo menuMo : parentList) {
|
||||
parentParentList.addAll(getAllParentList(allMenuList, menuMo));
|
||||
}
|
||||
parentList.addAll(parentParentList);
|
||||
return parentList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
package com.redstar.auth.service.impl;
|
||||
|
||||
import com.redstar.auth.mo.UserMo;
|
||||
import com.redstar.auth.service.UserService;
|
||||
import com.redstar.auth.vo.AuthSession;
|
||||
import com.redstar.auth.vo.AuthUser;
|
||||
import com.redstar.common.constant.PreSetRoleConstant;
|
||||
import com.redstar.common.constant.UserConstants;
|
||||
import com.redstar.common.service.RedisService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by fangzhipeng on 2017/5/10.
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class UserServiceDetailImpl implements UserDetailsService {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
@Autowired
|
||||
RedisService redisService;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
Long loadStart = System.currentTimeMillis();
|
||||
AuthSession authSession = (AuthSession)redisService.get(username);
|
||||
AuthUser authUser = new AuthUser();
|
||||
authUser.setUserType(authSession.getUserType());
|
||||
UserMo userMo = userService.getUserMo(username);
|
||||
|
||||
BeanUtils.copyProperties(userMo, authUser);
|
||||
if(authUser.getMobile()==null){
|
||||
authUser.setMobile(username.substring(0,username.length()-1));
|
||||
}
|
||||
// 载入用户角色,权限
|
||||
Set<GrantedAuthority> roles =
|
||||
userService.loadUserRole(userMo.getUid(), authSession.getEnterpriseId(), authSession.getUserType());
|
||||
Boolean isAdmin = false;
|
||||
if (null != roles && roles.size() > 0) {
|
||||
for (GrantedAuthority grantedAuthority : roles) {
|
||||
if ((PreSetRoleConstant.ROLE_PREFIX + PreSetRoleConstant.ADMIN_ENTERPRISE)
|
||||
.equals(grantedAuthority.getAuthority())) {
|
||||
isAdmin = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<GrantedAuthority> roleAuthorities = new HashSet<>();
|
||||
List<String> authorities = new ArrayList<>();
|
||||
roles.stream().forEach(role -> {
|
||||
authorities.add(role.getAuthority());
|
||||
roleAuthorities.add(new SimpleGrantedAuthority(role.getAuthority()));
|
||||
});
|
||||
Long start = System.currentTimeMillis();
|
||||
if (!isAdmin || authSession.getUserType() != UserConstants.USER_TYPE_NORMAL.intValue()) {
|
||||
Set<GrantedAuthority> auths = userService.loadUserAuthority(userMo.getUid(), authSession.getEnterpriseId(),
|
||||
authSession.getUserType(), isAdmin);
|
||||
auths.stream().forEach(p -> {
|
||||
authorities.add(p.getAuthority());
|
||||
});
|
||||
}
|
||||
authUser.setAuthorities(roleAuthorities);
|
||||
authUser.setPassword(authSession.getPassword());
|
||||
redisService.put(username + "AUTH", authorities);
|
||||
return authUser;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,187 +0,0 @@
|
|||
package com.redstar.auth.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.redstar.auth.form.UserLoginForm;
|
||||
import com.redstar.auth.mapper.UserMapper;
|
||||
import com.redstar.auth.mapper.UserRoleMapper;
|
||||
import com.redstar.auth.mo.UserMenuMo;
|
||||
import com.redstar.auth.mo.UserMo;
|
||||
import com.redstar.auth.mo.UserRoleMo;
|
||||
import com.redstar.auth.service.UserMenuService;
|
||||
import com.redstar.auth.service.UserService;
|
||||
import com.redstar.auth.vo.AuthUser;
|
||||
import com.redstar.common.constant.PreSetRoleConstant;
|
||||
import com.redstar.common.constant.UserConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Date: 2019/7/6 20:58
|
||||
* @Description: 用户新增业务实现类
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, UserMo> implements UserService {
|
||||
|
||||
/**
|
||||
* POI支持最多导出的行数
|
||||
*/
|
||||
private static final Integer POI_MAX_ROWS = 1048576;
|
||||
|
||||
/**
|
||||
* excel表格的数据行是从第几行开始
|
||||
*/
|
||||
private static final int EXCEL_DATA_NUM = 2;
|
||||
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Resource
|
||||
private UserRoleMapper userRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private UserMenuService userMenuService;
|
||||
|
||||
/**
|
||||
* 载入所有用户权限, 数据库存储
|
||||
*
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
public Set<GrantedAuthority> loadUserAuthority(final Long uid, Long enterpriseId, Integer sysType,
|
||||
Boolean isAdmin) {
|
||||
List<UserMenuMo> userMenuMos = userMenuService.listUserHasMenu(uid, enterpriseId, sysType, isAdmin);
|
||||
final Set<String> authorityStringList = userMenuMos.stream().map(item -> {
|
||||
return item.getAuthority();
|
||||
}).collect(Collectors.toSet());
|
||||
final Set<GrantedAuthority> authorities = new HashSet<>();
|
||||
if (authorityStringList != null && authorityStringList.size() > 0) {
|
||||
for (final String authorityString : authorityStringList) {
|
||||
if (StringUtils.isNotEmpty(authorityString)) {
|
||||
authorities.add(new SimpleGrantedAuthority(authorityString));
|
||||
}
|
||||
}
|
||||
}
|
||||
return authorities;
|
||||
}
|
||||
|
||||
/**
|
||||
* 载入用户所有角色, 数据库存储约定 ROLE_ 开头,大写
|
||||
*
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
public Set<GrantedAuthority> loadUserRole(final Long uid, Long enterpriseId, Integer sysType) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
if (sysType.intValue() == UserConstants.USER_TYPE_ADMIN) {
|
||||
queryWrapper.eq("r.sys_type", UserConstants.USER_TYPE_ADMIN);
|
||||
} else {
|
||||
queryWrapper.ne("r.sys_type", UserConstants.USER_TYPE_ADMIN);
|
||||
}
|
||||
queryWrapper.eq("rm.uid", uid);
|
||||
queryWrapper.eq("rm.enterprise_id", enterpriseId);
|
||||
final Set<String> roleStringList = userMapper.selectRoleByUid(queryWrapper);
|
||||
final Set<String> groupRoleStringList = userMapper.selectRoleByGroup(uid, enterpriseId, sysType);
|
||||
roleStringList.addAll(groupRoleStringList);
|
||||
final List<String> roleTargetStringList = new ArrayList<String>();
|
||||
// 企业最大角色列表
|
||||
List<UserRoleMo> enterpriseRoleList = userRoleMapper.listEnterpriseRole(enterpriseId, sysType);
|
||||
UserRoleMo defalutMo = new UserRoleMo();
|
||||
defalutMo.setRole(PreSetRoleConstant.ROLE_PREFIX + PreSetRoleConstant.ADMIN_ENTERPRISE);
|
||||
enterpriseRoleList.add(defalutMo);
|
||||
UserRoleMo defalutMo2 = new UserRoleMo();
|
||||
defalutMo2.setRole(PreSetRoleConstant.ROLE_PREFIX + PreSetRoleConstant.ADMIN_ROOT);
|
||||
enterpriseRoleList.add(defalutMo2);
|
||||
roleTargetStringList.addAll(enterpriseRoleList.stream().filter(item -> {
|
||||
for (String role : roleStringList) {
|
||||
if (role.equals(item.getRole())
|
||||
|| role.equals(PreSetRoleConstant.ROLE_PREFIX + PreSetRoleConstant.ADMIN_ENTERPRISE)
|
||||
|| role.equals(PreSetRoleConstant.ROLE_PREFIX + PreSetRoleConstant.ADMIN_ROOT)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).map(it -> it.getRole()).collect(Collectors.toList()));
|
||||
|
||||
final Set<GrantedAuthority> roles = new HashSet<>();
|
||||
if (roleTargetStringList != null && roleTargetStringList.size() > 0) {
|
||||
for (final String roleString : roleTargetStringList) {
|
||||
roles.add(new SimpleGrantedAuthority(roleString));
|
||||
}
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据电话号码判断某个用户是否存在
|
||||
*
|
||||
* @param mobile
|
||||
* 手机号码
|
||||
* @return
|
||||
*/
|
||||
private UserMo getUserMoByMobile(final String mobile) {
|
||||
final Date startTime = new Date();
|
||||
final QueryWrapper<UserMo> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(true, UserMo::getMobile, mobile);
|
||||
final UserMo userMo = userMapper.selectOne(wrapper);
|
||||
final Date endTime = new Date();
|
||||
log.debug("根据手机号码获取用户耗时: " + (endTime.getTime() - startTime.getTime()));
|
||||
return userMo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据mac地址判断某个用户是否存在
|
||||
*
|
||||
* @param mac
|
||||
* 手机号码
|
||||
* @return
|
||||
*/
|
||||
private UserMo getUserMoByMac(final String mac) {
|
||||
LambdaQueryWrapper<UserMo> lambdaQueryWrapper = new LambdaQueryWrapper();
|
||||
lambdaQueryWrapper.eq(UserMo::getMac, mac);
|
||||
final UserMo userMo = userMapper.selectOne(lambdaQueryWrapper);
|
||||
return userMo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMo getUserMo(String username) {
|
||||
UserMo userMo = null;
|
||||
if (isNumber(username)) {
|
||||
// 手机号码登录
|
||||
userMo = this.getUserMoByMobile(username.substring(0, 11));
|
||||
} else {
|
||||
// MAC 地址登录
|
||||
userMo = this.getUserMoByMac(username.substring(0, username.length() - 1));
|
||||
}
|
||||
return userMo;
|
||||
}
|
||||
|
||||
public static boolean isNumber(String string) {
|
||||
if (string == null)
|
||||
return false;
|
||||
Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$");
|
||||
return pattern.matcher(string).matches();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AuthUser checkLogin(final UserLoginForm userLoginForm) {
|
||||
log.info("=============== 用户" + userLoginForm.getMobile() + "开始登录 ====================");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
package com.redstar.auth.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class AuthSession implements Serializable {
|
||||
private Long enterpriseId;// 企业ID
|
||||
private Integer userType;
|
||||
private Integer loginType;
|
||||
private Long uid;// 企业管理员用户ID
|
||||
private Long selfUid;// 用户ID 不区分企业
|
||||
private String nickName;
|
||||
private String selfNickName;
|
||||
private String mobile;
|
||||
private String password;
|
||||
private String name;
|
||||
private Integer sex;
|
||||
private String avatar;
|
||||
private Integer status;
|
||||
private String email;
|
||||
private Long personalId;// 用户账号id
|
||||
private Date lastLoginTime;
|
||||
private Date createTime;
|
||||
private String enterpriseName;// 企业名称
|
||||
private Integer platform; // 标识平台:1.zstack,2.openstack
|
||||
/**
|
||||
* 企业用户姓名
|
||||
*/
|
||||
private String enterpriseUsername;
|
||||
private String profile;// 个人简介
|
||||
private String position;// 职位
|
||||
/**
|
||||
* 真实的自身UID
|
||||
*/
|
||||
private Long realSelfUid;
|
||||
private Boolean isEnterpriseLogin = false; // 是否是企业登录
|
||||
private boolean isOfEnterpriseUser = false;// 是否是企业用户
|
||||
private boolean hasEnterprise = false;// 是否关联企业
|
||||
|
||||
/**
|
||||
* 用户是否有原始密码
|
||||
*/
|
||||
private Boolean isHasPassword;
|
||||
|
||||
/**
|
||||
* 是否用户绑定微信
|
||||
*/
|
||||
private Boolean isBindWechat;
|
||||
|
||||
/**
|
||||
* 用户身份认证状态
|
||||
*/
|
||||
private Integer identitificationStatus;
|
||||
|
||||
/**
|
||||
* 区域
|
||||
*/
|
||||
private String region;
|
||||
/**
|
||||
* 确实ID
|
||||
*/
|
||||
private String trustieOpenId;
|
||||
}
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
package com.redstar.auth.vo;
|
||||
|
||||
import com.redstar.common.constant.UserConstants;
|
||||
import com.redstar.common.vo.result.JWT;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class AuthUser implements UserDetails, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JWT jwt;
|
||||
private Long id;
|
||||
private String wxOpenId;
|
||||
private Long uid;// 企业管理员用户ID
|
||||
private Long selfUid;// 用户ID 不区分企业
|
||||
private String mobile;
|
||||
private String nickName;
|
||||
private String password;
|
||||
private String name;
|
||||
private Integer sex;
|
||||
private String avatar;
|
||||
private Integer status;
|
||||
private String email;
|
||||
private Long personalId;// 用户账号id
|
||||
private Date lastLoginTime;
|
||||
private Date createTime;
|
||||
private Long enterpriseId;// 企业ID
|
||||
private String enterpriseName;// 企业名称
|
||||
private String profile;// 个人简介
|
||||
private String position;// 职位
|
||||
/**
|
||||
* 企业用户姓名
|
||||
*/
|
||||
private String enterpriseUsername;
|
||||
private Set<GrantedAuthority> roles;// 用户角色
|
||||
private Set<GrantedAuthority> authorities;// 用户权限
|
||||
private List<String> authoritiesList;// 用户权限
|
||||
private boolean isOfEnterpriseUser = false;// 是否是企业用户
|
||||
private boolean hasEnterprise = false;// 是否关联企业
|
||||
private Boolean isEnterpriseLogin = false; // 是否是企业登录
|
||||
private String url; // 302 重定向地址
|
||||
|
||||
/**
|
||||
* 用户登陆系统类型 USER_TYPE_ADMIN 1 后台管理员 USER_TYPE_NORMAL 2 门户 USER_TYPE_ENTERPRISE 3 企业
|
||||
*/
|
||||
private Integer userType;
|
||||
|
||||
private Integer loginType= UserConstants.LOGIN_TYPE.MOBILE;
|
||||
|
||||
/**
|
||||
* 用户是否有原始密码
|
||||
*/
|
||||
private Boolean isHasPassword;
|
||||
|
||||
/**
|
||||
* 是否用户绑定微信
|
||||
*/
|
||||
private Boolean isBindWechat;
|
||||
|
||||
/**
|
||||
* 用户身份认证状态
|
||||
*/
|
||||
private Integer identitificationStatus;
|
||||
|
||||
/**
|
||||
* 真实的自身UID
|
||||
*/
|
||||
private Long realSelfUid;
|
||||
|
||||
public void setUid(Long uid) {
|
||||
this.uid = uid;
|
||||
this.id = uid;
|
||||
}
|
||||
|
||||
public void setWxOpenId(String wxOpenId) {
|
||||
this.wxOpenId = null;
|
||||
this.isBindWechat = !StringUtils.isEmpty(wxOpenId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
// 自定义userInfo hashCode方法,session管理时会用做key
|
||||
return mobile.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof AuthUser) {
|
||||
AuthUser userSessionVo = (AuthUser)obj;
|
||||
return new EqualsBuilder().append(userSessionVo.getId(), id).append(userSessionVo.getUid(), uid)
|
||||
.append(userSessionVo.getName(), name).isEquals();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return authorities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return mobile + userType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
<?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.redstar.auth.mapper.UserMapper">
|
||||
|
||||
<select id="selectRoleByUid" resultType="java.lang.String">
|
||||
SELECT DISTINCT
|
||||
( r.role )
|
||||
FROM
|
||||
user_role r
|
||||
LEFT JOIN user_role_mapping rm ON r.id = rm.user_role_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectRoleByGroup" resultType="java.lang.String">
|
||||
SELECT DISTINCT
|
||||
( user_role.role )
|
||||
FROM
|
||||
user_role
|
||||
where user_role.id IN ( SELECT role_id FROM user_group_mapping LEFT JOIN user_group_role_mapping
|
||||
ON user_group_mapping.group_id = user_group_role_mapping.group_id
|
||||
where user_group_mapping.uid =#{uid} and user_group_mapping.enterprise_id =#{enterpriseId} and user_group_mapping.sys_type= #{sysType} )
|
||||
and user_role.sys_type= #{sysType}
|
||||
</select>
|
||||
|
||||
<select id="selectAuthorityByUid" resultType="java.lang.String">
|
||||
SELECT DISTINCT
|
||||
( a.authority )
|
||||
FROM
|
||||
user_menu a
|
||||
LEFT JOIN user_role_authority_mapping ram ON ram.user_authority_id = a.id
|
||||
LEFT JOIN user_role r ON r.id = ram.user_role_id
|
||||
LEFT JOIN user_role_mapping rm ON rm.user_role_id = r.id
|
||||
WHERE
|
||||
rm.uid = #{uid, jdbcType=INTEGER}
|
||||
<if test="enterpriseId != null ">
|
||||
and rm.enterprise_id = #{enterpriseId, jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="sysType != null and sysType != '' ">
|
||||
and a.sys_type = #{sysType,jdbcType=INTEGER}
|
||||
</if>
|
||||
and a.type=2
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
<?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.redstar.auth.mapper.UserMenuMapper">
|
||||
<select id="listByUser" resultType="com.redstar.auth.mo.UserMenuMo">
|
||||
SELECT
|
||||
user_menu.id,
|
||||
user_menu.`name`,
|
||||
user_menu.default_url,
|
||||
user_menu.authority,
|
||||
user_menu.parent_id,
|
||||
user_menu.is_enabled,
|
||||
user_menu.icon,
|
||||
user_menu.sequence,
|
||||
user_menu.is_new_window,
|
||||
user_menu.is_full_screen,
|
||||
user_menu.create_time,
|
||||
user_menu.component,
|
||||
user_menu.type,
|
||||
user_menu.sys_type,
|
||||
user_role_authority_mapping.user_authority_id,
|
||||
user_role_authority_mapping.user_role_id,
|
||||
user_role.id,
|
||||
user_role.role,
|
||||
user_role.enterprise_id,
|
||||
user_role_mapping.user_role_id,
|
||||
user_role_mapping.uid
|
||||
FROM
|
||||
user_menu
|
||||
LEFT JOIN user_role_authority_mapping ON user_role_authority_mapping.user_authority_id = user_menu.id
|
||||
LEFT JOIN user_role ON user_role.id = user_role_authority_mapping.user_role_id
|
||||
LEFT JOIN user_role_mapping user_role_mapping ON user_role_mapping.user_role_id = user_role.id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="listByGroupUser" resultType="com.redstar.auth.mo.UserMenuMo">
|
||||
SELECT
|
||||
user_menu.id,
|
||||
user_menu.`name`,
|
||||
user_menu.default_url,
|
||||
user_menu.authority,
|
||||
user_menu.parent_id,
|
||||
user_menu.is_enabled,
|
||||
user_menu.icon,
|
||||
user_menu.sequence,
|
||||
user_menu.is_new_window,
|
||||
user_menu.is_full_screen,
|
||||
user_menu.create_time,
|
||||
user_menu.component,
|
||||
user_menu.type,
|
||||
user_menu.sys_type,
|
||||
user_role_authority_mapping.user_authority_id,
|
||||
user_role_authority_mapping.user_role_id,
|
||||
user_role.id,
|
||||
user_role.role,
|
||||
user_role.enterprise_id,
|
||||
user_role_mapping.user_role_id,
|
||||
user_role_mapping.uid
|
||||
FROM
|
||||
user_menu
|
||||
LEFT JOIN user_role_authority_mapping ON user_role_authority_mapping.user_authority_id = user_menu.id
|
||||
LEFT JOIN user_role ON user_role.id = user_role_authority_mapping.user_role_id
|
||||
LEFT JOIN user_role_mapping user_role_mapping ON user_role_mapping.user_role_id = user_role.id
|
||||
where user_role.id IN ( SELECT role_id FROM user_group_mapping LEFT JOIN user_group_role_mapping
|
||||
ON user_group_mapping.group_id = user_group_role_mapping.group_id
|
||||
where user_group_mapping.uid =#{uid} and user_group_mapping.enterprise_id =#{enterpriseId} and user_group_mapping.sys_type= #{sysType} )
|
||||
and user_role.sys_type= #{sysType}
|
||||
GROUP BY user_menu.id
|
||||
</select>
|
||||
|
||||
<select id="listByEnterprise" resultType="com.redstar.auth.mo.UserMenuMo">
|
||||
SELECT
|
||||
user_menu.id,
|
||||
user_menu.`name`,
|
||||
user_menu.default_url,
|
||||
user_menu.authority,
|
||||
user_menu.parent_id,
|
||||
user_menu.is_enabled,
|
||||
user_menu.icon,
|
||||
user_menu.sequence,
|
||||
user_menu.is_new_window,
|
||||
user_menu.is_full_screen,
|
||||
user_menu.create_time,
|
||||
user_menu.component,
|
||||
user_menu.type,
|
||||
user_role.sys_type,
|
||||
user_role_authority_mapping.user_authority_id,
|
||||
user_role_authority_mapping.user_role_id,
|
||||
user_role.id,
|
||||
user_role.role,
|
||||
user_role.enterprise_id,
|
||||
user_role_mapping.user_role_id,
|
||||
user_role_mapping.uid
|
||||
FROM
|
||||
user_menu
|
||||
LEFT JOIN user_role_authority_mapping ON user_role_authority_mapping.user_authority_id = user_menu.id
|
||||
LEFT JOIN user_role ON user_role.id = user_role_authority_mapping.user_role_id
|
||||
LEFT JOIN user_role_mapping user_role_mapping ON user_role_mapping.user_role_id = user_role.id
|
||||
where user_role.id IN ( SELECT role_id FROM enterprise_group_mapping LEFT JOIN enterprise_group_role_mapping
|
||||
ON enterprise_group_mapping.group_id = enterprise_group_role_mapping.group_id
|
||||
where enterprise_group_mapping.enterprise_id =#{enterpriseId} ) and user_role.sys_type= #{sysType}
|
||||
GROUP BY user_menu.id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
<?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.redstar.auth.mapper.UserRoleMapper">
|
||||
|
||||
<select id="listEnterpriseRole" resultType="com.redstar.auth.mo.UserRoleMo">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
user_role
|
||||
WHERE
|
||||
<if test="sysType !=1">
|
||||
id IN ( SELECT role_id FROM enterprise_group_mapping LEFT JOIN enterprise_group_role_mapping
|
||||
ON enterprise_group_mapping.group_id = enterprise_group_role_mapping.group_id
|
||||
WHERE enterprise_id = #{enterpriseId} ) AND user_role.sys_type = #{sysType}
|
||||
</if>
|
||||
<if test="sysType ==1">
|
||||
user_role.sys_type = 1
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
<% include("/common/css.html"){} %>
|
||||
</head>
|
||||
<body>
|
||||
<% include("/common/header.html"){} %>
|
||||
<div class="mblock">
|
||||
<div class="panel">
|
||||
<div class="title">用户登录</div>
|
||||
<div class="content">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% include("/common/footer.html"){} %>
|
||||
<% include("/common/js.html"){} %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
<% include("/common/css.html"){} %>
|
||||
</head>
|
||||
<body>
|
||||
<% include("/common/header.html"){} %>
|
||||
<div class="mblock">
|
||||
<div class="panel">
|
||||
<div class="title">用户登出</div>
|
||||
<div class="content">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% include("/common/footer.html"){} %>
|
||||
<% include("/common/js.html"){} %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<div class="footer clear">
|
||||
CopyRight 2018 星空下の花生 页面执行耗时${executeTime!0}毫秒
|
||||
</div>
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<% include("/common/js.html"){} %>
|
||||
<meta charset="UTF-8">
|
||||
<title>测试桩</title>
|
||||
</head>
|
||||
<body>
|
||||
<div align="center">
|
||||
<h2 align="center">测试桩</h2>
|
||||
<table>
|
||||
<tr align="right">
|
||||
<td>请输入手机号:</td>
|
||||
<td><input type="text" id="mobile"></td>
|
||||
<td><input type="button" value = "查询注册验证码" id="registerBtn"></td>
|
||||
<td><input type="button" value="查询重置验证码" id="findPwdBtn"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">验证码:</td>
|
||||
<td><input type="text" id="code"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
package business.book.listener;
|
||||
|
||||
@Slf4j
|
||||
//有个很重要的点 DirMoListener 不能被spring管理,要每次读取excel都要new,然后里面用到spring可以构造方法传进去
|
||||
public class BookListener extends AnalysisEventListener<DirMo> {
|
||||
|
||||
/**
|
||||
* 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收
|
||||
*/
|
||||
private static final int BATCH_COUNT = 5;
|
||||
List<DirMo> list = new ArrayList<DirMo>();
|
||||
/**
|
||||
* 假设这个是一个DAO,当然有业务逻辑这个也可以是一个service。当然如果不用存储这个对象没用。
|
||||
*/
|
||||
private DemoDAO demoDAO;
|
||||
public DirMoListener() {
|
||||
// 这里是demo,所以随便new一个。实际使用如果到了spring,请使用下面的有参构造函数
|
||||
demoDAO = new DemoDAO();
|
||||
}
|
||||
/**
|
||||
* 如果使用了spring,请使用这个构造方法。每次创建Listener的时候需要把spring管理的类传进来
|
||||
*
|
||||
* @param demoDAO
|
||||
*/
|
||||
public DirMoListener(DemoDAO demoDAO) {
|
||||
this.demoDAO = demoDAO;
|
||||
}
|
||||
/**
|
||||
* 这个每一条数据解析都会来调用
|
||||
*
|
||||
* @param data
|
||||
* one row value. Is is same as {@link AnalysisContext#readRowHolder()}
|
||||
* @param context
|
||||
*/
|
||||
@Override
|
||||
public void invoke(DirMo data, AnalysisContext context) {
|
||||
log.info("解析到一条数据:{}", JSON.toJSONString(data));
|
||||
list.add(data);
|
||||
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
|
||||
if (list.size() >= BATCH_COUNT) {
|
||||
saveData();
|
||||
// 存储完成清理 list
|
||||
list.clear();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 所有数据解析完成了 都会来调用
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
|
||||
saveData();
|
||||
log.info("所有数据解析完成!");
|
||||
}
|
||||
/**
|
||||
* 加上存储数据库
|
||||
*/
|
||||
private void saveData() {
|
||||
log.info("{}条数据,开始存储数据库!", list.size());
|
||||
demoDAO.save(list);
|
||||
log.info("存储数据库成功!");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
package business.book.mo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DirMo {
|
||||
|
||||
|
||||
private String title;
|
||||
private String fileName;
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package redstar.framework.markdown;
|
||||
|
||||
public class ExcelDirTool {
|
||||
@Test
|
||||
public void simpleRead() {
|
||||
String fileName = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx";
|
||||
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
|
||||
EasyExcel.read(fileName, DemoData.class, new DemoDataListener()).sheet().doRead();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<link rel="stylesheet" type="text/css" href="${ctxPath!}/static/css/common/reset.css">
|
||||
<link rel="stylesheet" type="text/css" href="${ctxPath!}/static/css/common/common.css">
|
||||
<link rel="stylesheet" type="text/css" href="${ctxPath!}/static/css/common/header.css">
|
||||
<link rel="stylesheet" type="text/css" href="${ctxPath!}/static/css/common/footer.css">
|
||||
<link rel="stylesheet" type="text/css" href="${ctxPath!}/static/css/common/panel.css">
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<div class="footer clear">
|
||||
CopyRight 2018 星空下の花生 页面执行耗时${executeTime!0}毫秒
|
||||
</div>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<div class="header clear" >
|
||||
<i class="logo"></i><span>[红星微服务] - v1.00</span>
|
||||
</div>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
<script type="text/javascript" src="${ctxPath!}/static/js/jquery-3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src="${ctxPath!}/static/js/stub/stub.js"></script>
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
<% include("/common/css.html"){} %>
|
||||
</head>
|
||||
<body>
|
||||
<% include("/common/header.html"){} %>
|
||||
<div class="mblock">
|
||||
<div class="panel">
|
||||
<div class="title">404错误</div>
|
||||
<div class="content">
|
||||
<p>timestamp=${timestamp!}</p>
|
||||
<p>status=${status!}</p>
|
||||
<p>error=${error!}</p>
|
||||
<p>message=${message!}</p>
|
||||
<p>path=${path!}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% include("/common/footer.html"){} %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
<% include("/common/css.html"){} %>
|
||||
</head>
|
||||
<body>
|
||||
<% include("/common/header.html"){} %>
|
||||
<div class="mblock">
|
||||
<div class="panel">
|
||||
<div class="title">500错误</h1></div>
|
||||
<div class="content">
|
||||
<p>${message!}</p>
|
||||
<p>${trace!}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% include("/common/footer.html"){} %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#### 从命令行创建一个新的仓库
|
||||
|
||||
```bash
|
||||
touch README.md
|
||||
git init
|
||||
git add README.md
|
||||
git commit -m "first commit"
|
||||
git remote add origin https://git.trustie.net/greatwall/redstar.git
|
||||
git push -u origin master
|
||||
|
||||
```
|
||||
|
||||
#### 从命令行推送已经创建的仓库
|
||||
|
||||
```bash
|
||||
git remote add origin https://git.trustie.net/greatwall/redstar.git
|
||||
git push -u origin master
|
||||
|
||||
```
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue