Compare commits
No commits in common. "master" and "main" have entirely different histories.
|
@ -1,35 +0,0 @@
|
|||
<?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="xxl-job-admin" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="admin-boot" options="-parameters" />
|
||||
<module name="common-base" options="-parameters" />
|
||||
<module name="common-mybatis-plus" options="-parameters" />
|
||||
<module name="common-web" options="-parameters" />
|
||||
<module name="hoe-auth" options="-parameters" />
|
||||
<module name="hoe-gateway" options="-parameters" />
|
||||
<module name="hoe-order" options="-parameters" />
|
||||
<module name="xxl-job-admin" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -1,17 +0,0 @@
|
|||
<?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>
|
|
@ -1,22 +0,0 @@
|
|||
<?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>
|
|
@ -1,55 +0,0 @@
|
|||
<?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="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="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="Sonatype" />
|
||||
<option name="name" value="Sonatype Repository" />
|
||||
<option name="url" value="http://repository.sonatype.org/content/groups/public/" />
|
||||
</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="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://maven.aliyun.com/nexus/content/groups/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>
|
|
@ -1,23 +0,0 @@
|
|||
<?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" />
|
||||
<option value="$PROJECT_DIR$/xxl-job-admin/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" />
|
||||
<option value="$PROJECT_DIR$/xxl-job-admin/pom.xml" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||
<?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>
|
|
@ -1,87 +0,0 @@
|
|||
<?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>
|
|
@ -1,124 +0,0 @@
|
|||
<?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>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,158 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 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>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</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>
|
||||
|
||||
<!-- 添加Hibernate Validator依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>6.2.0.Final</version>
|
||||
</dependency>
|
||||
<!-- 添加Hibernate Validator依赖所需的依赖项 -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>jakarta.el</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</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>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>javax.persistence-api</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 注意一定要引入对版本,要引入spring-cloud版本seata,而不是springboot版本的seata-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba.cloud</groupId>-->
|
||||
<!-- <artifactId>spring-cloud-starter-alibaba-seata</artifactId>-->
|
||||
<!-- <!– 排除掉springcloud默认的seata版本,以免版本不一致出现问题–>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>io.seata</groupId>-->
|
||||
<!-- <artifactId>seata-spring-boot-starter</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>io.seata</groupId>-->
|
||||
<!-- <artifactId>seata-all</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– 上面排除掉了springcloud默认色seata版本,此处引入和seata-server版本对应的seata包–>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.seata</groupId>-->
|
||||
<!-- <artifactId>seata-spring-boot-starter</artifactId>-->
|
||||
<!-- <version>1.4.2</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.baomidou</groupId>-->
|
||||
<!-- <artifactId>mybatis-plus-generator</artifactId>-->
|
||||
<!-- <version>3.4.0</version>-->
|
||||
<!-- <scope>test</scope>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- JWT库 -->
|
||||
<dependency>
|
||||
<groupId>com.nimbusds</groupId>
|
||||
<artifactId>nimbus-jose-jwt</artifactId>
|
||||
<version>9.22</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>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
</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>
|
|
@ -1,26 +0,0 @@
|
|||
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;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@RefreshScope
|
||||
@EnableFeignClients
|
||||
@EnableScheduling
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
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();
|
||||
// 根据域名获取c网站信息
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package com.recovery.admin.boot.config;
|
||||
|
||||
|
||||
import com.recovery.admin.boot.interceptor.JwtInterceptor;
|
||||
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 {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
//添加拦截器
|
||||
registry.addInterceptor(new JwtInterceptor())
|
||||
//拦截的路径 需要进行token验证的路径
|
||||
.addPathPatterns("/**")
|
||||
//放行的路径
|
||||
.excludePathPatterns("/api/rest/users/getUserByUsername")
|
||||
.excludePathPatterns("/api/user/sendMsg")
|
||||
//放行swagger 测试验证
|
||||
.excludePathPatterns("/api/user/get");
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
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());
|
||||
})
|
||||
;
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
package com.recovery.admin.boot.config.ds;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||
import com.recovery.common.base.ds.DynamicDataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
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);
|
||||
//设置默认数据源
|
||||
dynamicDataSource.setDefaultTargetDataSource(masterDataSource);
|
||||
//
|
||||
return dynamicDataSource;
|
||||
}
|
||||
|
||||
@Bean(name = "commonSqlSessionFactory")
|
||||
@Primary
|
||||
public SqlSessionFactory sqlSessionFactory(
|
||||
@Qualifier("commonDataSource") DataSource dynamicDataSource)
|
||||
throws Exception {
|
||||
// SqlSessionFactoryBean
|
||||
// bean = new SqlSessionFactoryBean();
|
||||
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
|
||||
bean.setDataSource(dynamicDataSource);
|
||||
bean.setMapperLocations(new PathMatchingResourcePatternResolver()
|
||||
.getResources(DataSourceConfig.MAPPER_LOCATION));
|
||||
bean.setTransactionFactory(new SpringManagedTransactionFactory());
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
//package com.recovery.admin.boot.config.ds;
|
||||
//
|
||||
//
|
||||
//
|
||||
//import com.alibaba.druid.pool.DruidDataSource;
|
||||
//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||
//import io.seata.rm.datasource.DataSourceProxy;
|
||||
//import org.apache.ibatis.session.SqlSessionFactory;
|
||||
//import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
//import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
//
|
||||
//import javax.sql.DataSource;
|
||||
//
|
||||
//
|
||||
////使用seata对DataSource进行代理
|
||||
//@Configuration
|
||||
//public class DataSourceProxyConfig {
|
||||
//
|
||||
// //mapper.xml路径
|
||||
// static final String MAPPER_LOCATION = "classpath:mapper/*.xml";
|
||||
//
|
||||
// //手动配置bean
|
||||
// @Bean
|
||||
// @ConfigurationProperties(prefix = "master.datasource")
|
||||
// public DataSource druidDataSource(){
|
||||
//
|
||||
// return new DruidDataSource();
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public SqlSessionFactory sessionFactory(DataSourceProxy dataSourceProxy) throws Exception {
|
||||
// MybatisSqlSessionFactoryBean sessionFactoryBean = new MybatisSqlSessionFactoryBean();
|
||||
// sessionFactoryBean.setDataSource(dataSourceProxy);
|
||||
// sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(MAPPER_LOCATION));
|
||||
// //事务管理工厂
|
||||
// sessionFactoryBean.setTransactionFactory(new SpringManagedTransactionFactory());
|
||||
// return sessionFactoryBean.getObject();
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public DataSourceProxy dataSource() {
|
||||
// DataSource source = druidDataSource();
|
||||
// return new DataSourceProxy(druidDataSource());
|
||||
// }
|
||||
//}
|
|
@ -1,47 +0,0 @@
|
|||
package com.recovery.admin.boot.config.redis;
|
||||
|
||||
public interface RedisCache {
|
||||
/**
|
||||
* 描述:获取缓存
|
||||
*/
|
||||
public String get(String key);
|
||||
public Object get_obj(String key);
|
||||
/**
|
||||
* 描述:删除缓存
|
||||
*/
|
||||
public void remove(String key);
|
||||
/**
|
||||
* 描述:添加缓存
|
||||
*/
|
||||
public void put(String key, String value);
|
||||
public void put_obj(String key, Object value);
|
||||
|
||||
/**
|
||||
* 描述:添加缓存并且添加失效时间
|
||||
*/
|
||||
public void put(String key, String value, int second);
|
||||
public void put_obj(String key, Object value, int second);
|
||||
/**
|
||||
* 描述:根据缓存value值加减
|
||||
*/
|
||||
public long incr(String key, long value);
|
||||
|
||||
/**
|
||||
* 描述:设置超时时间
|
||||
*/
|
||||
public void expire(String key);
|
||||
public void expireDays(String key,int days);
|
||||
|
||||
/**
|
||||
* 是否存在
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
Boolean isExists(String key);
|
||||
|
||||
/**
|
||||
* 清除某类key
|
||||
* @param patten
|
||||
*/
|
||||
public void clean(String patten);
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
package com.recovery.admin.boot.config.redis;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component("RedisCacheImpl")
|
||||
public class RedisCacheImpl implements RedisCache {
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate_obj;
|
||||
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
if (null == key) {
|
||||
return null;
|
||||
}
|
||||
ValueOperations<String, String> operations = redisTemplate.opsForValue();
|
||||
return operations.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get_obj(String key) {
|
||||
if (null == key) {
|
||||
return null;
|
||||
}
|
||||
return redisTemplate_obj.opsForValue().get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String key) {
|
||||
if (redisTemplate.hasKey(key)) {
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, String value) {
|
||||
try {
|
||||
ValueOperations<String, String> operations = redisTemplate.opsForValue();
|
||||
operations.set(key, value);
|
||||
} catch (Exception err) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put_obj(String key, Object value) {
|
||||
redisTemplate_obj.opsForValue().set(key,value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, String value, int second) {
|
||||
ValueOperations<String, String> operations = redisTemplate.opsForValue();
|
||||
operations.set(key, value, second, TimeUnit.SECONDS);
|
||||
}
|
||||
@Override
|
||||
public void put_obj(String key, Object value, int second) {
|
||||
redisTemplate_obj.opsForValue().set(key, value, second, TimeUnit.SECONDS);
|
||||
}
|
||||
@Override
|
||||
public long incr(String key, long value) {
|
||||
ValueOperations<String, String> operations = redisTemplate.opsForValue();
|
||||
return operations.increment(key,value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expire(String key) {
|
||||
try {
|
||||
redisTemplate.expire(key, 15, TimeUnit.DAYS);
|
||||
} catch (Exception err) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expireDays(String key, int days) {
|
||||
try {
|
||||
redisTemplate.expire(key, days, TimeUnit.DAYS);
|
||||
} catch (Exception err) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isExists(String key) {
|
||||
if(redisTemplate.hasKey(key)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clean(String patten) {
|
||||
Set<String> keys = redisTemplate.keys(patten);
|
||||
if(keys.size() > 0) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package com.recovery.admin.boot.controller;
|
||||
|
||||
|
||||
import com.recovery.admin.boot.service.UserService;
|
||||
|
||||
import com.recovery.common.base.dto.MemberUserAuthDTO;
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/users")
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
@GetMapping("/username")
|
||||
public ApiResult<UserAuthDTO> getUserByUsername(@RequestParam String username) {
|
||||
UserAuthDTO user = userService.getByUsername(username);
|
||||
return ApiResult.ok(user);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package com.recovery.admin.boot.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.recovery.admin.boot.config.DynamicThreadPoolConfig;
|
||||
import com.recovery.admin.boot.entity.User;
|
||||
import com.recovery.admin.boot.service.UserService;
|
||||
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 com.recovery.common.base.util.UtilTools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.data.annotation.Reference;
|
||||
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;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/test")
|
||||
@Slf4j
|
||||
@RefreshScope
|
||||
public class testController {
|
||||
|
||||
@Resource
|
||||
UserService userService;
|
||||
@Resource
|
||||
RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private DynamicThreadPoolConfig dynamicThreadPool;
|
||||
|
||||
@Value("${sa-token.token-name}")
|
||||
private String tokenHeader;
|
||||
|
||||
/**
|
||||
* cs
|
||||
*/
|
||||
@GetMapping("/cs")
|
||||
public ApiResult<UserAuthDTO> cs(@RequestParam String name, HttpServletRequest request) {
|
||||
try {
|
||||
User user = new User();
|
||||
user.setUserName("测试库");
|
||||
user.setPhone("123");
|
||||
List<User> list = userService.list();
|
||||
log.info("测试库:"+list.size());
|
||||
}catch (Exception e) {
|
||||
return ApiResult.failed(e.getMessage());
|
||||
}
|
||||
|
||||
// try {
|
||||
// UserAuthDTO authDTO = userService.getByUsername(name);
|
||||
// List<User> l = userService.list();
|
||||
|
||||
// log.info("测试库:"+authDTO.getStatus());
|
||||
// log.info("111获取线程的数据=="+HspHostUtil.getHspHost());
|
||||
// log.info("获取登陆值去除------"+ UtilTools.getUserId() +"");
|
||||
// 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);
|
||||
// }catch (Exception e){
|
||||
// log.info("cs异常"+e.getMessage(),e);
|
||||
// return ApiResult.failed("cs异常");
|
||||
// }
|
||||
return ApiResult.ok();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* cs
|
||||
*/
|
||||
@GetMapping("/cs1")
|
||||
public ApiResult ccss(HttpServletRequest request) {
|
||||
String user = StpUtil.getLoginIdDefaultNull()+"";
|
||||
StpUtil.kickout(StpUtil.getLoginId());
|
||||
// StpUtil.logout();
|
||||
return ApiResult.ok("踢下线");
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
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;
|
||||
|
||||
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
package com.recovery.admin.boot.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author ytChen
|
||||
* @since 2024-01-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("tbl_user")
|
||||
public class User implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
// /**
|
||||
// * 性别1=男2=女
|
||||
// */
|
||||
// private Integer gender;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
// /**
|
||||
// * 货场名称
|
||||
// */
|
||||
// private String factoryName;
|
||||
//
|
||||
// /**
|
||||
// * 货场详细地址
|
||||
// */
|
||||
// private String factoryAddress;
|
||||
//
|
||||
// /**
|
||||
// * 省份id
|
||||
// */
|
||||
// private Integer provinceId;
|
||||
// /**
|
||||
// * 市区id
|
||||
// */
|
||||
// private Integer areaId;
|
||||
// /**
|
||||
// * 县id
|
||||
// */
|
||||
// private Integer citiyId;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 用户类别 1= 工作人员 2=采购商3=客户
|
||||
// */
|
||||
// private Integer userType;
|
||||
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
// /**
|
||||
// * 状态 1=有效 0=无效
|
||||
// */
|
||||
// private Integer state;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 修改时间
|
||||
// */
|
||||
// @Column(name = "update_time")
|
||||
// private LocalDateTime updateTime;
|
||||
//
|
||||
// /**
|
||||
// * 创建时间
|
||||
// */
|
||||
// @Column(name = "create_time")
|
||||
// private LocalDateTime createTime;
|
||||
//
|
||||
// /**
|
||||
// * 创建人id
|
||||
// */
|
||||
// @Column(name = "create_user_id")
|
||||
// private Long createUserId;
|
||||
//
|
||||
// /**
|
||||
// * 修改人id
|
||||
// */
|
||||
// @Column(name = "update_user_id")
|
||||
// private Long updateUserId;
|
||||
|
||||
//
|
||||
// /**
|
||||
// * 删除状态
|
||||
// */
|
||||
// private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
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("请求方式不支持");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package com.recovery.admin.boot.feign;
|
||||
|
||||
|
||||
|
||||
import com.recovery.common.base.config.feign.FeignConfiguration;
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@FeignClient(value = "hoe-order",configuration = FeignConfiguration.class)
|
||||
public interface OrderFeignClient {
|
||||
|
||||
@RequestMapping("/api/rest/order/test")
|
||||
String test();
|
||||
|
||||
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
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) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
package com.recovery.admin.boot.interceptor;
|
||||
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import com.recovery.admin.boot.exception.BusinessException;
|
||||
import com.recovery.common.base.constant.Constants;
|
||||
import com.recovery.common.base.result.ResultCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
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;
|
||||
|
||||
@Slf4j
|
||||
@RefreshScope
|
||||
public class JwtInterceptor implements HandlerInterceptor {
|
||||
|
||||
|
||||
|
||||
public JwtInterceptor() {}
|
||||
@Value("${sa-token.token-name}")
|
||||
private String tokenHeader;
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 获取当前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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package com.recovery.admin.boot.listener;
|
||||
|
||||
|
||||
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 {
|
||||
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
log.info("刷新权限------------------------------");
|
||||
// iSysPermissionService.refreshPermRolesRules();
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.recovery.admin.boot.mapper;
|
||||
|
||||
|
||||
|
||||
import com.recovery.admin.boot.entity.User;
|
||||
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import com.recovery.common.mybatis.config.MyMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends MyMapper<User> {
|
||||
|
||||
UserAuthDTO getByUsername(@Param("userName") String userName);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package com.recovery.admin.boot.rest;
|
||||
|
||||
|
||||
import com.recovery.admin.boot.service.UserService;
|
||||
import com.recovery.common.base.dto.MemberUserAuthDTO;
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/rest/users")
|
||||
@Slf4j
|
||||
public class UserRest {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
@GetMapping("/getUserByUsername")
|
||||
public ApiResult<UserAuthDTO> getUserByUsername(@RequestParam(value = "username") String username) {
|
||||
UserAuthDTO user = userService.getByUsername(username);
|
||||
if (user == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
return ApiResult.ok(user);
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
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 UserService extends IService<User> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户名获取认证用户信息,携带角色和密码
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
UserAuthDTO getByUsername(String username);
|
||||
|
||||
|
||||
|
||||
void add(User user);
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
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.feign.OrderFeignClient;
|
||||
import com.recovery.admin.boot.mapper.UserMapper;
|
||||
import com.recovery.admin.boot.service.UserService;
|
||||
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||
@Resource
|
||||
OrderFeignClient orderFeignClient;
|
||||
@Override
|
||||
public UserAuthDTO getByUsername(String username) {
|
||||
UserAuthDTO userAuthInfo = this.baseMapper.getByUsername(username);
|
||||
return userAuthInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void add(User user) {
|
||||
user.setUserName("123");
|
||||
this.baseMapper.insert(user);
|
||||
String sc= orderFeignClient.test();
|
||||
|
||||
System.out.println("123");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
spring:
|
||||
datasource:
|
||||
dynamic:
|
||||
seata: true
|
||||
application:
|
||||
name: hoe-admin
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
allow-circular-references: true
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
# discovery:
|
||||
# metadata:
|
||||
# serviceGroup: cpp
|
||||
config:
|
||||
server-addr: 192.168.110.210:8848
|
||||
file-extension: yaml
|
||||
prefix: ${spring.application.name}
|
||||
group: ${spring.profiles.active}
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
#Nacos Config 目前提供了三种配置能力从 Nacos 拉取相关的配置
|
||||
#A: 通过 spring.cloud.nacos.config.shared-dataids 支持多个共享 Data Id 的配置
|
||||
#B: 通过 spring.cloud.nacos.config.ext-config[n].data-id 的方式支持多个扩展 Data Id 的配置
|
||||
#C: 通过内部相关规则(应用名、应用名+ Profile )自动生成相关的 Data Id 配置
|
||||
#当三种方式共同使用时,他们的一个优先级关系是:A < B < C
|
||||
# 共享的配置,比如连接池之类的 需要注意共享配置不区分环境默认就是DEFAULT_GROUP
|
||||
shared-configs: # 多微服务间共享的配置列表
|
||||
- dataId: share.yaml # 要共享的配置文件id
|
||||
refresh: true
|
||||
server:
|
||||
port: 9002
|
||||
|
||||
|
||||
|
||||
#分布式事务
|
||||
#seata:
|
||||
# enabled: true
|
||||
# enable-auto-data-source-proxy: false
|
||||
# config:
|
||||
# type: nacos
|
||||
# nacos:
|
||||
# server-addr: localhost:8848
|
||||
# group: SEATA_GROUP
|
||||
# username: nacos
|
||||
# password: nacos
|
||||
# data-id: seataServer.properties
|
||||
# namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
# registry:
|
||||
# type: nacos
|
||||
# nacos:
|
||||
# application: seata-server
|
||||
# server-addr: localhost:8848
|
||||
# group: SEATA_GROUP
|
||||
# username: nacos
|
||||
# password: nacos
|
||||
# namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
|
@ -1,53 +0,0 @@
|
|||
<?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>
|
|
@ -1,175 +0,0 @@
|
|||
<?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>
|
|
@ -1,53 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.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>
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.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>
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.recovery.admin.boot.mapper.UserMapper">
|
||||
|
||||
|
||||
<select id="getByUsername" resultType="com.recovery.common.base.dto.UserAuthDTO">
|
||||
select t1.name, 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>
|
|
@ -1,115 +0,0 @@
|
|||
//package code;
|
||||
//
|
||||
//import cn.hutool.extra.template.TemplateConfig;
|
||||
//import com.baomidou.mybatisplus.annotation.DbType;
|
||||
//import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
||||
//import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
//import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
//import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.*;
|
||||
//import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
//import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||
//import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
//import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
|
||||
//import com.recovery.admin.boot.config.ds.DataSourceConfig;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class CodeGenerator {
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// // 代码生成器
|
||||
// AutoGenerator mpg = new AutoGenerator();
|
||||
//
|
||||
// // 全局配置
|
||||
// GlobalConfig gc = new GlobalConfig();
|
||||
// String projectPath = System.getProperty("user.dir");
|
||||
// gc.setOutputDir(projectPath + "/src/main/java");
|
||||
// gc.setAuthor("ytChen");
|
||||
// gc.setOpen(false);
|
||||
//// gc.setEntityName("%sEntity");
|
||||
// gc.setBaseColumnList(true);
|
||||
// //去除生成的Service前缀I
|
||||
// gc.setServiceName("%sService");
|
||||
// gc.setBaseResultMap(true);
|
||||
// gc.setDateType(DateType.ONLY_DATE);
|
||||
// gc.setSwagger2(false); //实体属性 Swagger2 注解
|
||||
// mpg.setGlobalConfig(gc);
|
||||
//
|
||||
// // 数据源配置
|
||||
// DataSourceConfig dsc = new DataSourceConfig();
|
||||
// dsc.setUrl("jdbc:mysql://124.70.167.140:3306/avatar_dev?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useSSL=false");
|
||||
// //dsc.setDriverName("dm.jdbc.driver.DmDriver"); //jdk 1.8使用这个 9之后就要下面的
|
||||
// dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
||||
// dsc.setUsername("avatar");
|
||||
// dsc.setPassword("p9_34K_l1");
|
||||
// dsc.setDbType(DbType.MYSQL);
|
||||
// mpg.setDataSource(dsc);
|
||||
//
|
||||
// // 包配置
|
||||
// PackageConfig pc = new PackageConfig();
|
||||
//// pc.setModuleName(scanner("模块名"));
|
||||
// pc.setParent("com.recovery.order");
|
||||
// mpg.setPackageInfo(pc);
|
||||
//
|
||||
// // 自定义配置
|
||||
// InjectionConfig cfg = new InjectionConfig() {
|
||||
// @Override
|
||||
// public void initMap() {
|
||||
// // to do nothing
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// // 如果模板引擎是 velocity
|
||||
// String templatePath = "/templates/mapper.xml.vm";
|
||||
//
|
||||
// // 自定义输出配置
|
||||
// List<FileOutConfig> focList = new ArrayList<>();
|
||||
// // 自定义配置会被优先输出
|
||||
// focList.add(new FileOutConfig(templatePath) {
|
||||
// @Override
|
||||
// public String outputFile(TableInfo tableInfo) {
|
||||
// // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
|
||||
//// return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
|
||||
//// + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
|
||||
// return projectPath + "/src/main/resources/mapper" + pc.getModuleName()
|
||||
// + "/" + tableInfo.getEntityName() + "Mapper"
|
||||
// + StringPool.DOT_XML;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// cfg.setFileOutConfigList(focList);
|
||||
// mpg.setCfg(cfg);
|
||||
//
|
||||
// // 配置模板
|
||||
// TemplateConfig templateConfig = new TemplateConfig();
|
||||
//
|
||||
// // 配置自定义输出模板
|
||||
// //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
|
||||
// templateConfig.setEntity("templates/entity.java");
|
||||
// // templateConfig.setService();
|
||||
// templateConfig.setController(null);
|
||||
// templateConfig.setXml(null);
|
||||
// mpg.setTemplate(templateConfig);
|
||||
//
|
||||
// // 策略配置
|
||||
// StrategyConfig strategy = new StrategyConfig();
|
||||
// strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||
// strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
||||
//// strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!");
|
||||
// strategy.setEntityLombokModel(true);
|
||||
// strategy.setRestControllerStyle(true);
|
||||
// // 公共父类
|
||||
//// strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!");
|
||||
// // 写于父类中的公共字段
|
||||
//// strategy.setSuperEntityColumns("id");
|
||||
// strategy.setInclude("tbl_notice_info");
|
||||
// strategy.setSuperMapperClass("com.recovery.common.mybatis.config.MyMapper");
|
||||
// strategy.setControllerMappingHyphenStyle(true);
|
||||
// strategy.setTablePrefix("tbl" + "_"); //生成实体时去掉表前缀
|
||||
// mpg.setStrategy(strategy);
|
||||
// mpg.setTemplateEngine(new VelocityTemplateEngine());
|
||||
// mpg.execute();
|
||||
// }
|
||||
//}
|
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 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>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -1,93 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 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>
|
||||
|
||||
|
||||
<!-- 添加Hibernate Validator依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>6.2.0.Final</version>
|
||||
</dependency>
|
||||
<!-- 添加Hibernate Validator依赖所需的依赖项 -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>jakarta.el</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</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>
|
|
@ -1,24 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
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 为您提供服务";
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
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"));
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
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();
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
package com.recovery.auth.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 = "authSqlSessionFactory")
|
||||
public class DataSourceConfig {
|
||||
|
||||
// 精确到模块目录,以便跟其他数据源隔离
|
||||
static final String PACKAGE = "com.recovery.auth.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 = "authDataSource")
|
||||
@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 = "authSqlSessionFactory")
|
||||
@Primary
|
||||
public SqlSessionFactory sqlSessionFactory(
|
||||
@Qualifier("authDataSource") DataSource dynamicDataSource)
|
||||
throws Exception {
|
||||
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
|
||||
bean.setDataSource(dynamicDataSource);
|
||||
bean.setMapperLocations(new PathMatchingResourcePatternResolver()
|
||||
.getResources(DataSourceConfig.MAPPER_LOCATION));
|
||||
return bean.getObject();
|
||||
|
||||
}
|
||||
|
||||
@Bean(name = "authTransactionManager")
|
||||
@Primary
|
||||
public DataSourceTransactionManager authTransactionManager() {
|
||||
return new DataSourceTransactionManager(dynamicDataSource());
|
||||
}
|
||||
|
||||
|
||||
@Bean(name = "authSqlSessionTemplate")
|
||||
public SqlSessionTemplate sqlSessionTemplate(
|
||||
@Qualifier("authSqlSessionFactory") SqlSessionFactory sqlSessionFactory)
|
||||
throws Exception {
|
||||
return new SqlSessionTemplate(sqlSessionFactory);
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
//package com.recovery.auth.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 {
|
||||
// // 精确到 auth 目录,以便跟其他数据源隔离
|
||||
// static final String PACKAGE = "com.recovery.auth.dao.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();
|
||||
// }
|
||||
//}
|
|
@ -1,98 +0,0 @@
|
|||
package com.recovery.auth.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.recovery.auth.exception.BusinessException;
|
||||
import com.recovery.auth.feign.UserFeignClient;
|
||||
import com.recovery.auth.security.details.user.JwtAuthenticationRequest;
|
||||
import com.recovery.auth.service.AuthService;
|
||||
import com.recovery.common.base.config.redis.BaseRedisCache;
|
||||
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.result.ResultCode;
|
||||
import com.recovery.common.base.util.EncryptUtil;
|
||||
import com.recovery.common.base.util.HspHostUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/oauth")
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
public class AuthController {
|
||||
|
||||
@Resource
|
||||
AuthService authService;
|
||||
@Resource
|
||||
UserFeignClient userFeignClient;
|
||||
@Resource
|
||||
BaseRedisCache redisCache;
|
||||
|
||||
@PostMapping("/token")
|
||||
public ApiResult postAccessToken(@RequestBody JwtAuthenticationRequest authenticationRequest, HttpServletRequest request){
|
||||
log.info("----------------获取token");
|
||||
HashMap map= new HashMap();
|
||||
try {
|
||||
map = authService.login(authenticationRequest, request);
|
||||
}catch (Exception e){
|
||||
log.error("获取token:"+e.getMessage(),e);
|
||||
return ApiResult.failed(e.getMessage());
|
||||
}
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
@PostMapping("/doLogin")
|
||||
public ApiResult doLogin(@RequestBody JwtAuthenticationRequest authenticationRequest) {
|
||||
if(StringUtils.isEmpty(authenticationRequest.getUsername())){
|
||||
throw new BusinessException("账户不能为空");
|
||||
}
|
||||
if(StringUtils.isEmpty(authenticationRequest.getPassword())){
|
||||
throw new BusinessException("密码不能为空");
|
||||
}
|
||||
|
||||
ApiResult<UserAuthDTO> result = userFeignClient.getUserByUsername(authenticationRequest.getUsername());
|
||||
UserAuthDTO userDetails = new UserAuthDTO();
|
||||
if (ResultCode.SUCCESS.getCode().equals(result.getCode())) {
|
||||
userDetails = result.getData();
|
||||
}
|
||||
// 数据库中查询数据进行比对
|
||||
if (userDetails.getUserName().equals(authenticationRequest.getUsername())
|
||||
&& userDetails.getPassword().equals(EncryptUtil.encrypt(authenticationRequest.getPassword())))
|
||||
{
|
||||
log.info("密码校验成功!");
|
||||
StpUtil.login(HspHostUtil.getHspHost()+":"+userDetails.getUserId(),"PC");
|
||||
}else {
|
||||
return ApiResult.failed("密码错误");
|
||||
}
|
||||
//认证通过 使用userid 储存用户信息
|
||||
try {
|
||||
redisCache.put_obj(Constants.REDIS_USRE_INFO + userDetails.getUserId(),userDetails , Constants.REDIS_TOKEN_TIME);
|
||||
} catch (Exception e) {
|
||||
log.error("redis储存token报错"+e.getMessage(),e);
|
||||
}
|
||||
// 第3步,返回给前端
|
||||
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
|
||||
HashMap map= new HashMap();
|
||||
map.put("token",tokenInfo.getTokenValue());
|
||||
map.put("user",userDetails);
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
// @GetMapping("/public-key")
|
||||
// public Map<String, Object> getPublicKey() {
|
||||
// //单例模式
|
||||
//
|
||||
// return “吃啥;
|
||||
// }
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package com.recovery.auth.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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package com.recovery.auth.exception;
|
||||
|
||||
|
||||
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import com.recovery.common.base.result.ResultCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* 全局异常处理
|
||||
*/
|
||||
@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());
|
||||
}
|
||||
|
||||
//Security
|
||||
// @ExceptionHandler(value = AccessDeniedException.class)
|
||||
// public void accessDeniedException(AccessDeniedException e) {
|
||||
// throw e;
|
||||
// }
|
||||
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package com.recovery.auth.feign;
|
||||
|
||||
|
||||
|
||||
import com.recovery.common.base.config.feign.FeignConfiguration;
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
@FeignClient(value = "hoe-admin",configuration = FeignConfiguration.class)
|
||||
public interface UserFeignClient {
|
||||
|
||||
@GetMapping("/api/rest/users/getUserByUsername")
|
||||
ApiResult<UserAuthDTO> getUserByUsername(@RequestParam(value = "username") String username);
|
||||
|
||||
@GetMapping("/api/rest/users/member/username")
|
||||
ApiResult<UserAuthDTO> getMemberUserByUsername(@RequestParam(value = "username") String username);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package com.recovery.auth.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.recovery.common.base.po.base.OauthClientDetails;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【oauth_client_details(存储客户端的配置信息)】的数据库操作Mapper
|
||||
* @createDate 2024-03-04 10:33:19
|
||||
* @Entity dao.entiy.OauthClientDetails
|
||||
*/
|
||||
@Mapper
|
||||
public interface OauthClientDetailsMapper extends BaseMapper<OauthClientDetails> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
package com.recovery.auth.rest;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
@Slf4j
|
||||
public class UserRest {
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package com.recovery.auth.security.details.user;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class JwtAuthenticationRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8445943548965154778L;
|
||||
|
||||
private String username;
|
||||
private String phone;
|
||||
private String password;
|
||||
private String verifyCode;
|
||||
private String loginMethod;
|
||||
private String visitorsType;
|
||||
|
||||
public JwtAuthenticationRequest(String username,String phone,String password,String verifyCode,String loginMethod,String visitorsType) {
|
||||
this.username = username;
|
||||
this.phone = phone;
|
||||
this.password = password;
|
||||
this.verifyCode = verifyCode;
|
||||
this.loginMethod = loginMethod;
|
||||
this.visitorsType = visitorsType;
|
||||
}
|
||||
|
||||
public JwtAuthenticationRequest() {
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getUserPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setUserPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getVerifyCode() {
|
||||
return verifyCode;
|
||||
}
|
||||
|
||||
public void setVerifyCode(String verifyCode) {
|
||||
this.verifyCode = verifyCode;
|
||||
}
|
||||
|
||||
public String getLoginMethod() {
|
||||
return loginMethod;
|
||||
}
|
||||
|
||||
public void setLoginMethod(String loginMethod) {
|
||||
this.loginMethod = loginMethod;
|
||||
}
|
||||
public String getVisitorsType() {
|
||||
return visitorsType;
|
||||
}
|
||||
|
||||
public void setVisitorsType(String visitorsType) {
|
||||
this.visitorsType = visitorsType;
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.recovery.auth.service;
|
||||
|
||||
import com.recovery.auth.security.details.user.JwtAuthenticationRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface AuthService {
|
||||
|
||||
HashMap login(JwtAuthenticationRequest authenticationRequest, HttpServletRequest request);
|
||||
}
|
||||
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.recovery.auth.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.recovery.common.base.po.base.OauthClientDetails;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【oauth_client_details(存储客户端的配置信息)】的数据库操作Service
|
||||
* @createDate 2024-03-04 10:33:19
|
||||
*/
|
||||
public interface OauthClientDetailsService extends IService<OauthClientDetails> {
|
||||
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
package com.recovery.auth.service.impl;
|
||||
|
||||
|
||||
import com.recovery.auth.exception.BusinessException;
|
||||
import com.recovery.auth.feign.UserFeignClient;
|
||||
import com.recovery.auth.security.details.user.JwtAuthenticationRequest;
|
||||
import com.recovery.auth.service.AuthService;
|
||||
import com.recovery.common.base.dto.UserAuthDTO;
|
||||
import com.recovery.common.base.dto.UserAuthorityDto;
|
||||
import com.recovery.common.base.result.ApiResult;
|
||||
import com.recovery.common.base.result.ResultCode;
|
||||
import com.recovery.common.base.util.EncryptUtil;
|
||||
import com.recovery.common.base.util.RedisUtil;
|
||||
import com.recovery.common.base.utils.JwtUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【oauth_client_details(存储客户端的配置信息)】的数据库操作Service
|
||||
* @createDate 2024-03-04 10:33:19
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AuthServiceImpl implements AuthService {
|
||||
|
||||
@Resource
|
||||
UserFeignClient userFeignClient;
|
||||
@Resource
|
||||
RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public HashMap login(JwtAuthenticationRequest authenticationRequest, HttpServletRequest request) {
|
||||
HashMap map = new HashMap();
|
||||
if(null == authenticationRequest.getUsername() || "".equals(authenticationRequest.getUsername())){
|
||||
throw new BusinessException("账户不能为空");
|
||||
}
|
||||
if(null == authenticationRequest.getPassword() || "".equals(authenticationRequest.getPassword())){
|
||||
throw new BusinessException("密码不能为空");
|
||||
}
|
||||
|
||||
ApiResult<UserAuthDTO> result = userFeignClient.getUserByUsername(authenticationRequest.getUsername());
|
||||
UserAuthorityDto userDetails = new UserAuthorityDto();
|
||||
if (ResultCode.SUCCESS.getCode().equals(result.getCode())) {
|
||||
UserAuthDTO user = result.getData();
|
||||
if (null != user) {
|
||||
userDetails.setUserName(user.getUserName());
|
||||
userDetails.setId(user.getUserId());
|
||||
userDetails.setPassword(user.getPassword());
|
||||
}
|
||||
}
|
||||
|
||||
if (Objects.isNull(userDetails)) {
|
||||
throw new BusinessException(result.getMsg());
|
||||
}
|
||||
//加密
|
||||
if (userDetails.getUserName().equals(authenticationRequest.getUsername()) && userDetails.getPassword().equals(EncryptUtil.encrypt(authenticationRequest.getPassword()))) {
|
||||
log.info("密码校验成功!");
|
||||
} else {
|
||||
throw new BusinessException("密码错误!");
|
||||
}
|
||||
//用户信息
|
||||
map.put("userId", userDetails.toString());
|
||||
map.put("name", userDetails.getName());
|
||||
map.put("userName", userDetails.getUserName());
|
||||
map.put("password",userDetails.getPassword());
|
||||
//生成token
|
||||
String token = JwtUtils.generateToken(map);
|
||||
//token
|
||||
map.put("userInfo", userDetails);
|
||||
map.put("token", token);
|
||||
|
||||
//认证通过 使用userid 生成jwt token令牌
|
||||
try {
|
||||
boolean resultRedis = redisUtil.set("userToken:" + token,userDetails , 24 * 600 * 7);
|
||||
if (!resultRedis) {
|
||||
throw new RuntimeException("网络链接失败,登录失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package com.recovery.auth.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import com.recovery.auth.mapper.OauthClientDetailsMapper;
|
||||
import com.recovery.auth.service.OauthClientDetailsService;
|
||||
import com.recovery.common.base.po.base.OauthClientDetails;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【oauth_client_details(存储客户端的配置信息)】的数据库操作Service实现
|
||||
* @createDate 2024-03-04 10:33:19
|
||||
*/
|
||||
@Service
|
||||
public class OauthClientDetailsServiceImpl extends ServiceImpl<OauthClientDetailsMapper, OauthClientDetails> implements OauthClientDetailsService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
spring:
|
||||
application:
|
||||
name: hoe-auth
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
allow-circular-references: true
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# metadata:
|
||||
# serviceGroup: ytChen
|
||||
# server-addr: 192.168.110.210:8848
|
||||
# namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
config:
|
||||
server-addr: 192.168.110.210:8848
|
||||
file-extension: yaml
|
||||
prefix: hoe-auth
|
||||
group: dev
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
shared-dataids: share.yaml
|
||||
server:
|
||||
port: 9001
|
Binary file not shown.
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.recovery.auth.mapper.OauthClientDetailsMapper">
|
||||
|
||||
|
||||
</mapper>
|
|
@ -1,36 +0,0 @@
|
|||
|
||||
spring:
|
||||
application:
|
||||
name: hoe-auth
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
allow-circular-references: true
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# metadata:
|
||||
# serviceGroup: ytChen
|
||||
server-addr: 192.168.110.210:8848
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
config:
|
||||
server-addr: 192.168.110.210:8848
|
||||
file-extension: yaml
|
||||
prefix: hoe-auth
|
||||
group: dev
|
||||
namespace: 11bfd099-10d6-4f2c-b969-58b76e435cce
|
||||
server:
|
||||
port: 9001
|
||||
|
||||
|
||||
|
||||
sa-token:
|
||||
# jwt秘钥
|
||||
jwt-secret-key: asdasdasifhueuiwyurfewbfjsdafjk123
|
||||
token-name: satoken
|
||||
timeout: -1
|
||||
active-timeout: -1
|
||||
is-concurrent: false
|
||||
is-share: false
|
||||
is-log: true
|
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.
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.recovery.auth.mapper.OauthClientDetailsMapper">
|
||||
|
||||
|
||||
</mapper>
|
|
@ -1,95 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.recovery</groupId>
|
||||
<artifactId>hoe-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
</parent>
|
||||
|
||||
<artifactId>common-base</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session</artifactId>
|
||||
<version>1.3.3.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
<version>3.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.2.6</version>
|
||||
</dependency>
|
||||
<!-- openfeign依赖 1. http客户端选择okhttp 2. loadbalancer替换ribbon -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--引入jwt-->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>3.11.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,4 +0,0 @@
|
|||
package com.recovery.common.base.config;
|
||||
|
||||
public class GlobalCorsConfig {
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package com.recovery.common.base.config.feign;
|
||||
|
||||
|
||||
import cn.dev33.satoken.same.SaSameUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.recovery.common.base.util.HspHostUtil;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class CommonRequestInterceptor implements RequestInterceptor{
|
||||
|
||||
@Override
|
||||
public void apply(RequestTemplate requestTemplate) {
|
||||
// SaSameToken 主要用于实现网关统一请求。即请求不能绕过网关去访问某个具体的服务
|
||||
requestTemplate.header(SaSameUtil.SAME_TOKEN, SaSameUtil.getToken());
|
||||
|
||||
// 如果希望被调用方有会话状态,此处就还需要将 satoken 添加到请求头中
|
||||
requestTemplate.header(StpUtil.getTokenName(), StpUtil.getTokenValue());
|
||||
HttpServletRequest request = getHttpServletRequest();
|
||||
if(request != null && request.getHeader("hospitalHost") != null){
|
||||
String hospitalHost = request.getHeader("hospitalHost");
|
||||
|
||||
String hospiatlProt = request.getHeader("hospiatlProt");
|
||||
String websiteDomain = request.getHeader("websiteDomain");
|
||||
String innerInternet = request.getHeader("innerInternet");
|
||||
String token = request.getHeader("userTokenHead");
|
||||
requestTemplate.header("hospitalHost", hospitalHost);
|
||||
requestTemplate.header("innerInternet", innerInternet);
|
||||
requestTemplate.header("websiteDomain",websiteDomain);
|
||||
requestTemplate.header("hospiatlProt",hospiatlProt);
|
||||
requestTemplate.header("userTokenHead",token);
|
||||
requestTemplate.header("feign","true");
|
||||
} else {
|
||||
//取当前线程变量中的域名进行传递
|
||||
requestTemplate.header("hospitalHost", HspHostUtil.getHspHost());
|
||||
requestTemplate.header("feign","true");
|
||||
}
|
||||
}
|
||||
|
||||
private HttpServletRequest getHttpServletRequest() {
|
||||
try {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if(attributes != null){
|
||||
return attributes.getRequest();
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package com.recovery.common.base.config.feign;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class FeignConfiguration {
|
||||
|
||||
@Bean
|
||||
CommonRequestInterceptor getCommonRequestInterceptor(){
|
||||
return new CommonRequestInterceptor();
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package com.recovery.common.base.config.redis;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface BaseRedisCache {
|
||||
/**
|
||||
* 描述:获取缓存
|
||||
*/
|
||||
public String get(String key);
|
||||
public Object get_obj(String key);
|
||||
/**
|
||||
* 描述:删除缓存
|
||||
*/
|
||||
public void remove(String key);
|
||||
/**
|
||||
* 描述:添加缓存
|
||||
*/
|
||||
public void put(String key, String value);
|
||||
public void put_obj(String key, Object value);
|
||||
|
||||
/**
|
||||
* 描述:添加缓存并且添加失效时间
|
||||
*/
|
||||
public void put(String key, String value, int second);
|
||||
public void put_obj(String key, Object value, int second);
|
||||
/**
|
||||
* 描述:根据缓存value值加减
|
||||
*/
|
||||
public long incr(String key, long value);
|
||||
|
||||
/**
|
||||
* 描述:设置超时时间
|
||||
*/
|
||||
public void expire(String key);
|
||||
public void expireDays(String key, int days);
|
||||
|
||||
/**
|
||||
* 是否存在
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Boolean isExists(String key);
|
||||
|
||||
/**
|
||||
* 匹配所有key值
|
||||
* @param patten
|
||||
* @return
|
||||
*/
|
||||
public Set<String> keySet(String patten);
|
||||
|
||||
/**
|
||||
* 清除某类key
|
||||
* @param patten
|
||||
*/
|
||||
public void clean(String patten);
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
package com.recovery.common.base.config.redis;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component("BaseRedisCacheImpl")
|
||||
public class BaseRedisCacheImpl implements BaseRedisCache {
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate_obj;
|
||||
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
ValueOperations<String, String> operations = redisTemplate.opsForValue();
|
||||
return operations.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get_obj(String key) {
|
||||
return redisTemplate_obj.opsForValue().get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String key) {
|
||||
if (redisTemplate.hasKey(key)) {
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, String value) {
|
||||
try {
|
||||
if(value == null) {
|
||||
value = "";
|
||||
}
|
||||
ValueOperations<String, String> operations = redisTemplate.opsForValue();
|
||||
operations.set(key, value);
|
||||
} catch (Exception err) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put_obj(String key, Object value) {
|
||||
redisTemplate_obj.opsForValue().set(key,value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, String value, int second) {
|
||||
if(value == null) {
|
||||
value = "";
|
||||
}
|
||||
ValueOperations<String, String> operations = redisTemplate.opsForValue();
|
||||
operations.set(key, value, second, TimeUnit.SECONDS);
|
||||
}
|
||||
@Override
|
||||
public void put_obj(String key, Object value, int second) {
|
||||
redisTemplate_obj.opsForValue().set(key, value, second, TimeUnit.SECONDS);
|
||||
}
|
||||
@Override
|
||||
public long incr(String key, long value) {
|
||||
ValueOperations<String, String> operations = redisTemplate.opsForValue();
|
||||
return operations.increment(key,value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expire(String key) {
|
||||
try {
|
||||
redisTemplate.expire(key, 15, TimeUnit.DAYS);
|
||||
} catch (Exception err) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expireDays(String key, int days) {
|
||||
try {
|
||||
redisTemplate.expire(key, days, TimeUnit.DAYS);
|
||||
} catch (Exception err) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isExists(String key) {
|
||||
if(redisTemplate.hasKey(key)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> keySet(String patten) {
|
||||
return redisTemplate.keys(patten);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clean(String patten) {
|
||||
Set<String> keys = redisTemplate.keys(patten);
|
||||
if(keys.size() > 0) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package com.recovery.common.base.config.redis;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.recovery.common.base.config.redis.RedisObjectSerializer;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.session.data.redis.config.ConfigureRedisAction;
|
||||
|
||||
|
||||
/**
|
||||
* @author RyanWang
|
||||
* @version 1.0.0
|
||||
* @date 16/4/15 下午3:19.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class RedisConfig extends CachingConfigurerSupport{
|
||||
@Bean
|
||||
public ConfigureRedisAction configureRedisAction() {
|
||||
return ConfigureRedisAction.NO_OP;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) {
|
||||
StringRedisTemplate template = new StringRedisTemplate(factory);
|
||||
return template;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
|
||||
template.setConnectionFactory(factory);
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(new RedisObjectSerializer());
|
||||
return template;
|
||||
}
|
||||
|
||||
/**
|
||||
* RedisTemplate配置
|
||||
* @param factory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RedisTemplate<String, String> redisTemplateString(RedisConnectionFactory factory) {
|
||||
StringRedisTemplate template = new StringRedisTemplate(factory);
|
||||
//定义value的序列化方式
|
||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||
|
||||
template.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
template.setHashValueSerializer(jackson2JsonRedisSerializer);
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package com.recovery.common.base.config.redis;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.serializer.support.DeserializingConverter;
|
||||
import org.springframework.core.serializer.support.SerializingConverter;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.SerializationException;
|
||||
|
||||
public class RedisObjectSerializer implements RedisSerializer<Object> {
|
||||
|
||||
private Converter<Object, byte[]> serializer = new SerializingConverter();
|
||||
private Converter<byte[], Object> deserializer = new DeserializingConverter();
|
||||
|
||||
static final byte[] EMPTY_ARRAY = new byte[0];
|
||||
|
||||
@Override
|
||||
public Object deserialize(byte[] bytes) {
|
||||
if (isEmpty(bytes)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return deserializer.convert(bytes);
|
||||
} catch (Exception ex) {
|
||||
throw new SerializationException("Cannot deserialize", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialize(Object object) {
|
||||
if (object == null) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
try {
|
||||
return serializer.convert(object);
|
||||
} catch (Exception ex) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmpty(byte[] data) {
|
||||
return (data == null || data.length == 0);
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package com.recovery.common.base.constant;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Constants {
|
||||
public static int OK = 1;
|
||||
public static int LOGIN_FAIL = 2;
|
||||
public static int PARAM_NULL = 3;
|
||||
public static int PARAM_ERR = 4;
|
||||
public static int SYSTEM_ERR = 5;
|
||||
public static int OTHER = 6;
|
||||
//格式异常
|
||||
public static int FORMAT_ERR=7;
|
||||
public final static String PARAM_NULL_MSG = "参数为空";
|
||||
public final static String PARAM_ERR_MSG = "参数错误";
|
||||
public final static String SYSTEM_ERR_MSG = "系统异常";
|
||||
|
||||
|
||||
|
||||
public final static String UPLOAD_SIZE_ERR_MSG = "上传大小错误";
|
||||
|
||||
|
||||
public static final String LOGIN_USRE_TOKEN = "satoken";
|
||||
|
||||
//token
|
||||
public static final String REDIS_USRE_TOKEN = "satoken:login:token:";
|
||||
|
||||
//用户信息
|
||||
public static final String REDIS_USRE_INFO = "satoken:login:userInfo:";
|
||||
|
||||
//token过期时间 七天
|
||||
public static final Integer REDIS_TOKEN_TIME = 7*24*60*60;
|
||||
|
||||
|
||||
|
||||
public final static String WHOLE_DOMAIN_REDIS_KEY = "HOE_WHOLE_DOMAIN_REDIS_KEY";
|
||||
public final static String[] CHINESE_NUM = {"一","二","三","四","五","六","七","八","九","十"
|
||||
,"十一","十二","十三","十四","十五","十六","十七","十八","十九","二十"
|
||||
,"二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十"
|
||||
,"三十一","三十一","三十一","三十一","三十一","三十一","三十一","三十一","三十一","四十"};
|
||||
|
||||
|
||||
public final static String[] WEEKS = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String[] distNames = dist_name.split(",");
|
||||
// Random random=new Random();
|
||||
// int number1 = random.nextInt(distNames.length);
|
||||
// String distName1 = distNames[number1];
|
||||
// int number2 = random.nextInt(distNames.length);
|
||||
// String distName2 = distNames[number2];
|
||||
// System.out.println(distName1 + distName2);
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package com.recovery.common.base.constant;
|
||||
|
||||
public interface GlobalConstants {
|
||||
String URL_PERM_ROLES_KEY = "system:perm_roles_rule:url:";
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package com.recovery.common.base.constant;
|
||||
/**
|
||||
* @author:
|
||||
*/
|
||||
public interface SecurityConstants {
|
||||
|
||||
/**
|
||||
* 认证请求头key
|
||||
*/
|
||||
String AUTHORIZATION_KEY = "Authorization";
|
||||
|
||||
/**
|
||||
* JWT令牌前缀
|
||||
*/
|
||||
String JWT_PREFIX = "Bearer ";
|
||||
|
||||
|
||||
/**
|
||||
* Basic认证前缀
|
||||
*/
|
||||
String BASIC_PREFIX = "Basic ";
|
||||
|
||||
/**
|
||||
* JWT载体key
|
||||
*/
|
||||
String JWT_PAYLOAD_KEY = "payload";
|
||||
|
||||
|
||||
/**
|
||||
* JWT存储权限前缀
|
||||
*/
|
||||
String AUTHORITY_PREFIX = "ROLE_";
|
||||
|
||||
/**
|
||||
* JWT存储权限属性
|
||||
*/
|
||||
String JWT_AUTHORITIES_KEY = "authorities";
|
||||
|
||||
|
||||
String CLIENT_ID_KEY = "client_id";
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package com.recovery.common.base.ds;
|
||||
|
||||
/**
|
||||
* @ClassName: DataSourceContextHolder
|
||||
* @Description: 数据源上下文
|
||||
* @Author:
|
||||
* @Date: 2022/2/18 10:04
|
||||
**/
|
||||
public class DataSourceContextHolder {
|
||||
private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
|
||||
/**
|
||||
* @MonthName: setDBType
|
||||
* @Description: 设置当前线程持有的数据源
|
||||
* @Author:
|
||||
* @Date: 2022/2/18 10:07
|
||||
* @Param: [dbType]
|
||||
* @return: void
|
||||
**/
|
||||
public static synchronized void setDBType(String dbType){
|
||||
contextHolder.set(dbType);
|
||||
}
|
||||
/**
|
||||
* @MonthName: getDBType
|
||||
* @Description: 获取当前线程持有的数据源
|
||||
* @Author: tanyp
|
||||
* @Date: 2022/2/18 10:07
|
||||
* @Param: []
|
||||
* @return: java.lang.String
|
||||
**/
|
||||
public static String getDBType(){
|
||||
return contextHolder.get();
|
||||
}
|
||||
/**
|
||||
* @MonthName: clearDBType
|
||||
* @Description: 清除当前线程持有的数据源
|
||||
* @Author: tanyp
|
||||
* @Date: 2022/2/18 10:07
|
||||
* @Param: []
|
||||
* @return: void
|
||||
**/
|
||||
public static void clearDBType(){
|
||||
contextHolder.remove();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue