第一次上传
This commit is contained in:
parent
394c44adc8
commit
b488fcc971
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
19
.idea/encodings.xml
Normal file
19
.idea/encodings.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-common/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-common/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-coupon-service/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-coupon-service/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-gateway/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-gateway/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-order-service/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-order-service/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-product-service/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-product-service/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-user-service/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/xdclass-user-service/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
13
.idea/misc.xml
Normal file
13
.idea/misc.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
177
pom.xml
Normal file
177
pom.xml
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
<?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>
|
||||||
|
|
||||||
|
<groupId>net.jieyuu</groupId>
|
||||||
|
<artifactId>xdclass-shop</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>xdclass-common</module>
|
||||||
|
<module>xdclass-product-service</module>
|
||||||
|
<module>xdclass-user-service</module>
|
||||||
|
<module>xdclass-order-service</module>
|
||||||
|
<module>xdclass-coupon-service</module>
|
||||||
|
<module>xdclass-gateway</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
|
<spring.boot.version>2.3.3.RELEASE</spring.boot.version>
|
||||||
|
|
||||||
|
<spring.cloud.version>Hoxton.SR8</spring.cloud.version>
|
||||||
|
<alibaba.cloud.version>2.2.1.RELEASE</alibaba.cloud.version>
|
||||||
|
|
||||||
|
<mybatisplus.boot.starter.version>3.4.0</mybatisplus.boot.starter.version>
|
||||||
|
<lombok.version>1.18.16</lombok.version>
|
||||||
|
<commons.lang3.version>3.9</commons.lang3.version>
|
||||||
|
<commons.codec.version>1.15</commons.codec.version>
|
||||||
|
<springfox.boot.starter.version>3.0.0</springfox.boot.starter.version>
|
||||||
|
|
||||||
|
<docker.image.prefix>xdclass-cloud</docker.image.prefix>
|
||||||
|
|
||||||
|
<!--跳过单元测试-->
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<!--锁定版本-->
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<!--https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/2.3.3.RELEASE-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring.boot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies/Hoxton.SR8-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring.cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-alibaba-dependencies/2.2.1.RELEASE-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
|
<version>${alibaba.cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--mybatis plus和springboot整合-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>${mybatisplus.boot.starter.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--https://mvnrepository.com/artifact/org.projectlombok/lombok/1.18.16-->
|
||||||
|
<!--scope=provided,说明它只在编译阶段生效,不需要打入包中, Lombok在编译期将带Lombok注解的Java文件正确编译为完整的Class文件-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
<!-- <scope>provided</scope>-->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>${commons.lang3.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
|
||||||
|
<!--用于加密-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>${commons.codec.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--接口文档依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-boot-starter</artifactId>
|
||||||
|
<version>${springfox.boot.starter.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--kaptcha依赖包-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>kaptcha-spring-boot-starter</artifactId>
|
||||||
|
<version>1.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<!-- 代码库 -->
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>maven-ali</id>
|
||||||
|
<url>http://maven.aliyun.com/nexus/content/groups/public//</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<updatePolicy>always</updatePolicy>
|
||||||
|
<checksumPolicy>fail</checksumPolicy>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>public</id>
|
||||||
|
<name>aliyun nexus</name>
|
||||||
|
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
|
<!--module不用添加打包版本信息-->
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring.boot.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<fork>true</fork>
|
||||||
|
<addResources>true</addResources>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
99
xdclass-common/pom.xml
Normal file
99
xdclass-common/pom.xml
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<?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>net.jieyuu</groupId>
|
||||||
|
<artifactId>xdclass-shop</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>xdclass-common</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--项目中添加 spring-boot-starter-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 代码自动生成依赖 begin -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-generator</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- velocity -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--swagger ui接口文档依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--单元测试依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--kaptcha依赖包-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>kaptcha-spring-boot-starter</artifactId>
|
||||||
|
<version>1.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--redis客户端-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>io.lettuce</groupId>
|
||||||
|
<artifactId>lettuce-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>redis.clients</groupId>
|
||||||
|
<artifactId>jedis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,118 @@
|
|||||||
|
package net.jieyuu.config;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import springfox.documentation.builders.*;
|
||||||
|
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||||
|
import springfox.documentation.schema.ScalarType;
|
||||||
|
import springfox.documentation.service.*;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@EnableOpenApi
|
||||||
|
@Data
|
||||||
|
public class SwaggerConfiguration {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* C端文档
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Docket webApiDoc() {
|
||||||
|
|
||||||
|
|
||||||
|
return new Docket(DocumentationType.OAS_30)
|
||||||
|
.groupName("用户端接口文档")
|
||||||
|
.pathMapping("/")
|
||||||
|
// 定义是否开启swagger,false为关闭,可以通过变量控制,线上关闭
|
||||||
|
.enable(true)
|
||||||
|
//配置api文档元信息
|
||||||
|
.apiInfo(apiInfo())
|
||||||
|
// 选择哪些接口作为swagger的doc发布
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("net.jieyuu"))
|
||||||
|
//正则匹配请求路径,并分配至当前分组
|
||||||
|
.paths(PathSelectors.ant("/api/**"))
|
||||||
|
.build()
|
||||||
|
//新版swagger3.0配置
|
||||||
|
.globalRequestParameters(getGlobalRequestParameters())
|
||||||
|
.globalResponses(HttpMethod.GET, getGlobalResponseMessage())
|
||||||
|
.globalResponses(HttpMethod.POST, getGlobalResponseMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ApiInfo apiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("1024电商平台")
|
||||||
|
.description("微服务接口文档")
|
||||||
|
.contact(new Contact("jieyuu", "https://134.175.219.253", "645634619@qq.com"))
|
||||||
|
.version("12")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端文档
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Docket adminApiDoc() {
|
||||||
|
return new Docket(DocumentationType.OAS_30)
|
||||||
|
.groupName("管理端接口文档")
|
||||||
|
.pathMapping("/")
|
||||||
|
// 定义是否开启swagger,false为关闭,可以通过变量控制,线上关闭
|
||||||
|
.enable(true)
|
||||||
|
//配置api文档元信息
|
||||||
|
.apiInfo(apiInfo())
|
||||||
|
// 选择哪些接口作为swagger的doc发布
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("net.jieyuu"))
|
||||||
|
//正则匹配请求路径,并分配至当前分组
|
||||||
|
.paths(PathSelectors.ant("/admin/**"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成全局通用参数, 支持配置多个响应参数
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<RequestParameter> getGlobalRequestParameters() {
|
||||||
|
List<RequestParameter> parameters = new ArrayList<>();
|
||||||
|
parameters.add(new RequestParameterBuilder()
|
||||||
|
.name("token")
|
||||||
|
.description("登录令牌")
|
||||||
|
.in(ParameterType.HEADER)
|
||||||
|
.query(q -> q.model(m -> m.scalarModel(ScalarType.STRING)))
|
||||||
|
.required(false)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
// parameters.add(new RequestParameterBuilder()
|
||||||
|
// .name("version")
|
||||||
|
// .description("版本号")
|
||||||
|
// .required(true)
|
||||||
|
// .in(ParameterType.HEADER)
|
||||||
|
// .query(q -> q.model(m -> m.scalarModel(ScalarType.STRING)))
|
||||||
|
// .required(false)
|
||||||
|
// .build());
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成通用响应信息
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<Response> getGlobalResponseMessage() {
|
||||||
|
List<Response> responseList = new ArrayList<>();
|
||||||
|
responseList.add(new ResponseBuilder().code("4xx").description("请求错误,根据code和msg检查").build());
|
||||||
|
return responseList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package net.jieyuu.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 状态码定义约束,共6位数,前三位代表服务,后4位代表接口
|
||||||
|
* 比如 商品服务210,购物车是220、用户服务230,403代表权限
|
||||||
|
**/
|
||||||
|
public enum BizCodeEnum {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用操作码
|
||||||
|
*/
|
||||||
|
OPS_REPEAT(110001, "重复操作"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码
|
||||||
|
*/
|
||||||
|
CODE_TO_ERROR(240001, "接收号码不合规"),
|
||||||
|
CODE_LIMITED(240002, "验证码发送过快"),
|
||||||
|
CODE_ERROR(240003, "验证码错误"),
|
||||||
|
CODE_CAPTCHA(240101, "图形验证码错误"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账号
|
||||||
|
*/
|
||||||
|
ACCOUNT_REPEAT(250001, "账号已经存在"),
|
||||||
|
ACCOUNT_UNREGISTER(250002, "账号不存在"),
|
||||||
|
ACCOUNT_PWD_ERROR(250003, "账号或者密码错误");
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int code;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private BizCodeEnum(int code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package net.jieyuu.enums;
|
||||||
|
|
||||||
|
public enum SendCodeEnum {
|
||||||
|
USER_REGISTER;
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package net.jieyuu.exception;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.jieyuu.enums.BizCodeEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局异常处理
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BizException extends RuntimeException {
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
public BizException(Integer code, String message) {
|
||||||
|
super(message);
|
||||||
|
this.code = code;
|
||||||
|
this.msg = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BizException(BizCodeEnum bizCodeEnum) {
|
||||||
|
super(bizCodeEnum.getMessage());
|
||||||
|
this.code = bizCodeEnum.getCode();
|
||||||
|
this.msg = bizCodeEnum.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package net.jieyuu.exception;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.jieyuu.utils.JsonData;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
@ControllerAdvice
|
||||||
|
@Slf4j
|
||||||
|
public class CustomExceptionHandle {
|
||||||
|
|
||||||
|
@ExceptionHandler(value = Exception.class)
|
||||||
|
@ResponseBody
|
||||||
|
public JsonData Handle(Exception e) {
|
||||||
|
|
||||||
|
if (e instanceof BizException) {
|
||||||
|
BizException bizException = (BizException) e;
|
||||||
|
log.info("[业务异常]{}", e);
|
||||||
|
return JsonData.buildCodeAndMsg(bizException.getCode(), bizException.getMsg());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log.info("[系统异常]{}", e);
|
||||||
|
return JsonData.buildError("全局异常,未知错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
43
xdclass-common/src/main/java/net/jieyuu/utils/CheckUtil.java
Normal file
43
xdclass-common/src/main/java/net/jieyuu/utils/CheckUtil.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package net.jieyuu.utils;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class CheckUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮箱正则
|
||||||
|
*/
|
||||||
|
private static final Pattern MAIL_PATTERN = Pattern.compile("^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号正则,暂时未用
|
||||||
|
*/
|
||||||
|
private static final Pattern PHONE_PATTERN = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param email
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isEmail(String email) {
|
||||||
|
if (null == email || "".equals(email)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Matcher m = MAIL_PATTERN.matcher(email);
|
||||||
|
return m.matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂时未用
|
||||||
|
* @param phone
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isPhone(String phone) {
|
||||||
|
if (null == phone || "".equals(phone)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Matcher m = PHONE_PATTERN.matcher(phone);
|
||||||
|
return m.matches();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
package net.jieyuu.utils;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class CommonUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取ip
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getIpAddr(HttpServletRequest request) {
|
||||||
|
String ipAddress = null;
|
||||||
|
try {
|
||||||
|
ipAddress = request.getHeader("x-forwarded-for");
|
||||||
|
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||||
|
ipAddress = request.getHeader("Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||||
|
ipAddress = request.getHeader("WL-Proxy-Client-IP");
|
||||||
|
}
|
||||||
|
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
|
||||||
|
ipAddress = request.getRemoteAddr();
|
||||||
|
if (ipAddress.equals("127.0.0.1")) {
|
||||||
|
// 根据网卡取本机配置的IP
|
||||||
|
InetAddress inet = null;
|
||||||
|
try {
|
||||||
|
inet = InetAddress.getLocalHost();
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
ipAddress = inet.getHostAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
|
||||||
|
if (ipAddress != null && ipAddress.length() > 15) {
|
||||||
|
// "***.***.***.***".length()
|
||||||
|
// = 15
|
||||||
|
if (ipAddress.indexOf(",") > 0) {
|
||||||
|
ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
ipAddress = "";
|
||||||
|
}
|
||||||
|
return ipAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MD5加密
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String MD5(String data) {
|
||||||
|
try {
|
||||||
|
java.security.MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
byte[] array = md.digest(data.getBytes("UTF-8"));
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (byte item : array) {
|
||||||
|
sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString().toUpperCase();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成随机数
|
||||||
|
* @param length
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static String getRandomCode(int length) {
|
||||||
|
String sources = "0123456789";
|
||||||
|
Random random = new Random();
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
stringBuilder.append(sources.charAt(random.nextInt(9)));
|
||||||
|
}
|
||||||
|
return stringBuilder.toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
74
xdclass-common/src/main/java/net/jieyuu/utils/JsonData.java
Normal file
74
xdclass-common/src/main/java/net/jieyuu/utils/JsonData.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package net.jieyuu.utils;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import net.jieyuu.enums.BizCodeEnum;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class JsonData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态码 0 表示成功,1表示处理中,-1表示失败
|
||||||
|
*/
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据
|
||||||
|
*/
|
||||||
|
private Object data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功,传入数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static JsonData buildSuccess() {
|
||||||
|
return new JsonData(0, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功,传入数据
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static JsonData buildSuccess(Object data) {
|
||||||
|
return new JsonData(0, data, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 失败,传入描述信息
|
||||||
|
* @param msg
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static JsonData buildError(String msg) {
|
||||||
|
return new JsonData(-1, null, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义状态码和错误信息
|
||||||
|
* @param code
|
||||||
|
* @param msg
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static JsonData buildCodeAndMsg(int code, String msg) {
|
||||||
|
return new JsonData(code, null, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传入枚举,返回信息
|
||||||
|
* @param codeEnum
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static JsonData buildResult(BizCodeEnum codeEnum){
|
||||||
|
return JsonData.buildCodeAndMsg(codeEnum.getCode(),codeEnum.getMessage());
|
||||||
|
}
|
||||||
|
}
|
20
xdclass-coupon-service/pom.xml
Normal file
20
xdclass-coupon-service/pom.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?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>net.jieyuu</groupId>
|
||||||
|
<artifactId>xdclass-shop</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>xdclass-coupon-service</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
20
xdclass-gateway/pom.xml
Normal file
20
xdclass-gateway/pom.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?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>net.jieyuu</groupId>
|
||||||
|
<artifactId>xdclass-shop</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>xdclass-gateway</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
20
xdclass-order-service/pom.xml
Normal file
20
xdclass-order-service/pom.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?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>net.jieyuu</groupId>
|
||||||
|
<artifactId>xdclass-shop</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>xdclass-order-service</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
21
xdclass-product-service/pom.xml
Normal file
21
xdclass-product-service/pom.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?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>net.jieyuu</groupId>
|
||||||
|
<artifactId>xdclass-shop</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>xdclass-product-service</artifactId>
|
||||||
|
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
42
xdclass-user-service/pom.xml
Normal file
42
xdclass-user-service/pom.xml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?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>net.jieyuu</groupId>
|
||||||
|
<artifactId>xdclass-shop</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>xdclass-user-service</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.jieyuu</groupId>
|
||||||
|
<artifactId>xdclass-common</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>kaptcha-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--发送邮件-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,14 @@
|
|||||||
|
package net.jieyuu;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@MapperScan("net.jieyuu.mapper")
|
||||||
|
public class UserServiceApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(UserServiceApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package net.jieyuu.component;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 邮件发送类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
public interface MailService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件
|
||||||
|
* @param to
|
||||||
|
* @param subject
|
||||||
|
* @param content
|
||||||
|
*/
|
||||||
|
public void sendMail(String to, String subject, String content);
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package net.jieyuu.component.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.jieyuu.component.MailService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class MailServiceImpl implements MailService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spring Boot 提供了一个发送邮件的简单抽象,直接注入即可使用
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private JavaMailSender mailSender;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置文件中的发送邮箱
|
||||||
|
*/
|
||||||
|
@Value("${spring.mail.from}")
|
||||||
|
private String from;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMail(String to, String subject, String content) {
|
||||||
|
//创建SimpleMailMessage对象
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
//邮件发送人
|
||||||
|
message.setFrom(from);
|
||||||
|
//邮件接收人
|
||||||
|
message.setTo(to);
|
||||||
|
//邮件主题
|
||||||
|
message.setSubject(subject);
|
||||||
|
//邮件内容
|
||||||
|
message.setText(content);
|
||||||
|
//发送邮件
|
||||||
|
mailSender.send(message);
|
||||||
|
log.info("邮件发成功:{}", message.toString());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package net.jieyuu.config;
|
||||||
|
|
||||||
|
import com.google.code.kaptcha.Constants;
|
||||||
|
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||||
|
import com.google.code.kaptcha.util.Config;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class CaptchaConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码配置
|
||||||
|
* Kaptcha配置类名
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@Qualifier("captchaProducer")
|
||||||
|
public DefaultKaptcha kaptcha() {
|
||||||
|
DefaultKaptcha kaptcha = new DefaultKaptcha();
|
||||||
|
Properties properties = new Properties();
|
||||||
|
// properties.setProperty(Constants.KAPTCHA_BORDER, "yes");
|
||||||
|
// properties.setProperty(Constants.KAPTCHA_BORDER_COLOR, "220,220,220");
|
||||||
|
// //properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_COLOR, "38,29,12");
|
||||||
|
// properties.setProperty(Constants.KAPTCHA_IMAGE_WIDTH, "147");
|
||||||
|
// properties.setProperty(Constants.KAPTCHA_IMAGE_HEIGHT, "34");
|
||||||
|
// properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_SIZE, "25");
|
||||||
|
// //properties.setProperty(Constants.KAPTCHA_SESSION_KEY, "code");
|
||||||
|
//验证码个数
|
||||||
|
properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4");
|
||||||
|
// properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Courier");
|
||||||
|
//字体间隔
|
||||||
|
properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "8");
|
||||||
|
//干扰线颜色
|
||||||
|
// properties.setProperty(Constants.KAPTCHA_NOISE_COLOR, "white");
|
||||||
|
//干扰实现类
|
||||||
|
properties.setProperty(Constants.KAPTCHA_NOISE_IMPL, "com.google.code.kaptcha.impl.NoNoise");
|
||||||
|
//图片样式
|
||||||
|
properties.setProperty(Constants.KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.FishEyeGimpy");
|
||||||
|
//文字来源
|
||||||
|
properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_STRING, "0123456789");
|
||||||
|
Config config = new Config(properties);
|
||||||
|
kaptcha.setConfig(config);
|
||||||
|
return kaptcha;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package net.jieyuu.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import net.jieyuu.service.AddressService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电商-公司收发货地址表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
@Api(tags = "收货地址模块")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/adderss/v1/")
|
||||||
|
public class AddressController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
AddressService addressService;
|
||||||
|
|
||||||
|
@ApiOperation("根据id查询地址详情")
|
||||||
|
@GetMapping("detail/{address_id}")
|
||||||
|
public Object detail(
|
||||||
|
@ApiParam(value = "地址", required = true)
|
||||||
|
@PathVariable("address_id") long id) {
|
||||||
|
return addressService.detail(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,124 @@
|
|||||||
|
package net.jieyuu.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.code.kaptcha.Producer;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.jieyuu.enums.SendCodeEnum;
|
||||||
|
import net.jieyuu.service.NotifyService;
|
||||||
|
import net.jieyuu.utils.CommonUtil;
|
||||||
|
import net.jieyuu.utils.JsonData;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
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.imageio.ImageIO;
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
|
@Api(tags = "短信通知")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/user/v1")
|
||||||
|
@Slf4j
|
||||||
|
public class NotifyController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Producer captchaProducer;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NotifyService notifyService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 临时使用10分钟有效,方便测试
|
||||||
|
*/
|
||||||
|
private static final long CAPTCHA_CODE_EXPIRED = 60 * 1000 * 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取图形验证码
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取图形验证码")
|
||||||
|
@GetMapping("captcha")
|
||||||
|
public void getCaptcha(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
|
||||||
|
String cacheKey = getCaptchaKey(request);
|
||||||
|
|
||||||
|
String capText = captchaProducer.createText();
|
||||||
|
|
||||||
|
//存储
|
||||||
|
redisTemplate.opsForValue().set(cacheKey, capText, CAPTCHA_CODE_EXPIRED, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
BufferedImage bi = captchaProducer.createImage(capText);
|
||||||
|
ServletOutputStream out = null;
|
||||||
|
try {
|
||||||
|
response.setDateHeader("Expires", 0);
|
||||||
|
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
|
||||||
|
response.addHeader("Cache-Control", "create_date-check=0, pre-check=0");
|
||||||
|
response.setHeader("Pragma", "no-cache");
|
||||||
|
out = response.getOutputStream();
|
||||||
|
ImageIO.write(bi, "jpg", out);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("获取验证码失败:{}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码接口
|
||||||
|
* 1 匹配图形验证码
|
||||||
|
* 2 发送邮件验证码
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation("发送注册验证码")
|
||||||
|
@GetMapping("send_code")
|
||||||
|
public JsonData sendRegisterCode(@ApiParam("收信人") @RequestParam(value = "to", required = true) String to,
|
||||||
|
@ApiParam("图形验证码") @RequestParam(value = "captcha", required = true) String captcha,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
String captchaKey = getCaptchaKey(request);
|
||||||
|
String cacheCaptcha = redisTemplate.opsForValue().get(captchaKey);
|
||||||
|
if (!StringUtils.isEmpty(captcha) || !StringUtils.isEmpty(cacheCaptcha) || captcha.equalsIgnoreCase(cacheCaptcha)) {
|
||||||
|
redisTemplate.delete(captchaKey);
|
||||||
|
JsonData jsonData = notifyService.sendCode(SendCodeEnum.USER_REGISTER, to);
|
||||||
|
return jsonData;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存的key
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getCaptchaKey(HttpServletRequest request) {
|
||||||
|
String ip = CommonUtil.getIpAddr(request);
|
||||||
|
String userAgent = request.getHeader("User-Agent");
|
||||||
|
|
||||||
|
String key = "user-service:captcha:" + CommonUtil.MD5(ip + userAgent);
|
||||||
|
log.info(key);
|
||||||
|
log.info("ip:{}", ip);
|
||||||
|
log.info("useragent{}", userAgent);
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package net.jieyuu.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import net.jieyuu.service.AddressService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
@Api(tags = "用户模块")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/user/v1/")
|
||||||
|
public class UserController {
|
||||||
|
@Autowired
|
||||||
|
AddressService addressService;
|
||||||
|
|
||||||
|
@ApiOperation("根据id查询地址详情")
|
||||||
|
@GetMapping("detail/{address_id}")
|
||||||
|
public Object detail(
|
||||||
|
@ApiParam(value = "地址", required = true)
|
||||||
|
@PathVariable("address_id") long id) {
|
||||||
|
return addressService.detail(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
package net.jieyuu.mapper;
|
||||||
|
|
||||||
|
import net.jieyuu.model.AddressDO;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电商-公司收发货地址表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
public interface AddressMapper extends BaseMapper<AddressDO> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package net.jieyuu.mapper;
|
||||||
|
|
||||||
|
import net.jieyuu.model.UserDO;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
public interface UserMapper extends BaseMapper<UserDO> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package net.jieyuu.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import java.util.Date;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电商-公司收发货地址表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("address")
|
||||||
|
public class AddressDO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否默认收货地址:0->否;1->是
|
||||||
|
*/
|
||||||
|
private Integer defaultStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收发货人姓名
|
||||||
|
*/
|
||||||
|
private String receiveName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收货人电话
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 省/直辖市
|
||||||
|
*/
|
||||||
|
private String province;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 市
|
||||||
|
*/
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区
|
||||||
|
*/
|
||||||
|
private String region;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详细地址
|
||||||
|
*/
|
||||||
|
private String detailAddress;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package net.jieyuu.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import java.util.Date;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("user")
|
||||||
|
public class UserDO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 昵称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String pwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头像
|
||||||
|
*/
|
||||||
|
private String headImg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户签名
|
||||||
|
*/
|
||||||
|
private String slogan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0表示女,1表示男
|
||||||
|
*/
|
||||||
|
private Integer sex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分
|
||||||
|
*/
|
||||||
|
private Integer points;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
*/
|
||||||
|
private String mail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 盐,用于个人敏感信息处理
|
||||||
|
*/
|
||||||
|
private String secret;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package net.jieyuu.service;
|
||||||
|
|
||||||
|
import net.jieyuu.mapper.AddressMapper;
|
||||||
|
import net.jieyuu.model.AddressDO;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电商-公司收发货地址表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
public interface AddressService extends IService<AddressDO> {
|
||||||
|
public AddressDO detail(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package net.jieyuu.service;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 邮件发送类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
public interface MailService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件
|
||||||
|
* @param to
|
||||||
|
* @param subject
|
||||||
|
* @param content
|
||||||
|
*/
|
||||||
|
public void sendMail(String to, String subject, String content);
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package net.jieyuu.service;
|
||||||
|
|
||||||
|
import net.jieyuu.enums.SendCodeEnum;
|
||||||
|
import net.jieyuu.utils.JsonData;
|
||||||
|
|
||||||
|
public interface NotifyService {
|
||||||
|
|
||||||
|
public JsonData sendCode(SendCodeEnum sendCodeType, String to);
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package net.jieyuu.service;
|
||||||
|
|
||||||
|
import net.jieyuu.model.UserDO;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
public interface UserService extends IService<UserDO> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package net.jieyuu.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import net.jieyuu.model.AddressDO;
|
||||||
|
import net.jieyuu.mapper.AddressMapper;
|
||||||
|
import net.jieyuu.service.AddressService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电商-公司收发货地址表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AddressServiceImpl extends ServiceImpl<AddressMapper, AddressDO> implements AddressService {
|
||||||
|
@Autowired
|
||||||
|
private AddressMapper addressMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AddressDO detail(Long id) {
|
||||||
|
QueryWrapper<AddressDO> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("id", id);
|
||||||
|
return addressMapper.selectOne(queryWrapper);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package net.jieyuu.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.jieyuu.service.MailService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class MailServiceImpl implements MailService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spring Boot 提供了一个发送邮件的简单抽象,直接注入即可使用
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private JavaMailSender mailSender;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置文件中的发送邮箱
|
||||||
|
*/
|
||||||
|
@Value("${spring.mail.from}")
|
||||||
|
private String from;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMail(String to, String subject, String content) {
|
||||||
|
//创建SimpleMailMessage对象
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
//邮件发送人
|
||||||
|
message.setFrom(from);
|
||||||
|
//邮件接收人
|
||||||
|
message.setTo(to);
|
||||||
|
//邮件主题
|
||||||
|
message.setSubject(subject);
|
||||||
|
//邮件内容
|
||||||
|
message.setText(content);
|
||||||
|
//发送邮件
|
||||||
|
mailSender.send(message);
|
||||||
|
log.info("邮件发成功:{}", message.toString());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package net.jieyuu.service.impl;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.jieyuu.enums.SendCodeEnum;
|
||||||
|
import net.jieyuu.service.MailService;
|
||||||
|
import net.jieyuu.service.NotifyService;
|
||||||
|
import net.jieyuu.utils.CheckUtil;
|
||||||
|
import net.jieyuu.utils.CommonUtil;
|
||||||
|
import net.jieyuu.utils.JsonData;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.security.auth.Subject;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class NotifyServiceImpl implements NotifyService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MailService mailService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
public static final String SUBJECT = "验证码";
|
||||||
|
public static final String CONTENT = "您的验证码是%s,有效时间为60秒";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置判断:判断是否重复发送
|
||||||
|
* 1 存储验证码到缓存
|
||||||
|
*
|
||||||
|
* 2 发送验证码
|
||||||
|
* 后置 存储发送记录
|
||||||
|
*
|
||||||
|
* @param sendCodeType
|
||||||
|
* @param to
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public JsonData sendCode(SendCodeEnum sendCodeType, String to) {
|
||||||
|
if (CheckUtil.isEmail(to)) {
|
||||||
|
//邮箱验证码
|
||||||
|
String code = CommonUtil.getRandomCode(6);
|
||||||
|
mailService.sendMail(to, SUBJECT, String.format(CONTENT, code));
|
||||||
|
return JsonData.buildSuccess();
|
||||||
|
|
||||||
|
} else if (CheckUtil.isPhone(to)) {
|
||||||
|
//短信验证码
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package net.jieyuu.service.impl;
|
||||||
|
|
||||||
|
import net.jieyuu.model.UserDO;
|
||||||
|
import net.jieyuu.mapper.UserMapper;
|
||||||
|
import net.jieyuu.service.UserService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author jieyuu
|
||||||
|
* @since 2024-02-12
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements UserService {
|
||||||
|
|
||||||
|
}
|
39
xdclass-user-service/src/main/resources/application.yml
Normal file
39
xdclass-user-service/src/main/resources/application.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
server:
|
||||||
|
port: 9001
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: xdclass-user-service
|
||||||
|
|
||||||
|
|
||||||
|
#数据库配置
|
||||||
|
datasource:
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://134.175.219.253:3306/xdclass_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||||
|
username: root
|
||||||
|
password: 59ae8683c59fead903132a8d440bd7d9fd4936529d1d6f45f9d41111d7537bdd
|
||||||
|
redis:
|
||||||
|
host: 134.175.219.253
|
||||||
|
password: 123456
|
||||||
|
port: 8000
|
||||||
|
mail:
|
||||||
|
host: smtp.163.com #发送邮件服务器
|
||||||
|
username: wa787966@163.com #发送邮件的邮箱地址
|
||||||
|
password: QIVDMITCCGMDFFBO #客户端授权码,不是邮箱密码,网易的是自己设置的
|
||||||
|
from: wa787966@163.com # 发送邮件的地址,和上面username一致
|
||||||
|
properties.mail.smtp:
|
||||||
|
starttls:
|
||||||
|
enable: true
|
||||||
|
required: true
|
||||||
|
ssl.enable: true
|
||||||
|
default-encoding: utf-8
|
||||||
|
|
||||||
|
#配置plus打印sql日志
|
||||||
|
mybatis-plus:
|
||||||
|
configuration:
|
||||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
||||||
|
#设置日志级别,ERROR/WARN/INFO/DEBUG,默认是INFO以上才显示
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
root: INFO
|
@ -0,0 +1,24 @@
|
|||||||
|
<?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="net.jieyuu.mapper.AddressMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="net.jieyuu.model.AddressDO">
|
||||||
|
<id column="id" property="id" />
|
||||||
|
<result column="user_id" property="userId" />
|
||||||
|
<result column="default_status" property="defaultStatus" />
|
||||||
|
<result column="receive_name" property="receiveName" />
|
||||||
|
<result column="phone" property="phone" />
|
||||||
|
<result column="province" property="province" />
|
||||||
|
<result column="city" property="city" />
|
||||||
|
<result column="region" property="region" />
|
||||||
|
<result column="detail_address" property="detailAddress" />
|
||||||
|
<result column="create_time" property="createTime" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, user_id, default_status, receive_name, phone, province, city, region, detail_address, create_time
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,24 @@
|
|||||||
|
<?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="net.jieyuu.mapper.UserMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="net.jieyuu.model.UserDO">
|
||||||
|
<id column="id" property="id" />
|
||||||
|
<result column="name" property="name" />
|
||||||
|
<result column="pwd" property="pwd" />
|
||||||
|
<result column="head_img" property="headImg" />
|
||||||
|
<result column="slogan" property="slogan" />
|
||||||
|
<result column="sex" property="sex" />
|
||||||
|
<result column="points" property="points" />
|
||||||
|
<result column="create_time" property="createTime" />
|
||||||
|
<result column="mail" property="mail" />
|
||||||
|
<result column="secret" property="secret" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, name, pwd, head_img, slogan, sex, points, create_time, mail, secret
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,30 @@
|
|||||||
|
package net.jieyuu.biz;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.jieyuu.UserServiceApplication;
|
||||||
|
import net.jieyuu.model.AddressDO;
|
||||||
|
import net.jieyuu.service.AddressService;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = UserServiceApplication.class)
|
||||||
|
@Slf4j
|
||||||
|
public class AddressTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AddressService addressService;
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddressDetail() {
|
||||||
|
|
||||||
|
AddressDO addressDO = addressService.detail(1L);
|
||||||
|
log.info(addressDO.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package net.jieyuu.biz;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.jieyuu.UserServiceApplication;
|
||||||
|
import net.jieyuu.service.MailService;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = UserServiceApplication.class)
|
||||||
|
@Slf4j
|
||||||
|
public class MailTest {
|
||||||
|
@Autowired
|
||||||
|
private MailService mailService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sendMail(){
|
||||||
|
mailService.sendMail("645634619@qq.com","邮件发送测试","nihaonihao");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
package net.jieyuu.db;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.PackageConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||||
|
|
||||||
|
public class MyBatisPlusGenerator {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
//1. 全局配置
|
||||||
|
GlobalConfig config = new GlobalConfig();
|
||||||
|
// 是否支持AR模式
|
||||||
|
config.setActiveRecord(true)
|
||||||
|
// 作者
|
||||||
|
.setAuthor("jieyuu")
|
||||||
|
// 生成路径,最好使用绝对路径,window路径是不一样的
|
||||||
|
//TODO TODO TODO TODO
|
||||||
|
.setOutputDir("D:\\workspace\\project\\xdclass-shop\\xdclass-shop\\xdclass-user-service\\src\\main\\java")
|
||||||
|
// 文件覆盖
|
||||||
|
.setFileOverride(true)
|
||||||
|
// 主键策略
|
||||||
|
.setIdType(IdType.AUTO)
|
||||||
|
|
||||||
|
.setDateType(DateType.ONLY_DATE)
|
||||||
|
// 设置生成的service接口的名字的首字母是否为I,默认Service是以I开头的
|
||||||
|
.setServiceName("%sService")
|
||||||
|
|
||||||
|
//实体类结尾名称
|
||||||
|
.setEntityName("%sDO")
|
||||||
|
|
||||||
|
//生成基本的resultMap
|
||||||
|
.setBaseResultMap(true)
|
||||||
|
|
||||||
|
//不使用AR模式
|
||||||
|
.setActiveRecord(false)
|
||||||
|
|
||||||
|
//生成基本的SQL片段
|
||||||
|
.setBaseColumnList(true);
|
||||||
|
|
||||||
|
//2. 数据源配置
|
||||||
|
DataSourceConfig dsConfig = new DataSourceConfig();
|
||||||
|
// 设置数据库类型
|
||||||
|
dsConfig.setDbType(DbType.MYSQL)
|
||||||
|
.setDriverName("com.mysql.cj.jdbc.Driver")
|
||||||
|
//TODO TODO TODO TODO
|
||||||
|
.setUrl("jdbc:mysql://134.175.219.253:3306/xdclass_user?useSSL=false")
|
||||||
|
.setUsername("root")
|
||||||
|
.setPassword("59ae8683c59fead903132a8d440bd7d9fd4936529d1d6f45f9d41111d7537bdd");
|
||||||
|
|
||||||
|
//3. 策略配置globalConfiguration中
|
||||||
|
StrategyConfig stConfig = new StrategyConfig();
|
||||||
|
|
||||||
|
//全局大写命名
|
||||||
|
stConfig.setCapitalMode(true)
|
||||||
|
// 数据库表映射到实体的命名策略
|
||||||
|
.setNaming(NamingStrategy.underline_to_camel)
|
||||||
|
|
||||||
|
//使用lombok
|
||||||
|
.setEntityLombokModel(true)
|
||||||
|
|
||||||
|
//使用restcontroller注解
|
||||||
|
.setRestControllerStyle(true)
|
||||||
|
|
||||||
|
// 生成的表, 支持多表一起生成,以数组形式填写
|
||||||
|
//TODO TODO TODO TODO
|
||||||
|
.setInclude("user","address");
|
||||||
|
|
||||||
|
//4. 包名策略配置
|
||||||
|
PackageConfig pkConfig = new PackageConfig();
|
||||||
|
pkConfig.setParent("net.jieyuu")
|
||||||
|
.setMapper("mapper")
|
||||||
|
.setService("service")
|
||||||
|
.setController("controller")
|
||||||
|
.setEntity("model")
|
||||||
|
.setXml("mapper");
|
||||||
|
|
||||||
|
//5. 整合配置
|
||||||
|
AutoGenerator ag = new AutoGenerator();
|
||||||
|
ag.setGlobalConfig(config)
|
||||||
|
.setDataSource(dsConfig)
|
||||||
|
.setStrategy(stConfig)
|
||||||
|
.setPackageInfo(pkConfig);
|
||||||
|
|
||||||
|
//6. 执行操作
|
||||||
|
ag.execute();
|
||||||
|
System.out.println("======= 小滴课堂 Done 相关代码生成完毕 ========");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user