Compare commits
No commits in common. "main" and "bf9b1abec65878581c4a79e703eb2769885afa2f" have entirely different histories.
main
...
bf9b1abec6
|
@ -0,0 +1,10 @@
|
|||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# GitHub Copilot persisted chat sessions
|
||||
/copilot/chatSessions
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="common-mybatis-plus" />
|
||||
<module name="hoe-auth" />
|
||||
<module name="common-web" />
|
||||
<module name="hoe-gateway" />
|
||||
<module name="admin-boot" />
|
||||
<module name="common-base" />
|
||||
<module name="hoe-order" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="admin-api" target="1.8" />
|
||||
<module name="common-redis" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="admin-api" options="-parameters" />
|
||||
<module name="admin-boot" options="-parameters" />
|
||||
<module name="common-base" options="-parameters" />
|
||||
<module name="common-mybatis-plus" options="-parameters" />
|
||||
<module name="common-redis" options="-parameters" />
|
||||
<module name="common-web" options="-parameters" />
|
||||
<module name="hoe-admin" options="" />
|
||||
<module name="hoe-auth" options="-parameters" />
|
||||
<module name="hoe-common" options="" />
|
||||
<module name="hoe-gateway" options="-parameters" />
|
||||
<module name="hoe-order" options="-parameters" />
|
||||
<module name="hoe-recovery" options="" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="hst" uuid="7e37209f-9aa5-451d-ae36-475b21bebef6">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://localhost:3306</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/hoe-admin/admin-api/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-admin/admin-boot/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-admin/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-admin/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-auth/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-common/common-base/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-common/common-base/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-common/common-mybatis-plus/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-common/common-redis/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-common/common-redis/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-common/common-web/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-common/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-gateway/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/hoe-order/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="central" />
|
||||
<option name="url" value="https://maven.aliyun.com/nexus/content/groups/public" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="rdc-releases" />
|
||||
<option name="name" value="rdc-releases" />
|
||||
<option name="url" value="https://packages.aliyun.com/maven/repository/2129281-release-rn0pJN/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="rdc-snapshots" />
|
||||
<option name="name" value="rdc-snapshots" />
|
||||
<option name="url" value="https://packages.aliyun.com/maven/repository/2129281-snapshot-71ZAnr/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="com.e-iceblue" />
|
||||
<option name="name" value="com.e-iceblue" />
|
||||
<option name="url" value="http://repo.e-iceblue.cn/repository/maven-public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="snapshots" />
|
||||
<option name="name" value="snapshots" />
|
||||
<option name="url" value="https://maven.aliyun.com/nexus/content/groups/public" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="ignoredFiles">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/hoe-admin/admin-api/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/hoe-common/common-redis/pom.xml" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/hoe-recovery.iml" filepath="$PROJECT_DIR$/hoe-recovery.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="TemplatesSettings">
|
||||
<option name="templateConfigs">
|
||||
<TemplateContext>
|
||||
<option name="generateConfig">
|
||||
<GenerateConfig>
|
||||
<option name="annotationType" value="MYBATIS_PLUS3" />
|
||||
<option name="basePackage" value="generator" />
|
||||
<option name="basePath" value="src/main/java" />
|
||||
<option name="classNameStrategy" value="camel" />
|
||||
<option name="encoding" value="UTF-8" />
|
||||
<option name="extraClassSuffix" value="" />
|
||||
<option name="ignoreFieldPrefix" value="" />
|
||||
<option name="ignoreFieldSuffix" value="" />
|
||||
<option name="ignoreTablePrefix" value="" />
|
||||
<option name="ignoreTableSuffix" value="" />
|
||||
<option name="moduleName" value="hoe-auth" />
|
||||
<option name="modulePath" value="$PROJECT_DIR$" />
|
||||
<option name="moduleUIInfoList">
|
||||
<list>
|
||||
<ModuleInfoGo>
|
||||
<option name="basePath" value="${domain.basePath}" />
|
||||
<option name="configFileName" value="mapperInterface.ftl" />
|
||||
<option name="configName" value="mapperInterface" />
|
||||
<option name="encoding" value="${domain.encoding}" />
|
||||
<option name="fileName" value="${domain.fileName}Mapper" />
|
||||
<option name="fileNameWithSuffix" value="${domain.fileName}Mapper.java" />
|
||||
<option name="modulePath" value="$PROJECT_DIR$" />
|
||||
<option name="packageName" value="${domain.basePackage}.mapper" />
|
||||
</ModuleInfoGo>
|
||||
<ModuleInfoGo>
|
||||
<option name="basePath" value="src/main/resources" />
|
||||
<option name="configFileName" value="mapperXml.ftl" />
|
||||
<option name="configName" value="mapperXml" />
|
||||
<option name="encoding" value="${domain.encoding}" />
|
||||
<option name="fileName" value="${domain.fileName}Mapper" />
|
||||
<option name="fileNameWithSuffix" value="${domain.fileName}Mapper.xml" />
|
||||
<option name="modulePath" value="$PROJECT_DIR$" />
|
||||
<option name="packageName" value="mapper" />
|
||||
</ModuleInfoGo>
|
||||
<ModuleInfoGo>
|
||||
<option name="basePath" value="${domain.basePath}" />
|
||||
<option name="configFileName" value="serviceImpl.ftl" />
|
||||
<option name="configName" value="serviceImpl" />
|
||||
<option name="encoding" value="${domain.encoding}" />
|
||||
<option name="fileName" value="${domain.fileName}ServiceImpl" />
|
||||
<option name="fileNameWithSuffix" value="${domain.fileName}ServiceImpl.java" />
|
||||
<option name="modulePath" value="$PROJECT_DIR$" />
|
||||
<option name="packageName" value="${domain.basePackage}.service.impl" />
|
||||
</ModuleInfoGo>
|
||||
<ModuleInfoGo>
|
||||
<option name="basePath" value="${domain.basePath}" />
|
||||
<option name="configFileName" value="serviceInterface.ftl" />
|
||||
<option name="configName" value="serviceInterface" />
|
||||
<option name="encoding" value="${domain.encoding}" />
|
||||
<option name="fileName" value="${domain.fileName}Service" />
|
||||
<option name="fileNameWithSuffix" value="${domain.fileName}Service.java" />
|
||||
<option name="modulePath" value="$PROJECT_DIR$" />
|
||||
<option name="packageName" value="${domain.basePackage}.service" />
|
||||
</ModuleInfoGo>
|
||||
</list>
|
||||
</option>
|
||||
<option name="needToStringHashcodeEquals" value="true" />
|
||||
<option name="needsComment" value="true" />
|
||||
<option name="needsModel" value="true" />
|
||||
<option name="relativePackage" value="domain" />
|
||||
<option name="superClass" value="" />
|
||||
<option name="tableUIInfoList">
|
||||
<list>
|
||||
<TableUIInfo>
|
||||
<option name="className" value="OauthClientDetails" />
|
||||
<option name="tableName" value="oauth_client_details" />
|
||||
</TableUIInfo>
|
||||
</list>
|
||||
</option>
|
||||
<option name="templatesName" value="mybatis-plus3" />
|
||||
<option name="useLombokPlugin" value="true" />
|
||||
</GenerateConfig>
|
||||
</option>
|
||||
<option name="moduleName" value="hoe-auth" />
|
||||
<option name="projectPath" value="$PROJECT_DIR$" />
|
||||
<option name="templateName" value="mybatis-plus3" />
|
||||
</TemplateContext>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,109 @@
|
|||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.recovery</groupId>
|
||||
<artifactId>hoe-admin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>admin-boot</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- 配置读取 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 单元测试 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Cloud & Alibaba -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 注册中心 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 配置中心 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Sa-Token 权限认证, 在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.37.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<!-- 配置冲突,需要排除 -->
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
|
||||
</dependency>
|
||||
|
||||
<!-- JWT库 -->
|
||||
<dependency>
|
||||
<groupId>com.nimbusds</groupId>
|
||||
<artifactId>nimbus-jose-jwt</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.recovery</groupId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>${hoe-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.recovery</groupId>
|
||||
<artifactId>common-mybatis-plus</artifactId>
|
||||
<version>${hoe-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.recovery</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${hoe-version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework</groupId>-->
|
||||
<!-- <artifactId>spring-webmvc</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,24 @@
|
|||
package com.recovery.admin.boot;
|
||||
|
||||
import com.dtp.core.spring.EnableDynamicTp;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@RefreshScope
|
||||
@EnableFeignClients
|
||||
@EnableDynamicTp
|
||||
@ComponentScan(basePackages = {"com.recovery.admin.boot","com.recovery.common.base"})
|
||||
@MapperScan("com.recovery.admin.boot.mapper")
|
||||
public class AdminApp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AdminApp.class, args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package com.recovery.admin.boot.aspect;
|
||||
|
||||
|
||||
import com.recovery.common.base.util.HspHostUtil;
|
||||
|
||||
import com.recovery.common.base.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.recovery.common.base.ds.*;
|
||||
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.After;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Web层日志切面
|
||||
*
|
||||
* @author RyanWang
|
||||
* @version 1.0.0
|
||||
* @date 16/5/17 上午10:42.
|
||||
*/
|
||||
@Aspect
|
||||
@Order(0)
|
||||
@Slf4j
|
||||
@Component
|
||||
public class WebLogAspect {
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
//
|
||||
@Pointcut("execution(public * com.recovery.admin.boot.controller..*.*(..)) || execution(public * com.recovery.admin.boot.rest.*.*(..))")
|
||||
public void webLog(){}
|
||||
|
||||
@Before("webLog()")
|
||||
public void doBefore(JoinPoint joinPoint) throws Throwable {
|
||||
|
||||
// 接收到请求,记录请求内容
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
//获取请求的域名
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
// 根据域名获取网站信息
|
||||
StringBuffer urlBuf = request.getRequestURL();
|
||||
URL url = new URL(urlBuf.toString());
|
||||
String path = url.getPath();
|
||||
log.info("获取请求地址:" + path);
|
||||
log.info("获取请求ip:" + getIPAddress(request));
|
||||
HttpServletResponse response = (HttpServletResponse)attributes.getResponse();
|
||||
String hospitalHost = request.getHeader("hospitalHost");
|
||||
// if(StringUtils.isEmpty(hospitalHost)){
|
||||
// return;
|
||||
// }
|
||||
|
||||
//切割获取访问目标模块
|
||||
String[] split = path.split("/");
|
||||
String module = split[0];
|
||||
System.out.println(RedisUtils.getDBInfoByHostAndModule(stringRedisTemplate,hospitalHost,"admin"));
|
||||
//根据域名和请求的模块名查询目标数据库
|
||||
HttpSession session = request.getSession();
|
||||
/**
|
||||
* 切换为动态数据源实例
|
||||
*/
|
||||
HspHostUtil.switchDB(hospitalHost,"admin",stringRedisTemplate);
|
||||
|
||||
}
|
||||
public String getIPAddress(HttpServletRequest request) {
|
||||
String ipAddress = request.getRemoteAddr();
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
//执行完切面后,将线程共享中的数据源名称清空
|
||||
@After("webLog()")
|
||||
public void after(JoinPoint joinPoint){
|
||||
log.info("清除数据源===========================================");
|
||||
//清除
|
||||
HspHostUtil.clear();
|
||||
DataSourceContextHolder.clearDBType();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.recovery.admin.boot.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
//跨越请求配置类
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
private CorsConfiguration buildConfig() {
|
||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
// 你需要跨域的地址 注意这里的 127.0.0.1 != localhost
|
||||
// * 表示对所有的地址都可以访问
|
||||
corsConfiguration.addAllowedOrigin("*"); // 1
|
||||
// 跨域的请求头
|
||||
corsConfiguration.addAllowedHeader("*"); // 2
|
||||
// 跨域的请求方法
|
||||
corsConfiguration.addAllowedMethod("*"); // 3
|
||||
//加上了这一句,大致意思是可以携带 cookie
|
||||
//最终的结果是可以 在跨域请求的时候获取同一个 session
|
||||
corsConfiguration.setAllowCredentials(true);
|
||||
return corsConfiguration;
|
||||
}
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
//配置 可以访问的地址
|
||||
source.registerCorsConfiguration("/**", buildConfig());
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package com.recovery.admin.boot.config;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosConfigManager;
|
||||
import com.alibaba.cloud.nacos.NacosConfigProperties;
|
||||
import com.alibaba.nacos.api.config.listener.Listener;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @author 小工匠
|
||||
* @version 1.0
|
||||
* @mark: show me the code , change the world
|
||||
*/
|
||||
@RefreshScope
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class DynamicThreadPoolConfig implements InitializingBean {
|
||||
|
||||
|
||||
private String coreSize = "5";
|
||||
|
||||
|
||||
private String maxSize = "5";
|
||||
|
||||
private static ThreadPoolExecutor threadPoolExecutor;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigManager nacosConfigManager;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
//按照nacos配置初始化线程池
|
||||
threadPoolExecutor = new ThreadPoolExecutor(Integer.parseInt(coreSize), Integer.parseInt(maxSize), 10L, TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(10),
|
||||
new ThreadFactoryBuilder().setNameFormat("c_t_%d").build(),
|
||||
new RejectedExecutionHandler() {
|
||||
@Override
|
||||
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
|
||||
log.info("Warn Warn Warn : rejected executed!!!");
|
||||
}
|
||||
});
|
||||
|
||||
//nacos配置变更监听
|
||||
nacosConfigManager.getConfigService().addListener("order-service-dev.yml", nacosConfigProperties.getGroup(),
|
||||
new Listener() {
|
||||
@Override
|
||||
public Executor getExecutor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
//配置变更,修改线程池配置
|
||||
log.info("收到Nacos Config Server推来的配置变更,修改线程池配置", configInfo);
|
||||
changeThreadPoolConfig(Integer.parseInt(coreSize), Integer.parseInt(maxSize));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印当前线程池的状态
|
||||
*/
|
||||
public String printThreadPoolStatus() {
|
||||
return String.format("core_size:%s,thread_current_size:%s;" +
|
||||
"thread_max_size:%s;queue_current_size:%s,total_task_count:%s", threadPoolExecutor.getCorePoolSize(),
|
||||
threadPoolExecutor.getActiveCount(), threadPoolExecutor.getMaximumPoolSize(), threadPoolExecutor.getQueue().size(),
|
||||
threadPoolExecutor.getTaskCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* 给线程池增加任务
|
||||
*
|
||||
* @param count
|
||||
*/
|
||||
public void dynamicThreadPoolAddTask(int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
int finalI = i;
|
||||
threadPoolExecutor.execute(() -> {
|
||||
try {
|
||||
log.info("dynamicThreadPoolAddTask->", finalI);
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改线程池核心参数
|
||||
*
|
||||
* @param coreSize
|
||||
* @param maxSize
|
||||
*/
|
||||
private void changeThreadPoolConfig(int coreSize, int maxSize) {
|
||||
threadPoolExecutor.setCorePoolSize(coreSize);
|
||||
threadPoolExecutor.setMaximumPoolSize(maxSize);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.recovery.admin.boot.config;
|
||||
|
||||
|
||||
import com.recovery.admin.boot.interceptor.JwtInterceptor;
|
||||
import com.recovery.common.base.config.redis.RedisCache;
|
||||
import com.recovery.common.base.util.RedisUtil;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class InterceptConfig implements WebMvcConfigurer {
|
||||
@Resource
|
||||
RedisCache redisCache;
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
//添加拦截器
|
||||
registry.addInterceptor(new JwtInterceptor(redisCache))
|
||||
//拦截的路径 需要进行token验证的路径
|
||||
.addPathPatterns("/**")
|
||||
//放行的路径
|
||||
.excludePathPatterns("/api/rest/users/getUserByUsername")
|
||||
.excludePathPatterns("/api/user/sendMsg")
|
||||
//放行swagger 测试验证
|
||||
.excludePathPatterns("/api/user/get");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.recovery.admin.boot.config;
|
||||
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.filter.SaServletFilter;
|
||||
import cn.dev33.satoken.same.SaSameUtil;
|
||||
import cn.dev33.satoken.util.SaResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Sa-Token 权限认证 配置类
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
// 注册 Sa-Token 全局过滤器
|
||||
@Bean
|
||||
public SaServletFilter getSaServletFilter() {
|
||||
log.info("校验是否是网关转发请求:====================");
|
||||
return new SaServletFilter()
|
||||
.addInclude("/**")
|
||||
.addExclude("/favicon.ico")
|
||||
.setAuth(obj -> {
|
||||
// 校验 Same-Token 身份凭证 —— 以下两句代码可简化为:SaSameUtil.checkCurrentRequestToken();
|
||||
String token = SaHolder.getRequest().getHeader(SaSameUtil.SAME_TOKEN);
|
||||
SaSameUtil.checkToken(token);
|
||||
})
|
||||
.setError(e -> {
|
||||
return SaResult.error(e.getMessage());
|
||||
})
|
||||
;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package com.recovery.admin.boot.config.ds;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
import com.recovery.common.base.ds.DynamicDataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by YHYR on 2017-12-25
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@MapperScan(basePackages = DataSourceConfig.PACKAGE, sqlSessionFactoryRef = "commonSqlSessionFactory")
|
||||
public class DataSourceConfig {
|
||||
|
||||
// 精确到模块目录,以便跟其他数据源隔离
|
||||
static final String PACKAGE = "com.recovery.admin.boot.mapper";
|
||||
static final String MAPPER_LOCATION = "classpath:mapper/*.xml";
|
||||
|
||||
@Value("${master.datasource.url}")
|
||||
private String masterDBUrl;
|
||||
|
||||
@Value("${master.datasource.username}")
|
||||
private String masterDBUser;
|
||||
|
||||
@Value("${master.datasource.password}")
|
||||
private String masterDBPassword;
|
||||
|
||||
@Value("${master.datasource.driverClassName}")
|
||||
private String masterDBDreiverName;
|
||||
|
||||
|
||||
@Bean(name = "commonDataSource")
|
||||
@Primary
|
||||
public DynamicDataSource dynamicDataSource(){
|
||||
DynamicDataSource dynamicDataSource = DynamicDataSource.getInstance();
|
||||
|
||||
DruidDataSource masterDataSource = new DruidDataSource();
|
||||
try {
|
||||
masterDataSource.setUrl(masterDBUrl);
|
||||
masterDataSource.setUsername(masterDBUser);
|
||||
masterDataSource.setPassword(masterDBPassword);
|
||||
masterDataSource.setDriverClassName(masterDBDreiverName);
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
Map<Object,Object> map = new HashMap<>();
|
||||
map.put("master", masterDataSource);
|
||||
dynamicDataSource.setTargetDataSources(map);
|
||||
|
||||
return dynamicDataSource;
|
||||
}
|
||||
|
||||
@Bean(name = "commonSqlSessionFactory")
|
||||
@Primary
|
||||
public SqlSessionFactory sqlSessionFactory(
|
||||
@Qualifier("commonDataSource") DataSource dynamicDataSource)
|
||||
throws Exception {
|
||||
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
|
||||
bean.setDataSource(dynamicDataSource);
|
||||
bean.setMapperLocations(new PathMatchingResourcePatternResolver()
|
||||
.getResources(DataSourceConfig.MAPPER_LOCATION));
|
||||
return bean.getObject();
|
||||
|
||||
}
|
||||
|
||||
@Bean(name = "commonTransactionManager")
|
||||
@Primary
|
||||
public DataSourceTransactionManager commonTransactionManager() {
|
||||
return new DataSourceTransactionManager(dynamicDataSource());
|
||||
}
|
||||
|
||||
|
||||
@Bean(name = "commonSqlSessionTemplate")
|
||||
public SqlSessionTemplate sqlSessionTemplate(
|
||||
@Qualifier("commonSqlSessionFactory") SqlSessionFactory sqlSessionFactory)
|
||||
throws Exception {
|
||||
return new SqlSessionTemplate(sqlSessionFactory);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
//package com.recovery.admin.boot.config.ds;
|
||||
//
|
||||
//import com.alibaba.druid.pool.DruidDataSource;
|
||||
//import org.apache.ibatis.session.SqlSessionFactory;
|
||||
//import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
//import org.springframework.beans.factory.annotation.Qualifier;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
//
|
||||
//import javax.sql.DataSource;
|
||||
//
|
||||
////@Configuration
|
||||
////// 扫描 Mapper 接口并容器管理
|
||||
////@MapperScan(basePackages = TeachingDataSourceConfig.PACKAGE, sqlSessionFactoryRef = "teachingSqlSessionFactory")
|
||||
//public class TeachingDataSourceConfig {
|
||||
// // 精确到 course 目录,以便跟其他数据源隔离
|
||||
// static final String PACKAGE = "com.recovery.admin.boot.mapper";
|
||||
// static final String MAPPER_LOCATION = "classpath:mapper/*.xml";
|
||||
//
|
||||
// @Value("${admin.datasource.url}")
|
||||
// private String url;
|
||||
//
|
||||
// @Value("${admin.datasource.username}")
|
||||
// private String user;
|
||||
//
|
||||
// @Value("${admin.datasource.password}")
|
||||
// private String password;
|
||||
//
|
||||
// @Value("${admin.datasource.driverClassName}")
|
||||
// private String driverClass;
|
||||
//
|
||||
// @Bean(name = "adminDataSource")
|
||||
// public DataSource cpdDataSource() {
|
||||
// DruidDataSource dataSource = new DruidDataSource();
|
||||
// dataSource.setDriverClassName(driverClass);
|
||||
// dataSource.setUrl(url);
|
||||
// dataSource.setUsername(user);
|
||||
// dataSource.setPassword(password);
|
||||
// return dataSource;
|
||||
// }
|
||||
//
|
||||
// @Bean(name = "adminTransactionManager")
|
||||
// public DataSourceTransactionManager courseTransactionManager() {
|
||||
// return new DataSourceTransactionManager(cpdDataSource());
|
||||
// }
|
||||
//
|
||||
// @Bean(name = "adminSqlSessionFactory")
|
||||
// public SqlSessionFactory cpdSqlSessionFactory(@Qualifier("adminDataSource") DataSource cpdDataSource)
|
||||
// throws Exception {
|
||||
// final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
||||
// sessionFactory.setDataSource(cpdDataSource);
|
||||
// sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
|
||||
// .getResources(TeachingDataSourceConfig.MAPPER_LOCATION));
|
||||
// return sessionFactory.getObject();
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,35 @@
|
|||
package com.recovery.admin.boot.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
|
||||
import com.recovery.admin.boot.entity.SysOauthClient;
|
||||
import com.recovery.admin.boot.service.ISysOauthClientService;
|
||||
|
||||
import com.recovery.common.base.dto.OAuth2ClientDTO;
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@RequestMapping("/api/oauth-clients")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
public class OauthClientController {
|
||||
private ISysOauthClientService iSysOauthClientService;
|
||||
|
||||
@GetMapping("/getOAuth2ClientById")
|
||||
public ApiResult<OAuth2ClientDTO> getOAuth2ClientById(@RequestParam String clientId) {
|
||||
SysOauthClient client = iSysOauthClientService.getById(clientId);
|
||||
Assert.notNull(client, "OAuth2 客户端不存在");
|
||||
OAuth2ClientDTO oAuth2ClientDTO = new OAuth2ClientDTO();
|
||||
BeanUtil.copyProperties(client, oAuth2ClientDTO);
|
||||
return ApiResult.ok(oAuth2ClientDTO);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.recovery.admin.boot.controller;
|
||||
|
||||
|
||||
import com.recovery.admin.boot.service.IMemberUserService;
|
||||
import com.recovery.admin.boot.service.ISysUserService;
|
||||
|
||||
import com.recovery.common.base.dto.MemberUserAuthDTO;
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import com.recovery.common.base.enums.PasswordEncoderTypeEnum;
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/users")
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class UserController {
|
||||
|
||||
private final ISysUserService iSysUserService;
|
||||
|
||||
private final IMemberUserService memberUserService;
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
@GetMapping("/username")
|
||||
public ApiResult<UserAuthDTO> getUserByUsername(@RequestParam String username) {
|
||||
UserAuthDTO user = iSysUserService.getByUsername(username);
|
||||
return ApiResult.ok(user);
|
||||
}
|
||||
/**
|
||||
* 获取会员用户信息
|
||||
*/
|
||||
@GetMapping("/member/username/{username}")
|
||||
public ApiResult<MemberUserAuthDTO> getMemberUserByUsername(@PathVariable String username) {
|
||||
log.info("获取member user info。。。");
|
||||
MemberUserAuthDTO user = memberUserService.getByUsername(username);
|
||||
return ApiResult.ok(user);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.recovery.admin.boot.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.log.Log;
|
||||
import com.recovery.admin.boot.config.DynamicThreadPoolConfig;
|
||||
import com.recovery.admin.boot.service.ISysUserService;
|
||||
import com.recovery.common.base.constant.Constants;
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import com.recovery.common.base.util.HspHostUtil;
|
||||
import com.recovery.common.base.util.RedisUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/test")
|
||||
@Slf4j
|
||||
public class testController {
|
||||
|
||||
@Resource
|
||||
ISysUserService iSysUserService;
|
||||
@Resource
|
||||
RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private DynamicThreadPoolConfig dynamicThreadPool;
|
||||
|
||||
/**
|
||||
* cs
|
||||
*/
|
||||
@GetMapping("/cs")
|
||||
public ApiResult<UserAuthDTO> cs(@RequestParam String name, HttpServletRequest request) {
|
||||
UserAuthDTO authDTO = iSysUserService.getByUsername(name);
|
||||
log.info("测试库:"+authDTO.getStatus());
|
||||
log.info("111获取线程的数据=="+HspHostUtil.getHspHost());
|
||||
StpUtil.kickoutByTokenValue(Constants.LOGIN_USRE_TOKEN);
|
||||
Thread thread = new Thread(()->{
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
log.info("获取线程的数据=="+HspHostUtil.getHspHost());
|
||||
},"测试线程");
|
||||
thread.start();
|
||||
// StpUtil.logout();
|
||||
dynamicThreadPool.printThreadPoolStatus();
|
||||
return ApiResult.ok(authDTO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* cs
|
||||
*/
|
||||
@GetMapping("/cs1")
|
||||
public ApiResult ccss(HttpServletRequest request) {
|
||||
String user = StpUtil.getLoginIdDefaultNull()+"";
|
||||
StpUtil.kickout(StpUtil.getLoginId());
|
||||
// StpUtil.logout();
|
||||
return ApiResult.ok("踢下线");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.recovery.admin.boot.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Data
|
||||
public class MemberUser {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String username;
|
||||
|
||||
private String nickname;
|
||||
|
||||
private String mobile;
|
||||
|
||||
private Integer gender;
|
||||
|
||||
private String avatar;
|
||||
|
||||
private String password;
|
||||
|
||||
private String email;
|
||||
|
||||
private Integer status;
|
||||
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
private Integer deleted;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<Long> roleIds;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String roleNames;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> roles;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.recovery.admin.boot.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Data
|
||||
public class SysOauthClient {
|
||||
|
||||
@TableId(type = IdType.INPUT)
|
||||
/**
|
||||
* 客户端ID
|
||||
*/
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
* 客户端密钥
|
||||
*/
|
||||
private String clientSecret;
|
||||
|
||||
/**
|
||||
* 资源id列表
|
||||
*/
|
||||
private String resourceIds;
|
||||
|
||||
/**
|
||||
* 资源id列表
|
||||
*/
|
||||
private String scope;
|
||||
|
||||
/**
|
||||
* 资源id列表
|
||||
*/
|
||||
private String authorizedGrantTypes;
|
||||
|
||||
/**
|
||||
* 回调地址
|
||||
*/
|
||||
private String webServerRedirectUri;
|
||||
|
||||
/**
|
||||
* 权限列表
|
||||
*/
|
||||
private String authorities;
|
||||
|
||||
/**
|
||||
* 认证令牌时效
|
||||
*/
|
||||
private Integer accessTokenValidity;
|
||||
|
||||
/**
|
||||
* 刷新认证令牌时效
|
||||
*/
|
||||
private Integer refreshTokenValidity;
|
||||
|
||||
/**
|
||||
* 扩展信息
|
||||
*/
|
||||
private String additionalInformation;
|
||||
|
||||
/**
|
||||
* 是否自动放行
|
||||
*/
|
||||
private String autoapprove;
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.recovery.admin.boot.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SysPermission {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Long menuId;
|
||||
|
||||
private String urlPerm;
|
||||
|
||||
// 有权限的角色编号集合
|
||||
@TableField(exist = false)
|
||||
private List<String> roles;
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.recovery.admin.boot.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Data
|
||||
public class User {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String username;
|
||||
|
||||
private String nickname;
|
||||
|
||||
private String mobile;
|
||||
|
||||
private Integer gender;
|
||||
|
||||
private String avatar;
|
||||
|
||||
private String password;
|
||||
|
||||
private String email;
|
||||
|
||||
private Integer status;
|
||||
|
||||
@TableLogic(value = "0", delval = "1")
|
||||
private Integer deleted;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<Long> roleIds;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String roleNames;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> roles;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.recovery.admin.boot.exception;
|
||||
|
||||
|
||||
|
||||
import com.recovery.common.base.result.IResultCode;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 自定义异常类
|
||||
*/
|
||||
@Data
|
||||
public class BusinessException extends RuntimeException{
|
||||
|
||||
private String code;
|
||||
|
||||
private String msg;
|
||||
|
||||
|
||||
public BusinessException(IResultCode apiCode) {
|
||||
super(apiCode.getMsg());
|
||||
this.code = apiCode.getCode();
|
||||
this.msg = apiCode.getMsg();
|
||||
}
|
||||
|
||||
public BusinessException(String code, String message) {
|
||||
super(code+":"+message);
|
||||
this.code = code;
|
||||
this.msg = message;
|
||||
}
|
||||
|
||||
public BusinessException(String message) {
|
||||
super("5001"+":"+message);
|
||||
this.code = "5001";
|
||||
this.msg = message;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
package com.recovery.admin.boot.exception;
|
||||
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.exception.NotPermissionException;
|
||||
import cn.dev33.satoken.util.SaResult;
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import com.recovery.common.base.result.ResultCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
|
||||
/**
|
||||
* 全局异常处理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
//自定义异常
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public ApiResult systemExceptionHandler(BusinessException e) {
|
||||
log.error("BusinessException全局异常:{}",e);
|
||||
return ApiResult.failed(e.getCode(), e.getMsg());
|
||||
}
|
||||
|
||||
//系统异常
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ApiResult exceptionHandler(Exception e) {
|
||||
log.error("Exception全局异常:{}",e);
|
||||
return ApiResult.failed(ResultCode.SYSTEM_EXECUTION_ERROR.getCode(), e.getMessage());
|
||||
}
|
||||
|
||||
// 全局异常拦截(拦截项目中的NotLoginException异常)
|
||||
@ExceptionHandler(NotLoginException.class)
|
||||
public ApiResult handlerNotLoginException(NotLoginException nle)
|
||||
throws Exception {
|
||||
|
||||
// 打印堆栈,以供调试
|
||||
nle.printStackTrace();
|
||||
|
||||
// 判断场景值,定制化异常信息
|
||||
String message = "";
|
||||
if(nle.getType().equals(NotLoginException.NOT_TOKEN)) {
|
||||
message = "未能读取到有效 token";
|
||||
}
|
||||
else if(nle.getType().equals(NotLoginException.INVALID_TOKEN)) {
|
||||
message = "token 无效";
|
||||
}
|
||||
else if(nle.getType().equals(NotLoginException.TOKEN_TIMEOUT)) {
|
||||
message = "token 已过期";
|
||||
}
|
||||
else if(nle.getType().equals(NotLoginException.BE_REPLACED)) {
|
||||
message = "token 已被顶下线";
|
||||
}
|
||||
else if(nle.getType().equals(NotLoginException.KICK_OUT)) {
|
||||
message = "token 已被踢下线";
|
||||
}
|
||||
else if(nle.getType().equals(NotLoginException.TOKEN_FREEZE)) {
|
||||
message = "token 已被冻结";
|
||||
}
|
||||
else if(nle.getType().equals(NotLoginException.NO_PREFIX)) {
|
||||
message = "未按照指定前缀提交 token";
|
||||
}
|
||||
else {
|
||||
message = "当前会话未登录";
|
||||
}
|
||||
// 返回给前端
|
||||
return ApiResult.failed(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截表单参数校验
|
||||
*/
|
||||
@ResponseBody
|
||||
@ExceptionHandler(BindException.class)
|
||||
public ApiResult bindExceptionHandler(BindException ex) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
BindingResult bindingResult = ex.getBindingResult();
|
||||
if (bindingResult.hasErrors()) {
|
||||
for (int i = 0; i < bindingResult.getAllErrors().size(); i++) {
|
||||
ObjectError error = bindingResult.getAllErrors().get(i);
|
||||
sb.append((i == 0 ? "" : "\n") + error.getDefaultMessage());
|
||||
}
|
||||
}
|
||||
return ApiResult.failed(sb.toString());
|
||||
}
|
||||
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
@ResponseBody
|
||||
public ApiResult handler(ConstraintViolationException ex) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int i = 0;
|
||||
for (ConstraintViolation violation : ex.getConstraintViolations()) {
|
||||
sb.append((++i == 1 ? "" : "\n") + violation.getMessage());
|
||||
}
|
||||
return ApiResult.failed(sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求方式不支持
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public ApiResult httpReqMethodNotSupported(HttpRequestMethodNotSupportedException e) {
|
||||
log.error("错误信息:{}", e.getLocalizedMessage());
|
||||
return ApiResult.failed("请求方式不支持");
|
||||
}
|
||||
|
||||
/**
|
||||
* 未登录异常
|
||||
*/
|
||||
@ExceptionHandler(NotLoginException.class)
|
||||
public ApiResult notLoginException(NotLoginException e) {
|
||||
return ApiResult.failed(ResultCode.LOGIN_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用异常
|
||||
*/
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ApiResult exception(Exception e) {
|
||||
if (e instanceof NotPermissionException){
|
||||
return ApiResult.failed("没有操作权限");
|
||||
}
|
||||
e.printStackTrace();
|
||||
return ApiResult.failed(ResultCode.ACCESS_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
//Security
|
||||
// @ExceptionHandler(value = AccessDeniedException.class)
|
||||
// public void accessDeniedException(AccessDeniedException e) {
|
||||
// throw e;
|
||||
// }
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package com.recovery.admin.boot.filter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class RequestWrapper extends HttpServletRequestWrapper {
|
||||
private final Logger logger = LoggerFactory.getLogger(RequestWrapper.class);
|
||||
private final byte[] body;
|
||||
|
||||
public RequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
String sessionStream = getBodyString(request);
|
||||
body = sessionStream.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public String getBodyString() {
|
||||
return new String(body, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @date: 2023/2/6 12:46
|
||||
* @author: zhouzhaodong
|
||||
* @description: 获取请求Body
|
||||
*/
|
||||
public String getBodyString(final ServletRequest request) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
InputStream inputStream = null;
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
inputStream = cloneInputStream(request.getInputStream());
|
||||
reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||
String line = "";
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 接收到请求,记录请求内容
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
//获取请求的域名
|
||||
HttpServletRequest req = attributes.getRequest();
|
||||
// 根据域名获取网站信息
|
||||
StringBuffer urlBuf = req.getRequestURL();
|
||||
try {
|
||||
logger.info("获取请求地址:" + new URL(urlBuf.toString()).getPath());
|
||||
logger.info("获取请求ip:" + getIPAddress(req));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
logger.info("获取body请求参数:" + sb);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getIPAddress(HttpServletRequest request) {
|
||||
String ipAddress = request.getRemoteAddr();
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @date: 2023/2/6 12:46
|
||||
* @author: zhouzhaodong
|
||||
* @description: 复制输入流
|
||||
*/
|
||||
public InputStream cloneInputStream(ServletInputStream inputStream) {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
try {
|
||||
while ((len = inputStream.read(buffer)) > -1) {
|
||||
byteArrayOutputStream.write(buffer, 0, len);
|
||||
}
|
||||
byteArrayOutputStream.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() {
|
||||
return new BufferedReader(new InputStreamReader(getInputStream()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() {
|
||||
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(body);
|
||||
return new ServletInputStream() {
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return bais.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package com.recovery.admin.boot.interceptor;
|
||||
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.strategy.SaStrategy;
|
||||
import cn.dev33.satoken.util.SaFoxUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
|
||||
import com.recovery.admin.boot.exception.BusinessException;
|
||||
import com.recovery.admin.boot.filter.RequestWrapper;
|
||||
import com.recovery.common.base.config.redis.RedisCache;
|
||||
import com.recovery.common.base.constant.Constants;
|
||||
import com.recovery.common.base.result.ResultCode;
|
||||
import com.recovery.common.base.util.RedisUtil;
|
||||
import com.recovery.common.base.utils.JwtUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Slf4j
|
||||
public class JwtInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Resource
|
||||
RedisCache redisCache;
|
||||
|
||||
public JwtInterceptor(RedisCache redisCache) {
|
||||
this.redisCache = redisCache;
|
||||
}
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
response.setHeader( "Set-Cookie" , "cookiename=httponlyTest;Path=/;Domain=domainvalue;Max-Age=seconds;HTTPOnly");
|
||||
response.setHeader( "Content-Security-Policy" , "default-src 'self'; script-src 'self'; frame-ancestors 'self'");
|
||||
response.setHeader("Access-Control-Allow-Origin", (request).getHeader("Origin"));
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
response.setHeader("Referrer-Policy","no-referrer");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
// 获取当前token(这个token获取的是请求头的token,也可以用 request 获取)
|
||||
String token = StpUtil.getTokenValue();
|
||||
long tokenTimeout = StpUtil.getTokenTimeout();// 获取过期时间
|
||||
//token没过期,过期时间不是-1的时候,每次请求都刷新过期时间
|
||||
if (tokenTimeout != -1){
|
||||
StpUtil.renewTimeout(3600);// 用于token续期
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
throw new BusinessException(ResultCode.LOGIN_ERROR);
|
||||
}
|
||||
if (!StpUtil.isLogin()) {
|
||||
throw new BusinessException(ResultCode.IS_LOGIN_EXPIRE_ERROR);
|
||||
}
|
||||
boolean rest = redisCache.isExists(Constants.REDIS_USRE_TOKEN+token);
|
||||
if (!rest) {
|
||||
throw new BusinessException(ResultCode.LOGIN_EXPIRE_ERROR);
|
||||
}
|
||||
//把变量放在request请求域中,仅可以被这次请求,即同一个requerst使用
|
||||
request.setAttribute(Constants.LOGIN_USRE_TOKEN,token);
|
||||
try {
|
||||
//如果验证成功放行请求
|
||||
// DecodedJWT verify = JwtUtils.verifyToken(token);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new BusinessException(ResultCode.TOKEN_INVALID_OR_EXPIRED);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @date: 2023/2/6 12:46
|
||||
* @author: zhouzhaodong
|
||||
* @description: 访问控制器方法后执行
|
||||
*/
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
|
||||
log.info(new Date() + "--postHandle:" + request.getRequestURL());
|
||||
}
|
||||
|
||||
/**
|
||||
* @date: 2023/2/6 12:46
|
||||
* @author: zhouzhaodong
|
||||
* @description: postHandle方法执行完成后执行,一般用于释放资源
|
||||
*/
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||
log.info(new Date() + "--afterCompletion:" + request.getRequestURL());
|
||||
}
|
||||
|
||||
public void renderJson(HttpServletResponse response, Object object) {
|
||||
response.reset();
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Methods", "*");
|
||||
response.setHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
try {
|
||||
response.getWriter().print(JSONObject.toJSONString(object));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.recovery.admin.boot.listener;
|
||||
|
||||
|
||||
import com.recovery.admin.boot.service.ISysPermissionService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class InitResourcePermissionCache implements CommandLineRunner {
|
||||
|
||||
private ISysPermissionService iSysPermissionService;
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
log.info("刷新权限------------------------------");
|
||||
// iSysPermissionService.refreshPermRolesRules();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.recovery.admin.boot.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.recovery.admin.boot.entity.MemberUser;
|
||||
|
||||
import com.recovery.common.base.dto.MemberUserAuthDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Mapper
|
||||
public interface MemberUserMapper extends BaseMapper<MemberUser> {
|
||||
|
||||
MemberUserAuthDTO getByUsername(@Param("userName") String userName);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.recovery.admin.boot.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.recovery.admin.boot.entity.SysOauthClient;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysOauthClientMapper extends BaseMapper<SysOauthClient> {
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.recovery.admin.boot.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.recovery.admin.boot.entity.SysPermission;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysPermissionMapper extends BaseMapper<SysPermission> {
|
||||
|
||||
List<SysPermission> listPermRoles();
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.recovery.admin.boot.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.recovery.admin.boot.entity.User;
|
||||
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
UserAuthDTO getByUsername(@Param("userName") String userName);
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.recovery.admin.boot.rest;
|
||||
|
||||
|
||||
import com.recovery.admin.boot.service.IMemberUserService;
|
||||
import com.recovery.admin.boot.service.ISysUserService;
|
||||
import com.recovery.common.base.dto.MemberUserAuthDTO;
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import com.recovery.common.base.enums.PasswordEncoderTypeEnum;
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/rest/users")
|
||||
@Slf4j
|
||||
public class UserRest {
|
||||
|
||||
@Resource
|
||||
private ISysUserService iSysUserService;
|
||||
@Resource
|
||||
private IMemberUserService memberUserService;
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
@GetMapping("/getUserByUsername")
|
||||
public ApiResult<UserAuthDTO> getUserByUsername(@RequestParam String username) {
|
||||
UserAuthDTO user = iSysUserService.getByUsername(username);
|
||||
if (user == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
return ApiResult.ok(user);
|
||||
}
|
||||
/**12
|
||||
* 获取会员用户信息
|
||||
*/
|
||||
@GetMapping("/member/username/{username}")
|
||||
public ApiResult<MemberUserAuthDTO> getMemberUserByUsername(@PathVariable String username) {
|
||||
log.info("获取member user info。。。");
|
||||
MemberUserAuthDTO user = memberUserService.getByUsername(username);
|
||||
return ApiResult.ok(user);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.recovery.admin.boot.service;
|
||||
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.recovery.admin.boot.entity.MemberUser;
|
||||
import com.recovery.common.base.dto.MemberUserAuthDTO;
|
||||
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
public interface IMemberUserService extends IService<MemberUser> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户名获取认证用户信息,携带角色和密码
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
MemberUserAuthDTO getByUsername(String username);
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.recovery.admin.boot.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.recovery.admin.boot.entity.SysOauthClient;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
public interface ISysOauthClientService extends IService<SysOauthClient> {
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.recovery.admin.boot.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.recovery.admin.boot.entity.SysPermission;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
public interface ISysPermissionService extends IService<SysPermission> {
|
||||
/**
|
||||
* 刷新Redis缓存中角色菜单的权限规则,角色和菜单信息变更调用
|
||||
*/
|
||||
boolean refreshPermRolesRules();
|
||||
|
||||
List<SysPermission> listPermRoles();
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.recovery.admin.boot.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.recovery.admin.boot.entity.User;
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
public interface ISysUserService extends IService<User> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户名获取认证用户信息,携带角色和密码
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
UserAuthDTO getByUsername(String username);
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.recovery.admin.boot.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.recovery.admin.boot.entity.MemberUser;
|
||||
import com.recovery.admin.boot.mapper.MemberUserMapper;
|
||||
import com.recovery.admin.boot.service.IMemberUserService;
|
||||
|
||||
import com.recovery.common.base.dto.MemberUserAuthDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberUser> implements IMemberUserService {
|
||||
@Override
|
||||
public MemberUserAuthDTO getByUsername(String username) {
|
||||
MemberUserAuthDTO memberUserAuthDTO = this.baseMapper.getByUsername(username);
|
||||
return memberUserAuthDTO;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.recovery.admin.boot.service.impl;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.recovery.admin.boot.entity.SysOauthClient;
|
||||
import com.recovery.admin.boot.mapper.SysOauthClientMapper;
|
||||
import com.recovery.admin.boot.service.ISysOauthClientService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysOauthClientServiceImpl extends ServiceImpl<SysOauthClientMapper, SysOauthClient> implements ISysOauthClientService {
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.recovery.admin.boot.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.recovery.admin.boot.entity.SysPermission;
|
||||
import com.recovery.admin.boot.mapper.SysPermissionMapper;
|
||||
import com.recovery.admin.boot.service.ISysPermissionService;
|
||||
import com.recovery.common.base.constant.GlobalConstants;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermission> implements ISysPermissionService {
|
||||
|
||||
private final RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public boolean refreshPermRolesRules() {
|
||||
redisTemplate.delete(Arrays.asList(GlobalConstants.URL_PERM_ROLES_KEY));
|
||||
List<SysPermission> permissions = this.listPermRoles();
|
||||
if (CollectionUtil.isNotEmpty(permissions)) {
|
||||
// 初始化URL- 角色规则
|
||||
List<SysPermission> urlPermList = permissions.stream()
|
||||
.filter(item -> StrUtil.isNotBlank(item.getUrlPerm()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(urlPermList)) {
|
||||
Map<String, List<String>> urlPermRoles = new HashMap<>();
|
||||
urlPermList.stream().forEach(item -> {
|
||||
String perm = item.getUrlPerm();
|
||||
List<String> roles = item.getRoles();
|
||||
urlPermRoles.put(perm, roles);
|
||||
});
|
||||
redisTemplate.opsForHash().putAll(GlobalConstants.URL_PERM_ROLES_KEY, urlPermRoles);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysPermission> listPermRoles() {
|
||||
return this.baseMapper.listPermRoles();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.recovery.admin.boot.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.recovery.admin.boot.entity.User;
|
||||
import com.recovery.admin.boot.mapper.UserMapper;
|
||||
import com.recovery.admin.boot.service.ISysUserService;
|
||||
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysUserServiceImpl extends ServiceImpl<UserMapper, User> implements ISysUserService {
|
||||
@Override
|
||||
public UserAuthDTO getByUsername(String username) {
|
||||
UserAuthDTO userAuthInfo = this.baseMapper.getByUsername(username);
|
||||
return userAuthInfo;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.recovery.admin.boot.util;
|
||||
|
||||
|
||||
import com.recovery.admin.boot.exception.BusinessException;
|
||||
import com.recovery.common.base.constant.Constants;
|
||||
import com.recovery.common.base.dto.UserAuthorityDto;
|
||||
import com.recovery.common.base.result.ResultCode;
|
||||
import com.recovery.common.base.util.RedisUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Slf4j
|
||||
public class UserUtil {
|
||||
|
||||
/**
|
||||
* 获取登录用户信息
|
||||
* @param request
|
||||
* @param redisUtil
|
||||
* @return
|
||||
*/
|
||||
public static UserAuthorityDto getLoginUserInfo(HttpServletRequest request, RedisUtil redisUtil){
|
||||
String loginUserToken = (String) request.getHeader(Constants.LOGIN_USRE_TOKEN);
|
||||
Boolean rest = redisUtil.hasKey("userToken:" +loginUserToken);
|
||||
log.info("缓存key:"+"userToken:" +loginUserToken);
|
||||
log.info("缓存中是否有这条用户:"+rest);
|
||||
if (!rest) {
|
||||
throw new BusinessException(ResultCode.TOKEN_INVALID_OR_EXPIRED);
|
||||
}
|
||||
UserAuthorityDto userAuthorityDto = (UserAuthorityDto) redisUtil.get("userToken:" +loginUserToken);
|
||||
return userAuthorityDto;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
|
||||
spring:
|
||||
application:
|
||||
name: hoe-admin
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# metadata:
|
||||
# serviceGroup: ytChen
|
||||
server-addr: localhost:8848
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
config:
|
||||
server-addr: localhost:8848
|
||||
file-extension: yaml
|
||||
prefix: hoe-admin
|
||||
group: dev
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
dynamic:
|
||||
tp:
|
||||
enabled: true
|
||||
enabledBanner: true # 是否开启banner打印,默认true
|
||||
enabledCollect: true # 是否开启监控指标采集,默认false
|
||||
collectorTypes: micrometer,logging # 监控数据采集器类型(logging | micrometer | internal_logging),默认micrometer
|
||||
logPath: /home/logs # 监控日志数据路径,默认 ${user.home}/logs,采集类型非logging不用配置
|
||||
monitorInterval: 5 # 监控时间间隔(报警判断、指标采集),默认5s
|
||||
platforms: # 通知报警平台配置
|
||||
- platform: email
|
||||
receivers: 1650611030@qq.com
|
||||
tomcatTp: # tomcat webserver线程池配置
|
||||
corePoolSize: 100
|
||||
maximumPoolSize: 200
|
||||
keepAliveTime: 60
|
||||
executors: # 动态线程池配置
|
||||
- threadPoolName: dtpExecutor
|
||||
# 线程池别名
|
||||
executorType: common # 线程池类型common、eager:适用于io密集型
|
||||
corePoolSize: 5 # 核心线程数
|
||||
maximumPoolSize: 18 # 最大线程数
|
||||
queueCapacity: 400 # 任务队列容量
|
||||
queueType: VariableLinkedBlockingQueue # 任务队列,查看源码QueueTypeEnum枚举类
|
||||
rejectedHandlerType: CallerRunsPolicy # 拒绝策略,查看RejectedTypeEnum枚举类
|
||||
keepAliveTime: 50
|
||||
allowCoreThreadTimeOut: false # 是否允许核心线程池超时
|
||||
threadNamePrefix: test # 线程名前缀
|
||||
waitForTasksToCompleteOnShutdown: false # 参考spring线程池设计,优雅关闭线程池
|
||||
awaitTerminationSeconds: 5 # 单位(s)
|
||||
preStartAllCoreThreads: false # 是否预热所有核心线程,默认false
|
||||
runTimeout: 200 # 任务执行超时阈值,目前只做告警用,单位(ms)
|
||||
queueTimeout: 100 # 任务在队列等待超时阈值,目前只做告警用,单位(ms)
|
||||
taskWrapperNames: [ "ttl" ] # 任务包装器名称,集成TaskWrapper接口
|
||||
notifyItems: # 报警项,不配置自动会按默认值配置(变更通知、容量报警、活性报警、拒绝报警、任务超时报警)
|
||||
- type: capacity # 报警项类型,查看源码 NotifyTypeEnum枚举类
|
||||
enabled: true
|
||||
threshold: 80 # 报警阈值
|
||||
platforms: [ ding,wechat ] # 可选配置,不配置默认拿上层platforms配置的所以平台
|
||||
interval: 120 # 报警间隔(单位:s)
|
||||
- type: change
|
||||
enabled: true
|
||||
- type: liveness
|
||||
enabled: true
|
||||
threshold: 80
|
||||
- type: reject
|
||||
enabled: true
|
||||
threshold: 1
|
||||
- type: run_timeout
|
||||
enabled: true
|
||||
threshold: 1
|
||||
- type: queue_timeout
|
||||
enabled: true
|
||||
threshold: 1
|
||||
|
||||
server:
|
||||
port: 9002
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<contextName>logback</contextName>
|
||||
<property name="SYS_LOG_DIR" value="logs" />
|
||||
<property name="LOG_FILE" value="demo.log" />
|
||||
<property name="fileLayoutPattern"
|
||||
value="%-20(%d{yyyyMMdd_HH:mm:ss.SSS} [%logger{10}][%thread] [%-4relative])
|
||||
[%X{hostName} %X{requestId} %X{processId} %X{service.timing} ][%level] %msg%n" />
|
||||
<property name="consoleLayoutPattern"
|
||||
value="%-20(%d{yyyyMMdd_HH:mm:ss.SSS} [%logger][%thread] [%-4relative])
|
||||
[%X{hostName} %X{requestId} %X{processId} %X{service.timing} ][%level] %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout name="StandardFormat" class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>${consoleLayoutPattern}</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!--输出到文件-->
|
||||
<appender name="LOG_ROLLING"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${SYS_LOG_DIR}/${LOG_FILE}</file>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> <!-- 日志过滤器,只记录warn级别日志 ,若要配置其他级别,复制appender,修改level,并在root中配置-->
|
||||
<level>WARN</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${SYS_LOG_DIR}/%d{yyyy-MM-dd}/${LOG_FILE}_%d{yyyy-MM-dd}_%i.zip</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<layout>
|
||||
<pattern>${fileLayoutPattern}</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" /> <!-- 控制台输出 -->
|
||||
<appender-ref ref="LOG_ROLLING" /> <!-- 文件输出 -->
|
||||
</root>
|
||||
<!-- 测试环境+开发环境. 多个使用逗号隔开. -->
|
||||
<springProfile name="test,dev">
|
||||
<logger name="com.recovery.admin.boot.controller" level="INFO" />
|
||||
</springProfile>
|
||||
<!-- 生产环境. -->
|
||||
<springProfile name="prod">
|
||||
<logger name="com.recovery.admin.boot.controller" level="ERROR" />
|
||||
</springProfile>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,175 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- 从高到地低 OFF 、 FATAL 、 ERROR 、 WARN 、 INFO 、 DEBUG 、 TRACE 、 ALL -->
|
||||
<!-- 日志输出规则 根据当前ROOT 级别,日志输出时,级别高于root默认的级别时 会输出 -->
|
||||
<!-- 以下 每个配置的 filter 是过滤掉输出文件里面,会出现高级别文件,依然出现低级别的日志信息,通过filter 过滤只记录本级别的日志-->
|
||||
|
||||
|
||||
<!-- 属性描述 scan:性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,
|
||||
默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。
|
||||
debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 定义日志文件 输入位置 -->
|
||||
<springProperty scope="context" name="logPath" source="log.path" defaultValue="logs"/>
|
||||
<property name="log_dir" value="${logPath}/common" />
|
||||
<!-- 日志最大的历史 30天 -->
|
||||
<property name="maxHistory" value="30"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ConsoleAppender 控制台输出日志 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<withJansi>true</withJansi>
|
||||
<!-- 对日志进行格式化 -->
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<!-- ERROR级别日志 -->
|
||||
<!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 RollingFileAppender-->
|
||||
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 过滤器,只记录WARN级别的日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责出发滚动 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--日志输出位置 可相对、和绝对路径 -->
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/error-log.log</fileNamePattern>
|
||||
<!-- 可选节点,控制保留的归档文件的最大数量,超出数量就删除旧文件假设设置每个月滚动,且<maxHistory>是6,
|
||||
则只保存最近6个月的文件,删除之前的旧文件。注意,删除旧文件是,那些为了归档而创建的目录也会被删除-->
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<!-- 按照固定窗口模式生成日志文件,当文件大于20MB时,生成新的日志文件。窗口大小是1到3,当保存了3个归档文件后,将覆盖最早的日志。
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/.log.zip</fileNamePattern>
|
||||
<minIndex>1</minIndex>
|
||||
<maxIndex>3</maxIndex>
|
||||
</rollingPolicy> -->
|
||||
<!-- 查看当前活动文件的大小,如果超过指定大小会告知RollingFileAppender 触发当前活动文件滚动
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<maxFileSize>5MB</maxFileSize>
|
||||
</triggeringPolicy> -->
|
||||
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
|
||||
<!-- WARN级别日志 appender -->
|
||||
<appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 过滤器,只记录WARN级别的日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>WARN</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 按天回滚 daily -->
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/warn-log.log
|
||||
</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- INFO级别日志 appender -->
|
||||
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 过滤器,只记录INFO级别的日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>INFO</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 按天回滚 daily -->
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/info-log.log
|
||||
</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- DEBUG级别日志 appender -->
|
||||
<appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 过滤器,只记录DEBUG级别的日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>DEBUG</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 按天回滚 daily -->
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/debug-log.log
|
||||
</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- TRACE级别日志 appender -->
|
||||
<appender name="TRACE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 过滤器,只记录ERROR级别的日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>TRACE</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 按天回滚 daily -->
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/trace-log.log
|
||||
</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="java.sql.PreparedStatement" value="DEBUG" />
|
||||
<logger name="java.sql.Connection" value="DEBUG" />
|
||||
<logger name="java.sql.Statement" value="DEBUG" />
|
||||
<logger name="com.recovery.admin.boot.aspect" value="DEBUG" />
|
||||
|
||||
|
||||
<!-- root级别 DEBUG -->
|
||||
<root level="INFO">
|
||||
<!-- 控制台输出 -->
|
||||
<appender-ref ref="STDOUT" />
|
||||
<!-- 文件输出 -->
|
||||
<appender-ref ref="ERROR" />
|
||||
<appender-ref ref="INFO" />
|
||||
<appender-ref ref="WARN" />
|
||||
<appender-ref ref="DEBUG" />
|
||||
<appender-ref ref="TRACE" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,53 @@
|
|||
<?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.recovery.admin.boot.mapper.MemberUserMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.recovery.admin.boot.entity.MemberUser">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="username" column="username" jdbcType="VARCHAR"/>
|
||||
<result property="nickname" column="nickname" jdbcType="VARCHAR"/>
|
||||
<result property="gender" column="gender" jdbcType="BOOLEAN"/>
|
||||
<result property="password" column="password" jdbcType="VARCHAR"/>
|
||||
<result property="avatar" column="avatar" jdbcType="VARCHAR"/>
|
||||
<result property="mobile" column="mobile" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="status" jdbcType="BOOLEAN"/>
|
||||
<result property="email" column="email" jdbcType="VARCHAR"/>
|
||||
<result property="deleted" column="deleted" jdbcType="BOOLEAN"/>
|
||||
<collection property="roles" ofType="string" javaType="list">
|
||||
<result column="roleCode"></result>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
,username,nickname,
|
||||
gender,password,dept_id,
|
||||
avatar,mobile,status,
|
||||
email,gmt_create,gmt_modified,
|
||||
deleted
|
||||
</sql>
|
||||
|
||||
<resultMap id="MemberUserAuthMap" type="com.recovery.common.base.dto.MemberUserAuthDTO">
|
||||
<id property="userId" column="userId" jdbcType="BIGINT"/>
|
||||
<result property="username" column="username" jdbcType="VARCHAR"/>
|
||||
<result property="password" column="password" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="status" jdbcType="BOOLEAN"/>
|
||||
<collection property="roles" ofType="string" javaType="list">
|
||||
<result column="roleCode"></result>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="getByUsername" resultMap="MemberUserAuthMap">
|
||||
select t1.id userId, t1.username, t1.nickname, t1.password, t1.status, t3.code roleCode
|
||||
from member_user t1,
|
||||
sys_user_role t2,
|
||||
sys_role t3
|
||||
where t1.username = #{userName}
|
||||
and t1.deleted = 0
|
||||
and t1.id = t2.user_id
|
||||
and t2.role_id = t3.id
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,35 @@
|
|||
<?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.recovery.admin.boot.mapper.SysPermissionMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.recovery.admin.boot.entity.SysPermission">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="menuId" column="menu_id" jdbcType="BIGINT"/>
|
||||
<result property="urlPerm" column="url_perm" jdbcType="VARCHAR"/>
|
||||
<collection property="roles" ofType="String" javaType="list">
|
||||
<result column="code"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
,name,menu_id,
|
||||
url_perm,btn_perm,gmt_create,
|
||||
gmt_modified
|
||||
</sql>
|
||||
|
||||
<select id="listPermRoles" resultMap="BaseResultMap">
|
||||
SELECT t1.id,
|
||||
t1.NAME,
|
||||
t1.menu_id,
|
||||
t1.url_perm,
|
||||
t3.CODE
|
||||
FROM sys_permission t1
|
||||
LEFT JOIN sys_role_permission t2 ON t1.id = t2.permission_id
|
||||
LEFT JOIN sys_role t3 ON t2.role_id = t3.id
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,12 @@
|
|||
<?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.recovery.admin.boot.mapper.UserMapper">
|
||||
|
||||
|
||||
<select id="getByUsername" resultType="com.recovery.common.base.dto.UserAuthDTO">
|
||||
select t1.user_name as userName,t1.password,t1.state as status,t1.id as userId
|
||||
from tbl_user t1 where t1.user_name = #{userName}
|
||||
|
||||
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,78 @@
|
|||
|
||||
spring:
|
||||
application:
|
||||
name: hoe-admin
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# metadata:
|
||||
# serviceGroup: ytChen
|
||||
server-addr: localhost:8848
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
config:
|
||||
server-addr: localhost:8848
|
||||
file-extension: yaml
|
||||
prefix: hoe-admin
|
||||
group: dev
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
dynamic:
|
||||
tp:
|
||||
enabled: true
|
||||
enabledBanner: true # 是否开启banner打印,默认true
|
||||
enabledCollect: true # 是否开启监控指标采集,默认false
|
||||
collectorTypes: micrometer,logging # 监控数据采集器类型(logging | micrometer | internal_logging),默认micrometer
|
||||
logPath: /home/logs # 监控日志数据路径,默认 ${user.home}/logs,采集类型非logging不用配置
|
||||
monitorInterval: 5 # 监控时间间隔(报警判断、指标采集),默认5s
|
||||
platforms: # 通知报警平台配置
|
||||
- platform: email
|
||||
receivers: 1650611030@qq.com
|
||||
tomcatTp: # tomcat webserver线程池配置
|
||||
corePoolSize: 100
|
||||
maximumPoolSize: 200
|
||||
keepAliveTime: 60
|
||||
executors: # 动态线程池配置
|
||||
- threadPoolName: dtpExecutor
|
||||
# 线程池别名
|
||||
executorType: common # 线程池类型common、eager:适用于io密集型
|
||||
corePoolSize: 5 # 核心线程数
|
||||
maximumPoolSize: 18 # 最大线程数
|
||||
queueCapacity: 400 # 任务队列容量
|
||||
queueType: VariableLinkedBlockingQueue # 任务队列,查看源码QueueTypeEnum枚举类
|
||||
rejectedHandlerType: CallerRunsPolicy # 拒绝策略,查看RejectedTypeEnum枚举类
|
||||
keepAliveTime: 50
|
||||
allowCoreThreadTimeOut: false # 是否允许核心线程池超时
|
||||
threadNamePrefix: test # 线程名前缀
|
||||
waitForTasksToCompleteOnShutdown: false # 参考spring线程池设计,优雅关闭线程池
|
||||
awaitTerminationSeconds: 5 # 单位(s)
|
||||
preStartAllCoreThreads: false # 是否预热所有核心线程,默认false
|
||||
runTimeout: 200 # 任务执行超时阈值,目前只做告警用,单位(ms)
|
||||
queueTimeout: 100 # 任务在队列等待超时阈值,目前只做告警用,单位(ms)
|
||||
taskWrapperNames: [ "ttl" ] # 任务包装器名称,集成TaskWrapper接口
|
||||
notifyItems: # 报警项,不配置自动会按默认值配置(变更通知、容量报警、活性报警、拒绝报警、任务超时报警)
|
||||
- type: capacity # 报警项类型,查看源码 NotifyTypeEnum枚举类
|
||||
enabled: true
|
||||
threshold: 80 # 报警阈值
|
||||
platforms: [ ding,wechat ] # 可选配置,不配置默认拿上层platforms配置的所以平台
|
||||
interval: 120 # 报警间隔(单位:s)
|
||||
- type: change
|
||||
enabled: true
|
||||
- type: liveness
|
||||
enabled: true
|
||||
threshold: 80
|
||||
- type: reject
|
||||
enabled: true
|
||||
threshold: 1
|
||||
- type: run_timeout
|
||||
enabled: true
|
||||
threshold: 1
|
||||
- type: queue_timeout
|
||||
enabled: true
|
||||
threshold: 1
|
||||
|
||||
server:
|
||||
port: 9002
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<contextName>logback</contextName>
|
||||
<property name="SYS_LOG_DIR" value="logs" />
|
||||
<property name="LOG_FILE" value="demo.log" />
|
||||
<property name="fileLayoutPattern"
|
||||
value="%-20(%d{yyyyMMdd_HH:mm:ss.SSS} [%logger{10}][%thread] [%-4relative])
|
||||
[%X{hostName} %X{requestId} %X{processId} %X{service.timing} ][%level] %msg%n" />
|
||||
<property name="consoleLayoutPattern"
|
||||
value="%-20(%d{yyyyMMdd_HH:mm:ss.SSS} [%logger][%thread] [%-4relative])
|
||||
[%X{hostName} %X{requestId} %X{processId} %X{service.timing} ][%level] %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout name="StandardFormat" class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>${consoleLayoutPattern}</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!--输出到文件-->
|
||||
<appender name="LOG_ROLLING"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${SYS_LOG_DIR}/${LOG_FILE}</file>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> <!-- 日志过滤器,只记录warn级别日志 ,若要配置其他级别,复制appender,修改level,并在root中配置-->
|
||||
<level>WARN</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${SYS_LOG_DIR}/%d{yyyy-MM-dd}/${LOG_FILE}_%d{yyyy-MM-dd}_%i.zip</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<layout>
|
||||
<pattern>${fileLayoutPattern}</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" /> <!-- 控制台输出 -->
|
||||
<appender-ref ref="LOG_ROLLING" /> <!-- 文件输出 -->
|
||||
</root>
|
||||
<!-- 测试环境+开发环境. 多个使用逗号隔开. -->
|
||||
<springProfile name="test,dev">
|
||||
<logger name="com.recovery.admin.boot.controller" level="INFO" />
|
||||
</springProfile>
|
||||
<!-- 生产环境. -->
|
||||
<springProfile name="prod">
|
||||
<logger name="com.recovery.admin.boot.controller" level="ERROR" />
|
||||
</springProfile>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,175 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- 从高到地低 OFF 、 FATAL 、 ERROR 、 WARN 、 INFO 、 DEBUG 、 TRACE 、 ALL -->
|
||||
<!-- 日志输出规则 根据当前ROOT 级别,日志输出时,级别高于root默认的级别时 会输出 -->
|
||||
<!-- 以下 每个配置的 filter 是过滤掉输出文件里面,会出现高级别文件,依然出现低级别的日志信息,通过filter 过滤只记录本级别的日志-->
|
||||
|
||||
|
||||
<!-- 属性描述 scan:性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,
|
||||
默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。
|
||||
debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 定义日志文件 输入位置 -->
|
||||
<springProperty scope="context" name="logPath" source="log.path" defaultValue="logs"/>
|
||||
<property name="log_dir" value="${logPath}/common" />
|
||||
<!-- 日志最大的历史 30天 -->
|
||||
<property name="maxHistory" value="30"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ConsoleAppender 控制台输出日志 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<withJansi>true</withJansi>
|
||||
<!-- 对日志进行格式化 -->
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{15}) - %highlight(%msg) %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<!-- ERROR级别日志 -->
|
||||
<!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 RollingFileAppender-->
|
||||
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 过滤器,只记录WARN级别的日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责出发滚动 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--日志输出位置 可相对、和绝对路径 -->
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/error-log.log</fileNamePattern>
|
||||
<!-- 可选节点,控制保留的归档文件的最大数量,超出数量就删除旧文件假设设置每个月滚动,且<maxHistory>是6,
|
||||
则只保存最近6个月的文件,删除之前的旧文件。注意,删除旧文件是,那些为了归档而创建的目录也会被删除-->
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<!-- 按照固定窗口模式生成日志文件,当文件大于20MB时,生成新的日志文件。窗口大小是1到3,当保存了3个归档文件后,将覆盖最早的日志。
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/.log.zip</fileNamePattern>
|
||||
<minIndex>1</minIndex>
|
||||
<maxIndex>3</maxIndex>
|
||||
</rollingPolicy> -->
|
||||
<!-- 查看当前活动文件的大小,如果超过指定大小会告知RollingFileAppender 触发当前活动文件滚动
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<maxFileSize>5MB</maxFileSize>
|
||||
</triggeringPolicy> -->
|
||||
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
|
||||
<!-- WARN级别日志 appender -->
|
||||
<appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 过滤器,只记录WARN级别的日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>WARN</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 按天回滚 daily -->
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/warn-log.log
|
||||
</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- INFO级别日志 appender -->
|
||||
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 过滤器,只记录INFO级别的日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>INFO</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 按天回滚 daily -->
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/info-log.log
|
||||
</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- DEBUG级别日志 appender -->
|
||||
<appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 过滤器,只记录DEBUG级别的日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>DEBUG</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 按天回滚 daily -->
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/debug-log.log
|
||||
</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- TRACE级别日志 appender -->
|
||||
<appender name="TRACE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 过滤器,只记录ERROR级别的日志 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>TRACE</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 按天回滚 daily -->
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/trace-log.log
|
||||
</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="java.sql.PreparedStatement" value="DEBUG" />
|
||||
<logger name="java.sql.Connection" value="DEBUG" />
|
||||
<logger name="java.sql.Statement" value="DEBUG" />
|
||||
<logger name="com.recovery.admin.boot.aspect" value="DEBUG" />
|
||||
|
||||
|
||||
<!-- root级别 DEBUG -->
|
||||
<root level="INFO">
|
||||
<!-- 控制台输出 -->
|
||||
<appender-ref ref="STDOUT" />
|
||||
<!-- 文件输出 -->
|
||||
<appender-ref ref="ERROR" />
|
||||
<appender-ref ref="INFO" />
|
||||
<appender-ref ref="WARN" />
|
||||
<appender-ref ref="DEBUG" />
|
||||
<appender-ref ref="TRACE" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,53 @@
|
|||
<?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.recovery.admin.boot.mapper.MemberUserMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.recovery.admin.boot.entity.MemberUser">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="username" column="username" jdbcType="VARCHAR"/>
|
||||
<result property="nickname" column="nickname" jdbcType="VARCHAR"/>
|
||||
<result property="gender" column="gender" jdbcType="BOOLEAN"/>
|
||||
<result property="password" column="password" jdbcType="VARCHAR"/>
|
||||
<result property="avatar" column="avatar" jdbcType="VARCHAR"/>
|
||||
<result property="mobile" column="mobile" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="status" jdbcType="BOOLEAN"/>
|
||||
<result property="email" column="email" jdbcType="VARCHAR"/>
|
||||
<result property="deleted" column="deleted" jdbcType="BOOLEAN"/>
|
||||
<collection property="roles" ofType="string" javaType="list">
|
||||
<result column="roleCode"></result>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
,username,nickname,
|
||||
gender,password,dept_id,
|
||||
avatar,mobile,status,
|
||||
email,gmt_create,gmt_modified,
|
||||
deleted
|
||||
</sql>
|
||||
|
||||
<resultMap id="MemberUserAuthMap" type="com.recovery.common.base.dto.MemberUserAuthDTO">
|
||||
<id property="userId" column="userId" jdbcType="BIGINT"/>
|
||||
<result property="username" column="username" jdbcType="VARCHAR"/>
|
||||
<result property="password" column="password" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="status" jdbcType="BOOLEAN"/>
|
||||
<collection property="roles" ofType="string" javaType="list">
|
||||
<result column="roleCode"></result>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="getByUsername" resultMap="MemberUserAuthMap">
|
||||
select t1.id userId, t1.username, t1.nickname, t1.password, t1.status, t3.code roleCode
|
||||
from member_user t1,
|
||||
sys_user_role t2,
|
||||
sys_role t3
|
||||
where t1.username = #{userName}
|
||||
and t1.deleted = 0
|
||||
and t1.id = t2.user_id
|
||||
and t2.role_id = t3.id
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,35 @@
|
|||
<?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.recovery.admin.boot.mapper.SysPermissionMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.recovery.admin.boot.entity.SysPermission">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="menuId" column="menu_id" jdbcType="BIGINT"/>
|
||||
<result property="urlPerm" column="url_perm" jdbcType="VARCHAR"/>
|
||||
<collection property="roles" ofType="String" javaType="list">
|
||||
<result column="code"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
,name,menu_id,
|
||||
url_perm,btn_perm,gmt_create,
|
||||
gmt_modified
|
||||
</sql>
|
||||
|
||||
<select id="listPermRoles" resultMap="BaseResultMap">
|
||||
SELECT t1.id,
|
||||
t1.NAME,
|
||||
t1.menu_id,
|
||||
t1.url_perm,
|
||||
t3.CODE
|
||||
FROM sys_permission t1
|
||||
LEFT JOIN sys_role_permission t2 ON t1.id = t2.permission_id
|
||||
LEFT JOIN sys_role t3 ON t2.role_id = t3.id
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,12 @@
|
|||
<?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.recovery.admin.boot.mapper.UserMapper">
|
||||
|
||||
|
||||
<select id="getByUsername" resultType="com.recovery.common.base.dto.UserAuthDTO">
|
||||
select t1.user_name as userName,t1.password,t1.state as status,t1.id as userId
|
||||
from tbl_user t1 where t1.user_name = #{userName}
|
||||
|
||||
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,24 @@
|
|||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.recovery</groupId>
|
||||
<artifactId>hoe-recovery</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hoe-admin</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>admin-boot</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,78 @@
|
|||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.recovery</groupId>
|
||||
<artifactId>hoe-recovery</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0.0</version>
|
||||
<description>认证中心</description>
|
||||
<artifactId>hoe-auth</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!--Spring Cloud & Alibaba -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.recovery</groupId>
|
||||
<artifactId>common-base</artifactId>
|
||||
<version>${hoe-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.recovery</groupId>
|
||||
<artifactId>common-mybatis-plus</artifactId>
|
||||
<version>${hoe-version}</version>
|
||||
</dependency>
|
||||
<!-- 注册中心 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Sa-Token 权限认证, 在线文档:https://sa-token.cc -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.37.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 配置中心 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.recovery</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${hoe-version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,24 @@
|
|||
package com.recovery.auth;
|
||||
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
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.ComponentScan;
|
||||
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients({"com.recovery.auth.feign"})
|
||||
@ComponentScan(basePackages = {"com.recovery.auth","com.recovery.common.base"})
|
||||
@MapperScan("com.recovery.auth.mapper")
|
||||
public class AuthApp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthApp.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.recovery.auth;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
* @date: 2022/5/22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/oauth")
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
public class TestController {
|
||||
|
||||
@GetMapping("/public-test")
|
||||
public String test() {
|
||||
return "hoe-auth 为您提供服务";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.recovery.auth.aspect;
|
||||
|
||||
|
||||
import com.recovery.common.base.ds.DataSourceContextHolder;
|
||||
import com.recovery.common.base.util.HspHostUtil;
|
||||
import com.recovery.common.base.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.After;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Web层日志切面
|
||||
*
|
||||
* @author RyanWang
|
||||
* @version 1.0.0
|
||||
* @date 16/5/17 上午10:42.
|
||||
*/
|
||||
@Aspect
|
||||
@Order(0)
|
||||
@Slf4j
|
||||
@Component
|
||||
public class WebLogAspect {
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@Pointcut("execution(public * com.recovery.auth.controller..*.*(..)) || execution(public * com.recovery.auth.rest..*.*(..))")
|
||||
public void webLog(){}
|
||||
|
||||
@Before("webLog()")
|
||||
public void doBefore(JoinPoint joinPoint) throws Throwable {
|
||||
|
||||
// 接收到请求,记录请求内容
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
//获取请求的域名
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
// 根据域名获取网站信息
|
||||
StringBuffer urlBuf = request.getRequestURL();
|
||||
URL url = new URL(urlBuf.toString());
|
||||
String path = url.getPath();
|
||||
HttpServletResponse response = (HttpServletResponse)attributes.getResponse();
|
||||
String hospitalHost = request.getHeader("hospitalHost");
|
||||
// if(StringUtils.isEmpty(hospitalHost)){
|
||||
// return;
|
||||
// }
|
||||
|
||||
//切割获取访问目标模块
|
||||
String[] split = path.split("/");
|
||||
String module = split[0];
|
||||
log.info(RedisUtils.getDBInfoByHostAndModule(stringRedisTemplate,hospitalHost,"admin")+"");
|
||||
//根据域名和请求的模块名查询目标数据库
|
||||
HttpSession session = request.getSession();
|
||||
/**
|
||||
* 切换为动态数据源实例
|
||||
*/
|
||||
HspHostUtil.switchDB(hospitalHost,"admin",stringRedisTemplate);
|
||||
|
||||
}
|
||||
//执行完切面后,将线程共享中的数据源名称清空
|
||||
@After("webLog()")
|
||||
public void after(JoinPoint joinPoint){
|
||||
log.info("清除数据源===========================================");
|
||||
//清除
|
||||
HspHostUtil.clear();
|
||||
DataSourceContextHolder.clearDBType();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.recovery.auth.comm;
|
||||
|
||||
|
||||
import com.recovery.common.base.enums.PasswordEncoderTypeEnum;
|
||||
import com.recovery.common.base.util.EncryptUtil;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
public class test {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(EncryptUtil.encrypt("123"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.recovery.auth.config;
|
||||
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.filter.SaServletFilter;
|
||||
import cn.dev33.satoken.jwt.StpLogicJwtForMixin;
|
||||
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
|
||||
import cn.dev33.satoken.same.SaSameUtil;
|
||||
import cn.dev33.satoken.stp.StpLogic;
|
||||
import cn.dev33.satoken.util.SaResult;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Sa-Token 权限认证 配置类
|
||||
*/
|
||||
@Configuration
|
||||
public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
// 注册 Sa-Token 全局过滤器
|
||||
@Bean
|
||||
public SaServletFilter getSaServletFilter() {
|
||||
return new SaServletFilter()
|
||||
.addInclude("/**")
|
||||
.addExclude("/favicon.ico")
|
||||
.setAuth(obj -> {
|
||||
// 校验 Same-Token 身份凭证 —— 以下两句代码可简化为:SaSameUtil.checkCurrentRequestToken();
|
||||
String token = SaHolder.getRequest().getHeader(SaSameUtil.SAME_TOKEN);
|
||||
SaSameUtil.checkToken(token);
|
||||
})
|
||||
.setError(e -> {
|
||||
return SaResult.error(e.getMessage());
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
// Sa-Token 整合 jwt (Simple 简单模式)
|
||||
@Bean
|
||||
public StpLogic getStpLogicJwt() {
|
||||
return new StpLogicJwtForSimple();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue