Commit c5825a20 authored by tangtuo's avatar tangtuo

初始化

parents
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AnalysisProjectProfileManager">
<option name="PROJECT_PROFILE" />
<option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
<list size="0" />
</component>
<component name="SuppressionsComponent">
<option name="suppComments" value="[]" />
</component>
</project>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../:\workspace\fzm-ly\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<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="joying-common" />
<module name="joying-admin" />
<module name="joying-portal" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="joying-admin" options="-parameters" />
<module name="joying-common" options="-parameters" />
<module name="joying-portal" options="-parameters" />
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/joying-admin/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/joying-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/joying-portal/src/main/java" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="date" />
</inspection_tool>
<inspection_tool class="SpringJavaInjectionPointsAutowiringInspection" enabled="true" level="INFORMATION" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="maven-nexus-group" />
<option name="name" value="maven-nexus-group" />
<option name="url" value="http://146.56.197.85:12100/repository/maven-central/" />
</remote-repository>
<remote-repository>
<option name="id" value="fzm" />
<option name="name" value="fzm repositories" />
<option name="url" value="http://maven.citydo.com.cn/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="nexus" />
<option name="name" value="Nexus Repository" />
<option name="url" value="http://146.56.197.85:12100/repository/maven-central/" />
</remote-repository>
<remote-repository>
<option name="id" value="fzm" />
<option name="name" value="fzm repositories" />
<option name="url" value="http://146.56.197.85:12100/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="aliyun" />
<option name="name" value="aliyun repositories" />
<option name="url" value="http://146.56.197.85:12100/repository/maven-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="fzm" />
<option name="name" value="fzm repositories" />
<option name="url" value="http://146.56.197.85:12100/repository/maven-central/" />
</remote-repository>
<remote-repository>
<option name="id" value="nexus" />
<option name="name" value="local private nexus" />
<option name="url" value="http://maven.citydo.com.cn/repository/maven-public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FindBugsConfigurable">
<option name="make" value="true" />
<option name="effort" value="default" />
<option name="priority" value="Medium" />
<option name="excludeFilter" value="" />
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/ly-portal/pom.xml" />
<option value="$PROJECT_DIR$/ly-admin/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="SuppressionsComponent">
<option name="suppComments" value="[]" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
<?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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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.png" 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>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
\ No newline at end of file
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
This diff is collapsed.
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>fzm-joying</artifactId>
<groupId>com.fzm</groupId>
<version>1.0.0</version>
</parent>
<artifactId>joying-admin</artifactId>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fzm</groupId>
<artifactId>joying-common</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.fzm.admin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class JoyingAdminApplication {
public static void main(String[] args) {
SpringApplication.run(JoyingAdminApplication.class, args);
}
}
server:
port: 8001
spring:
application:
name: joying-portal
main:
allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
datasource:
url: jdbc:mysql://172.16.101.135:3306/fzm_joying?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
username: root
password: 123456
platform: mysql
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
druid:
initial-size: 5
min-idle: 5
max-active: 20
max-wait: 60000
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
pool-prepared-statements: false
max-pool-prepared-statement-per-connection-size: 20
filters: stat ,wall
connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
useGlobalDataSourceStat: true
redis:
host: 172.16.101.135
port: 6379
password: 123456
lettuce:
pool:
# 连接池最大连接数(使用负值表示没有限制) 默认 8
max-active: 100
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1
max-wait: -1
# 连接池中的最大空闲连接 默认 8
max-idle: 8
# 连接池中的最小空闲连接 默认 0
min-idle: 0
cache:
# 整合SpringCache,redis作为缓存类型
type: redis
# sa-token配置
sa-token:
# token名称 (同时也是cookie名称)
token-name: Authorization
# token有效期,单位s 默认30天, -1代表永不过期
timeout: 2592000
# token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
activity-timeout: 3600
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
is-share: false
# token风格
#token-style: uuid
# 是否输出操作日志
is-log: false
tokenPrefix: Bearer
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
is-concurrent: false
swagger:
title: 乐映影视
description: 乐映影视门户系统RESTFUL API
version: 1.0.0
base-package: com.fzm.portal.controller
base-path: /**
enabled: true
globalOperationParameters:
- description: Authorization
modelRef: string
name: Authorization
parameterType: header
required: false
contact:
name: tangtuo
email: ttuo@33.com
sms:
app-key: Yiru
app-secret: mx5oaR^RY8!(ziHn
message-login-codetype: quick
email-login-codetype: quick
voice-login-codetype: quick
send-sms-url: http://118.31.52.32/send/sms2
validate-code-url: http://118.31.52.32/validate/code
spring:
profiles:
active: dev
application:
name: ly-portal
jackson:
date-format: yyyy-MM-dd HH:mm:ss
mybatis-plus:
type-aliases-package: com.fzm.common.entity
mapper-locations: classpath:mapper/*.xml
configuration:
map-underscore-to-camel-case: true
logging:
level:
com.fzm.common.mapper: debug
package com.fzm.admin;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class LyAdminApplicationTests {
@Test
void contextLoads() {
}
}
<?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">
<parent>
<artifactId>fzm-joying</artifactId>
<groupId>com.fzm</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>joying-common</artifactId>
<dependencies>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<!-- Sa-Token 权限认证, 在线文档:http://sa-token.dev33.cn/ -->
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-spring-boot-starter</artifactId>
</dependency>
<!-- Sa-Token整合redis (使用jackson序列化方式) -->
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-dao-redis-jackson</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
</dependency>
<dependency>
<groupId>cn.fzm.chain</groupId>
<artifactId>simple-sdk</artifactId>
<version>2.2.1</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
package com.fzm.common.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class CorsConfig implements WebMvcConfigurer {
/**
* 跨域支持
*
* @param registry
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowCredentials(true)
.allowedMethods("GET", "POST", "DELETE", "PUT")
.allowedHeaders("*").maxAge(3600 * 24);
}
}
\ No newline at end of file
package com.fzm.common.config;
import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
// 注册Sa-Token的注解拦截器,打开注解式鉴权功能
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 注册注解拦截器,并排除不需要注解鉴权的接口地址 (与登录拦截器无关)
registry.addInterceptor(new SaAnnotationInterceptor()).addPathPatterns("/**");
}
}
package com.fzm.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
/**
* @author tangtuo
* @date 2021/6/23 22:14
*/
@Configuration
public class SecurityConfig {
@Bean
public PasswordEncoder passwordEncoder(){
return new BCryptPasswordEncoder();
}
}
package com.fzm.common.constant;
/**
* @author tangtuo
* @date 2021/6/23 16:21
*/
public class RedisConstant {
/**
* 后台管理用户的token的key值前缀
*/
public static final String ADMIN_USER_TOKEN_PREFIX = "admin:user:token:";
/**
* 门户用户的token的key值前缀
*/
public static final String PORTAL_USER_TOKEN_PREFIX = "portal:user:token:";
}
package com.fzm.common.constant;
/**
* @author tangtuo
* @date 2021/6/30 16:31
*
* <p>
* 系统全局常量
* </p>
*/
public class SystemConstant {
/**
* 系统数据库的所有Boolean的数据,都满足于 0:false 1:true
*/
public static final Integer BOOLEAN_DATA_TRUE = 1;
public static final Integer BOOLEAN_DATA_FALSE = 0;
}
package com.fzm.common.constant;
/**
* @author tangtuo
* @date 2021/6/23 14:46
*/
public class TokenConstant {
public static final String TOKEN_HEADER = "Authorization";
public static final String TOKEN_PREFIX = "Bearer ";
public static final String TOKEN_APP_ID_PORTAL = "portal";
public static final String TOKEN_APP_ID_ADMIN = "admin";
}
package com.fzm.common.entity;
/**
* @author tangtuo
* @date 2021/6/23 10:09
*/
public abstract class AbstractUser {
public abstract String appId();
public abstract Integer userId();
}
package com.fzm.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* @author tangtuo
* @date 2021/6/28 11:12
*/
@Data
@Accessors(chain = true)
@ApiModel("个人认证信息")
@TableName("tb_auth_person")
public class AuthPerson extends BaseEntity {
@ApiModelProperty("用户id")
private Integer userId;
@ApiModelProperty("姓名")
@NotBlank(message = "姓名不能为空")
private String name;
@ApiModelProperty("身份证号码")
@NotBlank(message = "身份证号码不能为空")
@Pattern(regexp = "^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$",
message = "身份证号码格式有误")
private String idCard;
@ApiModelProperty("身份证正面照片(人脸面)")
@NotBlank(message = "身份证正面照片不能为空")
private String cardPictureFront;
@ApiModelProperty("身份证反面照片(国徽面)")
@NotBlank(message = "身份证反面照片不能为空")
private String cardPictureBack;
}
package com.fzm.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* @author tangtuo
* @date 2021/6/28 11:15
*/
@Data
@Accessors(chain = true)
public abstract class BaseEntity {
@TableId(type = IdType.AUTO)
private Integer id;
@ApiModelProperty("创建时间")
private Date createDate;
@ApiModelProperty("修改时间")
private Date updateDate;
}
package com.fzm.common.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @author tangtuo
* @date 2021/6/30 15:42
*/
@Data
@ApiModel("nft信息")
@Accessors(chain = true)
@TableName("tb_nft")
public class Nft extends BaseEntity {
@ApiModelProperty("类目id")
private Integer categoryId;
@ApiModelProperty("用户id")
private Integer userId;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("作者")
private String author;
@ApiModelProperty("主题,多个用逗号,隔开")
private String theme;
@ApiModelProperty("简介")
private String synopsis;
@ApiModelProperty("文件名")
private String fileName;
@ApiModelProperty("文件地址--用户选择不存档的情况下为空")
private String fileUrl;
@ApiModelProperty("文件hash")
private String fileHash;
@ApiModelProperty("平台存档 0-不存档 1-加密存档")
private Integer isArchives;
@ApiModelProperty("授权阅读 0-不需要授权 1-需要授权")
private Integer isGrant;
@ApiModelProperty("nft编号")
private String nftId;
@ApiModelProperty("nft哈希")
private String nftHash;
}
package com.fzm.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fzm.common.constant.TokenConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* @author tangtuo
* @date 2021/6/23 11:54
*/
@Data
@Accessors(chain = true)
@ApiModel("用户信息")
@TableName("tb_user")
public class User extends AbstractUser {
@TableId(type = IdType.AUTO)
private Integer id;
@ApiModelProperty("手机号码(用户名)")
private String telephone;
@ApiModelProperty("邮箱")
private String email;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("钱包地址")
private String wallet;
@ApiModelProperty("昵称")
private String nickname;
@ApiModelProperty("个性签名")
private String signature;
@ApiModelProperty("头像")
private String avatar;
@ApiModelProperty("认证类型 0-个人认证 1-企业认证")
private Integer authType;
@ApiModelProperty("实名认证状态 0-未认证 1-认证成功 2-认证失败 3-认证中")
private Integer authStatus;
@ApiModelProperty("创建时间")
private Date createDate;
@ApiModelProperty("修改时间")
private Date updateDate;
@Override
public String appId() {
return TokenConstant.TOKEN_APP_ID_PORTAL;
}
@Override
public Integer userId() {
return id;
}
}
package com.fzm.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author tangtuo
* @date 2021/6/28 11:49
*/
@AllArgsConstructor
@Getter
public enum AuthStatusEnum {
NOT(0, "未认证"),
SUCCESS(1, "认证成功"),
FAIL(2, "认证失败"),
ONGOING(3, "认证中"),
;
private Integer status;
private String desc;
}
package com.fzm.common.enums;
import lombok.Getter;
/**
* @author tangtuo
* @date 2021/6/28 11:47
*/
@Getter
public enum AuthTypeEnum {
PERSON(0,"个人认证"),
ENTERPRISE(0,"企业认证")
;
private Integer type;
private String desc;
AuthTypeEnum(Integer type, String desc) {
this.type = type;
this.desc = desc;
}
}
package com.fzm.common.enums;
public interface IErrorCode {
Integer getCode();
String getMessage();
}
package com.fzm.common.enums;
public enum ResultCode implements IErrorCode {
SUCCESS(200, "success"),
FAILED(500, "failed"),
VALIDATE_FAILED(405, "参数检验失败"),
UNAUTHORIZED(401, "认证失败"),
FORBIDDEN(403, "没有相关权限"),
DATA_ERROR(601, "没找到相关数据"),
REGISTER_ERROR(410,"您已注册过"),
LOGIN_ERROR(411,"登录失败"),
FILE_UPLOAD_ERROR(412,"文件上传失败"),
TOKEN_VALID_ERROR(413,"token校验失败"),
CODE_ERROR(414,"验证码发送失败"),
;
private Integer code;
private String message;
ResultCode(Integer code, String message) {
this.code = code;
this.message = message;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getMessage() {
return message;
}
}
package com.fzm.common.exception;
import com.fzm.common.enums.IErrorCode;
/**
* @author :tangtuo
* @date :2021/04/30 16:18
*/
public class GlobalException extends RuntimeException {
private IErrorCode errorCode;
private GlobalException(IErrorCode errorCode) {
super(errorCode.getMessage());
this.errorCode = errorCode;
}
private GlobalException(IErrorCode errorCode, String errorMsg) {
super(errorMsg);
this.errorCode = errorCode;
}
public static GlobalException newException(IErrorCode errorCode) {
return new GlobalException(errorCode);
}
public static GlobalException newException(IErrorCode errorCode, String errorMsg) {
return new GlobalException(errorCode, errorMsg);
}
public IErrorCode getErrorCode() {
return errorCode;
}
public void setErrorCode(IErrorCode errorCode) {
this.errorCode = errorCode;
}
@Override
public String getMessage() {
return super.getMessage();
}
}
package com.fzm.common.exception.handler;
import cn.hutool.http.HttpStatus;
import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.model.ResponseModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author :tangtuo
* @date :2021/04/30 16:35
*/
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
@Resource
private HttpServletResponse response;
@ExceptionHandler(value = GlobalException.class)
public ResponseModel<String> handlerGlobalException(GlobalException globalException) {
log.error(globalException.getMessage(), globalException);
response.setStatus(HttpStatus.HTTP_INTERNAL_ERROR);
return ResponseModel.fail(globalException.getErrorCode(), globalException.getMessage());
}
@ExceptionHandler(value = Exception.class)
public ResponseModel<String> handlerException(Exception exception) {
log.error(exception.getMessage(), exception);
response.setStatus(HttpStatus.HTTP_INTERNAL_ERROR);
return ResponseModel.fail(exception);
}
@ExceptionHandler(value = {MethodArgumentNotValidException.class})
public ResponseModel<String> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
log.error(e.getMessage(), e);
response.setStatus(HttpStatus.HTTP_INTERNAL_ERROR);
List<ObjectError> allErrors = e.getBindingResult().getAllErrors();
String errorMsg = allErrors.
stream().
map(DefaultMessageSourceResolvable::getDefaultMessage).
collect(Collectors.joining("、"));
return ResponseModel.fail(ResultCode.VALIDATE_FAILED, errorMsg);
}
}
package com.fzm.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzm.common.entity.AuthPerson;
import org.apache.ibatis.annotations.Mapper;
/**
* @author tangtuo
* @date 2021/6/28 11:25
*/
@Mapper
public interface AuthPersonMapper extends BaseMapper<AuthPerson> {
}
package com.fzm.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzm.common.entity.Nft;
import org.apache.ibatis.annotations.Mapper;
/**
* @author tangtuo
* @date 2021/6/30 15:54
*/
@Mapper
public interface NftMapper extends BaseMapper<Nft> {
}
package com.fzm.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzm.common.entity.User;
import org.apache.ibatis.annotations.Mapper;
/**
* @author tangtuo
* @date 2021/6/23 15:14
*/
@Mapper
public interface UserMapper extends BaseMapper<User> {
}
package com.fzm.common.model;
import com.fzm.common.enums.IErrorCode;
import com.fzm.common.enums.ResultCode;
import lombok.Data;
/**
* @author :tangtuo
* @date :2021/04/30 16:03
*/
@Data
public class ResponseModel<T> {
private int code;
private String message;
private T data;
public ResponseModel() {
}
private ResponseModel(IErrorCode errorCode, T data) {
this.code = errorCode.getCode();
this.message = errorCode.getMessage();
this.data = data;
}
public static <T> ResponseModel<T> success(T data) {
return new ResponseModel<>(ResultCode.SUCCESS, data);
}
public static <T> ResponseModel<T> success() {
return new ResponseModel<>(ResultCode.SUCCESS, null);
}
public static <T> ResponseModel<T> fail() {
return new ResponseModel<>(ResultCode.FAILED, null);
}
public static <T> ResponseModel<T> fail(T data) {
return new ResponseModel<>(ResultCode.FAILED, data);
}
public static <T> ResponseModel<T> fail(IErrorCode errorCode) {
return new ResponseModel<>(errorCode, null);
}
public static ResponseModel<String> fail(IErrorCode errorCode, String errorMsg) {
return new ResponseModel<>(errorCode, errorMsg);
}
public static ResponseModel<String> fail(Throwable throwable) {
return fail(throwable.getMessage());
}
}
package com.fzm.common.params;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author tangtuo
* @date 2021/6/23 15:33
*/
@Data
public class LoginParam {
@ApiModelProperty("手机号")
private String telephone;
@ApiModelProperty("邮箱")
private String email;
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("验证码")
private String verificationCode;
@ApiModelProperty("验证码类型, sms-短信 email-邮件 voice-语音")
private String codetype;
}
package com.fzm.common.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @author tangtuo
* @date 2021/6/29 15:54
*/
@Data
@Component
@ConfigurationProperties(prefix = "aliyun.oss")
public class OssProperties {
private String appKey;
private String appSecret;
private String endPoint;
/**
* 非加密文件存储的bucket
*/
private String simpleBucket;
/**
* 加密文件存储的bucket
*/
private String encryptBucket;
}
package com.fzm.common.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @author tangtuo
* @date 2021/6/25 16:03
*/
@Data
@Component
@ConfigurationProperties(prefix = "sms")
public class SmsProperties {
private String appKey;
private String appSecret;
private String sendSmsUrl;
private String validateCodeUrl;
private String messageLoginCodetype;
private String emailLoginCodetype;
private String voiceLoginCodetype;
}
package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.AuthPerson;
/**
* @author tangtuo
* @date 2021/6/28 11:28
*/
public interface AuthPersonService extends IService<AuthPerson> {
}
package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.Nft;
/**
* @author tangtuo
* @date 2021/6/30 15:55
*/
public interface NftService extends IService<Nft> {
String publish(Nft nft);
}
package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.AuthPerson;
import com.fzm.common.entity.User;
import com.fzm.common.params.LoginParam;
/**
* @author tangtuo
* @date 2021/6/23 15:14
*/
public interface UserService extends IService<User> {
/**
* 根据手机号查询用户信息
*
* @param username
* @return
*/
User loadUserByUsername(String username);
/**
* 登录
*
* @param param
* @return
*/
User login(LoginParam param);
/**
* 根据token获取用户信息
*
* @return
*/
User getUserByToken();
/**
* 个人实名认证
*
* @param authPerson
*/
Boolean personAuth(AuthPerson authPerson);
/**
* 修改头像
*
* @param avatar
* @return
*/
User uploadAvatar(String avatar);
}
package com.fzm.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.AuthPerson;
import com.fzm.common.mapper.AuthPersonMapper;
import com.fzm.common.service.AuthPersonService;
import org.springframework.stereotype.Service;
/**
* @author tangtuo
* @date 2021/6/28 11:29
*/
@Service
public class AuthPersonServiceImpl extends ServiceImpl<AuthPersonMapper, AuthPerson> implements AuthPersonService {
}
package com.fzm.common.service.impl;
import cn.fzm.chain.simplesdk.client.ParaChainClient;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.Nft;
import com.fzm.common.mapper.NftMapper;
import com.fzm.common.service.NftService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author tangtuo
* @date 2021/6/30 15:55
*/
@Service
public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftService {
@Resource
private ParaChainClient paraChainClient;
@Override
public String publish(Nft nft) {
save(nft);
//return paraChainClient.evmPublishNFT1155();
return null;
}
}
package com.fzm.common.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.fzm.chain.simplesdk.client.ParaChainClient;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.AuthPerson;
import com.fzm.common.entity.User;
import com.fzm.common.enums.AuthStatusEnum;
import com.fzm.common.enums.AuthTypeEnum;
import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.mapper.UserMapper;
import com.fzm.common.params.LoginParam;
import com.fzm.common.properties.SmsProperties;
import com.fzm.common.service.AuthPersonService;
import com.fzm.common.service.UserService;
import com.fzm.common.utils.SmsUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* @author tangtuo
* @date 2021/6/23 15:15
*/
@Service
@Transactional(rollbackFor = RuntimeException.class)
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
@Resource
private PasswordEncoder passwordEncoder;
@Resource
private SmsProperties smsProperties;
@Resource
private SmsUtil smsUtil;
@Resource
private AuthPersonService authPersonService;
@Resource
private ParaChainClient paraClient;
@Override
public User loadUserByUsername(String username) {
QueryWrapper<User> wrapper = new QueryWrapper<>();
wrapper.eq("telephone", username).
or().
eq("email", username);
return getOne(wrapper);
}
@Override
public User login(LoginParam param) {
String username = StringUtils.isNotBlank(param.getTelephone()) ?
param.getTelephone() :
param.getEmail();
User user = loadUserByUsername(username);
if (user == null) {
// 当前手机号或者邮箱没有注册过,走注册逻辑
User registerUser = new User();
BeanUtil.copyProperties(param, registerUser, true);
if (StringUtils.isNotBlank(param.getPassword())) {
registerUser.setPassword(passwordEncoder.encode(param.getPassword()));
} else {
// 验证码注册流程
if (!smsUtil.validateCode(getLoginCodeType(param.getCodetype()), username, param.getVerificationCode(), param.getCodetype())) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED, "验证码校验失败");
}
}
save(registerUser);
// 生成钱包
String wallet = paraClient.walletCreateAccount(registerUser.getId().toString());
if (StringUtils.isNotBlank(wallet)) {
User u = new User().setId(registerUser.getId()).setWallet(wallet);
updateById(u);
}
return getById(registerUser.getId());
} else {
// 登录逻辑
if (StringUtils.isNotBlank(param.getPassword())) {
// 密码登录流程
if (!passwordEncoder.matches(param.getPassword(), user.getPassword())) {
throw GlobalException.newException(ResultCode.LOGIN_ERROR, "密码有误");
}
} else {
// 验证码登录流程
if (!smsUtil.validateCode(getLoginCodeType(param.getCodetype()), username, param.getVerificationCode(), param.getCodetype())) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED, "验证码校验失败");
}
}
return user;
}
}
@Override
public User getUserByToken() {
String token = StpUtil.getTokenValue();
if (StringUtils.isBlank(token)) {
throw GlobalException.newException(ResultCode.UNAUTHORIZED, "您还没有登录,请先登录");
}
Integer userId = Integer.parseInt(StpUtil.getLoginId().toString());
return getById(userId);
}
public String getLoginCodeType(String type) {
switch (type) {
case "sms":
return smsProperties.getMessageLoginCodetype();
case "email":
return smsProperties.getEmailLoginCodetype();
case "voice":
return smsProperties.getVoiceLoginCodetype();
default:
throw GlobalException.newException(ResultCode.CODE_ERROR);
}
}
@Override
public Boolean personAuth(AuthPerson authPerson) {
Integer loginId = Integer.parseInt(StpUtil.getLoginId().toString());
User user = new User().
setAuthStatus(AuthStatusEnum.ONGOING.getStatus()).
setAuthType(AuthTypeEnum.PERSON.getType()).
setId(loginId);
updateById(user);
authPerson.setUserId(loginId);
return authPersonService.save(authPerson);
}
@Override
public User uploadAvatar(String avatar) {
Integer loginId = Integer.parseInt(StpUtil.getLoginId().toString());
User user = new User().
setAvatar(avatar).
setId(loginId);
updateById(user);
return getById(loginId);
}
}
package com.fzm.common.utils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.lang.reflect.Type;
public class JsonUtil {
private static Gson gson;
private static JsonParser jsonParser;
private JsonUtil() {
}
static {
GsonBuilder builder = new GsonBuilder();
// 打印好看的json格式
builder.setPrettyPrinting();
// 设置日期格式
builder.setDateFormat("yyyy-MM-dd HH:mm:ss");
// 基于当前配置创建gson实例
gson = builder.create();
// 实例化jsonParser
jsonParser = new JsonParser();
}
/**
* json字符串转对象
*/
public static <T> T toObject(String json, Class<T> classOfT) {
return gson.fromJson(json, classOfT);
}
/**
* json复杂对象
*/
public static Object toObject(String json, Type type) {
return gson.fromJson(json, type);
}
/**
* 对象转json字符串
*/
public static String toJson(Object object) {
return gson.toJson(object);
}
/**
* String转为jsonObject
*/
public static JsonObject toJsonObject(String string) {
return jsonParser.parse(string).getAsJsonObject();
}
}
package com.fzm.common.utils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.fzm.common.entity.AbstractUser;
import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @author tangtuo
* @date 2021/6/23 9:40
*/
@Slf4j
public class JwtUtil {
private static final String CLAIM_KEY_USERNAME = "sub";
private static final String CLAIM_KEY_CREATED = "created";
private static final String CLAIM_KEY_USERID = "userId";
private static final String CLAIM_KEY_APP_ID = "appId";
private static final String SECRET = "fzm-ly";
private static final Long EXPIRATION = 1000 * 60 * 60 * 24L;
private static final String TOKEN_PREFIX = "Bearer ";
/**
* 根据负责生成JWT的token
*/
private static String generateToken(Map<String, Object> claims) {
return Jwts.builder()
.setClaims(claims)
.setExpiration(generateExpirationDate())
.signWith(SignatureAlgorithm.HS512, SECRET)
.compact();
}
/**
* 从token中获取JWT中的负载
*/
private static Claims getClaimsFromToken(String token) {
Claims claims = null;
token = token.replace(TOKEN_PREFIX, "");
try {
claims = Jwts.parser()
.setSigningKey(SECRET)
.parseClaimsJws(token)
.getBody();
} catch (Exception e) {
log.info("JWT格式验证失败:{}", token);
}
return claims;
}
/**
* 生成token的过期时间
*/
private static Date generateExpirationDate() {
return new Date(System.currentTimeMillis() + EXPIRATION * 1000);
}
/**
* 从token中获取登录用户名
*/
public static String getUserNameFromToken(String token) {
String username;
try {
Claims claims = getClaimsFromToken(token);
username = claims.getSubject();
} catch (Exception e) {
username = null;
}
return username;
}
/**
* 从token中获取登录用户id
*/
public static Integer getUserIdFromToken(String token) {
try {
Claims claims = getClaimsFromToken(token);
return claims.get(CLAIM_KEY_USERID, Integer.class);
} catch (Exception e) {
throw GlobalException.newException(ResultCode.TOKEN_VALID_ERROR, e.getMessage());
}
}
/**
* 从token中获取登录appId
*/
public static String getAppIdFromToken(String token) {
try {
Claims claims = getClaimsFromToken(token);
return claims.get(CLAIM_KEY_APP_ID, String.class);
} catch (Exception e) {
throw GlobalException.newException(ResultCode.TOKEN_VALID_ERROR, e.getMessage());
}
}
/**
* 验证token是否还有效
*
* @param token 客户端传入的token
* @param userDetails 从数据库中查询出来的用户信息
*/
/* public static boolean validateToken(String token, UserDetails userDetails) {
String username = getUserNameFromToken(token);
return username.equals(userDetails.getUsername()) && !isTokenExpired(token);
}*/
/**
* 判断token是否已经失效
*/
private static boolean isTokenExpired(String token) {
Date expiredDate = getExpiredDateFromToken(token);
return expiredDate.before(new Date());
}
/**
* 从token中获取过期时间
*/
private static Date getExpiredDateFromToken(String token) {
Claims claims = getClaimsFromToken(token);
return claims.getExpiration();
}
/**
* 根据用户信息生成token
*/
public static String generateToken(AbstractUser userDetails) {
Map<String, Object> claims = new HashMap<>();
//claims.put(CLAIM_KEY_USERNAME, userDetails.getUsername());
claims.put(CLAIM_KEY_CREATED, new Date());
claims.put(CLAIM_KEY_APP_ID, userDetails.appId());
claims.put(CLAIM_KEY_USERID, userDetails.userId());
return generateToken(claims);
}
/**
* 当原来的token没过期时是可以刷新的
*
* @param oldToken 带tokenHead的token
*/
public static String refreshHeadToken(String oldToken) {
if (StrUtil.isEmpty(oldToken)) {
return null;
}
String token = oldToken.substring(TOKEN_PREFIX.length());
if (StrUtil.isEmpty(token)) {
return null;
}
//token校验不通过
Claims claims = getClaimsFromToken(token);
if (claims == null) {
return null;
}
//如果token已经过期,不支持刷新
if (isTokenExpired(token)) {
return null;
}
//如果token在30分钟之内刚刷新过,返回原token
if (tokenRefreshJustBefore(token, 30 * 60)) {
return token;
} else {
claims.put(CLAIM_KEY_CREATED, new Date());
return generateToken(claims);
}
}
/**
* 判断token在指定时间内是否刚刚刷新过
*
* @param token 原token
* @param time 指定时间(秒)
*/
private static boolean tokenRefreshJustBefore(String token, int time) {
Claims claims = getClaimsFromToken(token);
Date created = claims.get(CLAIM_KEY_CREATED, Date.class);
Date refreshDate = new Date();
//刷新时间在创建时间的指定时间内
if (refreshDate.after(created) && refreshDate.before(DateUtil.offsetSecond(created, time))) {
return true;
}
return false;
}
}
package com.fzm.common.utils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.*;
import com.fzm.common.properties.OssProperties;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.Date;
/**
* @author tangtuo
* @date 2021/6/29 16:07
*/
@Component
public class OssUtil {
@Resource
private OssProperties ossProperties;
@Resource
private HttpServletResponse response;
/**
* @param file
* @return
*/
public String putSimpleObject(MultipartFile file) throws IOException {
String endpoint = ossProperties.getEndPoint();
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
String accessKeyId = ossProperties.getAppKey();
String accessKeySecret = ossProperties.getAppSecret();
String bucketName = ossProperties.getSimpleBucket();
// <yourObjectName>上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如20210629/a8703bcf7d354ea2bbb5ccdf76b7405f/123.jpg。
String objectName = String.format("%s/%s/%s", DateUtil.format(new Date(), "yyyyMMdd"), IdUtil.simpleUUID(), file.getOriginalFilename());
// 创建OSSClient实例。
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
// 上传文件到指定的存储空间(bucketName)并将其保存为指定的文件名称(objectName)。
String content = "Hello OSS";
ossClient.putObject(bucketName, objectName, file.getInputStream());
// 关闭OSSClient。
ossClient.shutdown();
return String.format("https://%s.%s/%s", bucketName, endpoint, objectName);
}
public void createEncryptBucket() {
String endpoint = ossProperties.getEndPoint();
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
String accessKeyId = ossProperties.getAppKey();
String accessKeySecret = ossProperties.getAppSecret();
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
// 创建存储空间。
String bucket = ossProperties.getEncryptBucket();
if (!ossClient.doesBucketExist(bucket)) {
// 设置Bucket加密。
ServerSideEncryptionByDefault applyServerSideEncryptionByDefault = new ServerSideEncryptionByDefault(SSEAlgorithm.AES256);
ServerSideEncryptionConfiguration sseConfig = new ServerSideEncryptionConfiguration();
sseConfig.setApplyServerSideEncryptionByDefault(applyServerSideEncryptionByDefault);
SetBucketEncryptionRequest request = new SetBucketEncryptionRequest("<yourBucketName>", sseConfig);
ossClient.setBucketEncryption(request);
ossClient.shutdown();
ossClient.createBucket(bucket);
}
ossClient.createBucket(ossProperties.getEncryptBucket());
}
public String putEncryptObject(MultipartFile file) {
String endpoint = ossProperties.getEndPoint();
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
String accessKeyId = ossProperties.getAppKey();
String accessKeySecret = ossProperties.getAppSecret();
String bucketName = ossProperties.getSimpleBucket();
// <yourObjectName>上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如20210629/a8703bcf7d354ea2bbb5ccdf76b7405f/123.jpg。
String objectName = String.format("%s/%s/%s", DateUtil.format(new Date(), "yyyyMMdd"), IdUtil.simpleUUID(), file.getOriginalFilename());
return String.format("https://%s.%s/%s", bucketName, endpoint, objectName);
}
public void downloadFile(String file) {
String endpoint = ossProperties.getEndPoint();
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
String accessKeyId = ossProperties.getAppKey();
String accessKeySecret = ossProperties.getAppSecret();
String bucketName = ossProperties.getEncryptBucket();
// 创建OSSClient实例。
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
file = file.replace(String.format("https://%s.%s/", bucketName, endpoint), "");
OSSObject ossObject = ossClient.getObject(bucketName, file);
try {
// 读取文件内容。
InputStream inputStream = ossObject.getObjectContent();
BufferedInputStream in = new BufferedInputStream(inputStream);// 把输入流放入缓存流
ServletOutputStream outputStream = response.getOutputStream();
BufferedOutputStream out = new BufferedOutputStream(outputStream);// 把输出流放入缓存流
byte[] buffer = new byte[1024];
int len = 0;
while ((len = in.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
if (out != null) {
out.flush();
out.close();
}
if (in != null) {
in.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
String endpoint = "oss-cn-hangzhou.aliyuncs.com";
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
String accessKeyId = "LTAI5tHGn7cVJdEtihTFLSeB";
String accessKeySecret = "XYmfBSbLaZoblGXZwIXkbhfBD7a1eg";
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
// 创建存储空间。
String bucket = "test-nft-2";
if (!ossClient.doesBucketExist(bucket)) {
// 设置Bucket加密。
ServerSideEncryptionByDefault applyServerSideEncryptionByDefault = new ServerSideEncryptionByDefault(SSEAlgorithm.AES256);
ServerSideEncryptionConfiguration sseConfig = new ServerSideEncryptionConfiguration();
sseConfig.setApplyServerSideEncryptionByDefault(applyServerSideEncryptionByDefault);
SetBucketEncryptionRequest request = new SetBucketEncryptionRequest(bucket, sseConfig);
ossClient.setBucketEncryption(request);
ossClient.shutdown();
}
}
}
package com.fzm.common.utils;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.Sign;
import cn.hutool.crypto.asymmetric.SignAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
import sun.misc.BASE64Encoder;
import sun.security.krb5.internal.crypto.HmacSha1Aes256CksumType;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
/**
* @author tangtuo
* @date 2021/6/23 18:16
*/
public class PasswordUtil {
private static final byte[] KEY = {-117, 98, -11, 43, 72, 24, -10, 125, -87, -10, -77, -35, -127, 40, 34, 119};
static SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, KEY);
public static String encrypt(String content) {
return aes.encryptBase64(content);
}
public static boolean match(String encrypt, String content) {
return aes.decryptStr(encrypt).equals(content);
}
public static void main(String[] args) {
String password="12rehkkkfbhksskkhbssrktbsr3456gbibvbybkfnriowernolwgrojgbrqg";
String encrypt = encrypt(password);
System.out.println(encrypt);
System.out.println(match(encrypt, password));
}
}
package com.fzm.common.utils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpStatus;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.properties.SmsProperties;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.*;
/**
* @author tangtuo
* @date 2021/6/28 16:02
*/
@Component
public class SmsUtil {
@Resource
private SmsProperties smsProperties;
public static String getStringToSignOfStr(Map<String, Object> map) {
TreeMap<String, String> treeMap = new TreeMap<>();
Iterator<String> iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
treeMap.put(key, map.get(key).toString());
}
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : treeMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
sb.append(key).append("=").append(value).append("&");
}
if (sb.length() > 1) {
return sb.deleteCharAt(sb.length() - 1).toString();
} else {
return "";
}
}
public static String getTimestamp() {
return DateUtil.format(new Date(), "yyyyMMddHHmmss");
}
public static String getSign(String appkey, String appSecret, String paramStr, String date) {
return SecureUtil.md5(appkey + paramStr + appSecret + date).toUpperCase();
}
/**
* @param codetype 模板类型
* @param mobile 手机号
* @return
*/
public Boolean sendSms(String codetype, String mobile) {
String timestamp = getTimestamp();
HashMap<String, Object> params = new HashMap<>();
params.put("mobile", mobile);
params.put("codetype", codetype);
params.put("param", "FzmRandom4");
String paramStr = getStringToSignOfStr(params);
System.out.println(paramStr);
String sign = getSign(smsProperties.getAppKey(), smsProperties.getAppSecret(), paramStr, timestamp);
HttpResponse response = HttpRequest.post(smsProperties.getSendSmsUrl()).
header("FZM-Ca-Timestamp", timestamp).
header("FZM-Ca-AppKey", smsProperties.getAppKey()).
header("FZM-Ca-Signature", sign).form(params).execute();
if (response == null || StringUtils.isBlank(response.body())) {
return false;
}
JSONObject jsonObject = JSONUtil.parseObj(response.body());
if (jsonObject.get("code", Integer.class) != HttpStatus.HTTP_OK) {
throw GlobalException.newException(ResultCode.CODE_ERROR, jsonObject.getStr("message"));
}
return true;
}
/**
* @param codetype 模板类型,和发短信的一样
* @param mobile 手机号
* @param code 验证码
* @param type sms/email/voice
* @return
*/
public Boolean validateCode(String codetype, String mobile, String code, String type) {
String timestamp = getTimestamp();
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("t", type);
paramMap.put("codetype", codetype);
paramMap.put("code", code);
paramMap.put("guide", "1");
paramMap.put("mobile", mobile);
String str = getStringToSignOfStr(paramMap);
String sign = getSign(smsProperties.getAppKey(), smsProperties.getAppSecret(), str, timestamp);
HttpResponse response = HttpRequest.post(smsProperties.getValidateCodeUrl()).
header("FZM-Ca-Timestamp", timestamp).
header("FZM-Ca-AppKey", smsProperties.getAppKey()).
header("FZM-Ca-Signature", sign).form(paramMap).execute();
if (response == null || StringUtils.isBlank(response.body())) {
return false;
}
JSONObject jsonObject = JSONUtil.parseObj(response.body());
if (jsonObject.get("code", Integer.class) != HttpStatus.HTTP_OK) {
throw GlobalException.newException(ResultCode.CODE_ERROR, jsonObject.getStr("message"));
}
return true;
}
/* public static void main(String[] args) {
String timestamp = getTimestamp();
HashMap<String, Object> params = new HashMap<>();
params.put("mobile", "17620078872");
params.put("codetype", "quick");
params.put("param", "FzmRandom4");
String paramStr = getStringToSignOfStr(params);
System.out.println(paramStr);
String sign = getSign(APP_KEY, APP_SECRET, paramStr, timestamp);
HttpRequest request = HttpRequest.post("http://118.31.52.32/send/sms2").
header("FZM-Ca-Timestamp", timestamp).
header("FZM-Ca-AppKey", APP_KEY).
header("FZM-Ca-OS", "h5").
header("FZM-Ca-Signature", sign).form(params);
System.out.println(request.getUrl());
System.out.println(request.execute().body());
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("t", "sms");
paramMap.put("codetype", "quick");
paramMap.put("code", "8102");
paramMap.put("guide", "1");
paramMap.put("mobile", "17620078872");
String str = getStringToSignOfStr(paramMap);
String sign1 = getSign(APP_KEY, APP_SECRET, str, timestamp);
HttpResponse h5 = HttpRequest.post("http://118.31.52.32/validate/code").
header("FZM-Ca-Timestamp", timestamp).
header("FZM-Ca-AppKey", APP_KEY).
header("FZM-Ca-OS", "h5").
header("FZM-Ca-Signature", sign1).form(paramMap).execute();
System.out.println(h5.body());
}*/
}
artifactId=joying-common
groupId=com.fzm
version=1.0.0
com\fzm\common\utils\OssUtil.class
com\fzm\common\enums\AuthTypeEnum.class
com\fzm\common\service\UserService.class
com\fzm\common\constant\RedisConstant.class
com\fzm\common\entity\AuthPerson.class
com\fzm\common\entity\AbstractUser.class
com\fzm\common\params\LoginParam.class
com\fzm\common\properties\SmsProperties.class
com\fzm\common\config\SaTokenConfigure.class
com\fzm\common\enums\AuthStatusEnum.class
com\fzm\common\exception\handler\GlobalExceptionHandler.class
com\fzm\common\mapper\UserMapper.class
com\fzm\common\enums\IErrorCode.class
com\fzm\common\utils\SmsUtil.class
com\fzm\common\constant\TokenConstant.class
com\fzm\common\entity\User.class
com\fzm\common\service\impl\AuthPersonServiceImpl.class
com\fzm\common\entity\BaseEntity.class
com\fzm\common\utils\PasswordUtil.class
com\fzm\common\exception\GlobalException.class
com\fzm\common\service\impl\UserServiceImpl.class
com\fzm\common\service\AuthPersonService.class
com\fzm\common\model\ResponseModel.class
com\fzm\common\utils\JwtUtil.class
com\fzm\common\config\SecurityConfig.class
com\fzm\common\mapper\AuthPersonMapper.class
com\fzm\common\utils\RedisUtil.class
com\fzm\common\config\CorsConfig.class
com\fzm\common\properties\OssProperties.class
com\fzm\common\utils\JsonUtil.class
com\fzm\common\enums\ResultCode.class
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\entity\User.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\properties\SmsProperties.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\constant\RedisConstant.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\enums\IErrorCode.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\constant\TokenConstant.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\service\impl\UserServiceImpl.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\model\ResponseModel.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\mapper\AuthPersonMapper.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\SmsUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\config\SecurityConfig.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\entity\AbstractUser.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\entity\AuthPerson.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\JwtUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\config\SaTokenConfigure.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\service\AuthPersonService.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\service\impl\AuthPersonServiceImpl.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\enums\AuthStatusEnum.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\RedisUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\mapper\UserMapper.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\config\CorsConfig.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\properties\OssProperties.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\OssUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\enums\AuthTypeEnum.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\exception\handler\GlobalExceptionHandler.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\entity\BaseEntity.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\JsonUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\exception\GlobalException.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\service\UserService.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\params\LoginParam.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\utils\PasswordUtil.java
D:\workspace\fzm-joying\joying-common\src\main\java\com\fzm\common\enums\ResultCode.java
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment