commit
385b377b10
@ -0,0 +1,2 @@
|
|||||||
|
# software_teamwork
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 118 KiB |
After Width: | Height: | Size: 121 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.6 MiB |
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# 基于编辑器的 HTTP 客户端请求
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
@ -0,0 +1,21 @@
|
|||||||
|
<?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="common" />
|
||||||
|
<module name="service" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
<component name="JavacSettings">
|
||||||
|
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||||
|
<module name="common" options="-parameters" />
|
||||||
|
<module name="luojia_channel" options="" />
|
||||||
|
<module name="service" options="-parameters" />
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="luojia_channel@192.168.59.129" uuid="fef17b9b-50ef-45a3-bed5-7aa6704a7372">
|
||||||
|
<driver-ref>mysql.8</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<imported>true</imported>
|
||||||
|
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:mysql://192.168.59.129:3306/luojia_channel?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="0@192.168.59.129" uuid="ad808a5f-004d-4f31-9402-19010c1be1ab">
|
||||||
|
<driver-ref>redis</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<imported>true</imported>
|
||||||
|
<jdbc-driver>jdbc.RedisDriver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:redis://192.168.59.129:6379/0</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/common/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/service/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://maven.aliyun.com/repository/public" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"luatools_path": "~/go/bin",
|
||||||
|
"dto_dir": "./ngx_conf/dto",
|
||||||
|
"swagger.docs.path": "./docs",
|
||||||
|
"swagger.excludes": "./client",
|
||||||
|
"swagger.file.type": "json",
|
||||||
|
"swagger.main.lua.path": "./main.lua",
|
||||||
|
"swagger.name": "swagger",
|
||||||
|
"swagger.search_dirs": "./ngx_conf,./config/cn/online",
|
||||||
|
"validator_dir": "./ngx_conf/validator",
|
||||||
|
"yapi.config.file": "docs/swagger-yapi.json",
|
||||||
|
"yapi.config.mode": "mergin",
|
||||||
|
"yapi.config.server": "https://api.yapi.net",
|
||||||
|
"yapi.config.token": "xxxxxxxxx"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/service/src/main/resources/db/luojia_channel.sql" dialect="GenericSQL" />
|
||||||
|
<file url="PROJECT" dialect="MySQL" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
|
https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.luojia</groupId>
|
||||||
|
<artifactId>luojia_channel</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- Redisson分布式锁 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 工具类库 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.14.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>transmittable-thread-local</artifactId>
|
||||||
|
<version>2.13.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- JWT 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-api</artifactId>
|
||||||
|
<version>0.11.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-impl</artifactId>
|
||||||
|
<version>0.11.5</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
|
<version>0.11.5</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.luojia_channel.common.advice;
|
||||||
|
|
||||||
|
|
||||||
|
import com.luojia_channel.common.domain.Result;
|
||||||
|
import com.luojia_channel.common.exception.BaseException;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
|
||||||
|
// 全局异常处理
|
||||||
|
@Slf4j
|
||||||
|
@RestControllerAdvice
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
// 处理自定义业务异常
|
||||||
|
@ExceptionHandler(BaseException.class)
|
||||||
|
public Object handleBadRequestException(BaseException e) {
|
||||||
|
log.error("自定义异常 -> {} , 异常原因:{} ",e.getClass().getName(), e.getMessage());
|
||||||
|
log.debug("", e);
|
||||||
|
return Result.fail(e.getErrorCode(), e.getErrorMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.luojia_channel.common.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class MybatisConfig {
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.luojia_channel.common.config;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
|
||||||
|
import org.redisson.Redisson;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
|
import org.redisson.config.Config;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RedisConfig {
|
||||||
|
@Bean
|
||||||
|
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||||
|
|
||||||
|
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||||
|
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||||
|
// 设置key和value的序列化规则
|
||||||
|
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||||
|
redisTemplate.setValueSerializer(new GenericFastJsonRedisSerializer());
|
||||||
|
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||||
|
redisTemplate.setHashValueSerializer(new GenericFastJsonRedisSerializer());
|
||||||
|
|
||||||
|
return redisTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redisson分布式锁
|
||||||
|
@Value("${spring.data.redis.host}")
|
||||||
|
private String host;
|
||||||
|
@Value("${spring.data.redis.port}")
|
||||||
|
private String port;
|
||||||
|
@Value("${spring.data.redis.password}")
|
||||||
|
private String password;
|
||||||
|
@Bean
|
||||||
|
public RedissonClient redissonClient(){
|
||||||
|
//配置
|
||||||
|
Config config=new Config();
|
||||||
|
config.useSingleServer().setAddress("redis://"+host+":"+port).setPassword(password);
|
||||||
|
//创建对并且返回
|
||||||
|
return Redisson.create(config);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.luojia_channel.common.config;
|
||||||
|
|
||||||
|
import com.luojia_channel.common.interceptor.AuthInterceptor;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
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;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class WebMvcConfig implements WebMvcConfigurer {
|
||||||
|
private final AuthInterceptor authInterceptor;
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
// 登录拦截器
|
||||||
|
registry.addInterceptor(authInterceptor)
|
||||||
|
.excludePathPatterns("/user/login",
|
||||||
|
"/user/register"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PasswordEncoder passwordEncoder() {
|
||||||
|
return new BCryptPasswordEncoder();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.luojia_channel.common.constants;
|
||||||
|
|
||||||
|
public class RedisConstant {
|
||||||
|
// redis存储的refreshToken前缀
|
||||||
|
public static final String REFRESH_TOKEN_PREFIX = "refresh_token:";
|
||||||
|
// redis存储的黑名单前缀
|
||||||
|
public static final String BLACKLIST_PREFIX = "blacklist:";
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.luojia_channel.common.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
// 统一返回前端的结果
|
||||||
|
@Data
|
||||||
|
public class Result<T> {
|
||||||
|
private int code;
|
||||||
|
private String msg;
|
||||||
|
private T data;
|
||||||
|
public Result(int code, String msg, T data) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
public static <T> Result<T> success(T data) {
|
||||||
|
return new Result<>(200, "success", data);
|
||||||
|
}
|
||||||
|
public static <T> Result<T> success() {
|
||||||
|
return new Result<>(200, "success", null);
|
||||||
|
}
|
||||||
|
public static <T> Result<T> fail(String msg) {
|
||||||
|
return new Result<>(500, msg, null);
|
||||||
|
}
|
||||||
|
public static <T> Result<T> fail(int code, String msg) {
|
||||||
|
return new Result<>(code, msg, null);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.luojia_channel.common.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class UserDTO {
|
||||||
|
private Long userId;
|
||||||
|
private String username;
|
||||||
|
private String accessToken;
|
||||||
|
private String refreshToken;
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.luojia_channel.common.exception;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class BaseException extends RuntimeException {
|
||||||
|
private final int errorCode;
|
||||||
|
private final String errorMessage;
|
||||||
|
|
||||||
|
public BaseException(int errorCode, String errorMessage) {
|
||||||
|
super(errorMessage);
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
this.errorMessage = errorMessage;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.luojia_channel.common.exception;
|
||||||
|
|
||||||
|
public class UserException extends BaseException{
|
||||||
|
public UserException(String msg){
|
||||||
|
super(500, msg);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.luojia_channel.common.interceptor;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.luojia_channel.common.domain.Result;
|
||||||
|
import com.luojia_channel.common.domain.UserDTO;
|
||||||
|
import com.luojia_channel.common.exception.UserException;
|
||||||
|
import com.luojia_channel.common.utils.JWTUtil;
|
||||||
|
import com.luojia_channel.common.utils.UserContext;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AuthInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
private final JWTUtil jwtUtil;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request,
|
||||||
|
HttpServletResponse response,
|
||||||
|
Object handler) throws Exception {
|
||||||
|
// 获取请求中的双Token
|
||||||
|
String accessToken = request.getHeader("Authorization");
|
||||||
|
String refreshToken = request.getHeader("X-Refresh-Token");
|
||||||
|
try {
|
||||||
|
// 验证Token并处理自动刷新
|
||||||
|
UserDTO user = jwtUtil.checkLogin(accessToken, refreshToken);
|
||||||
|
// 将新Token写入响应头
|
||||||
|
if (user.getAccessToken() != null) {
|
||||||
|
response.setHeader("New-Access-Token", JWTUtil.TOKEN_PREFIX + user.getAccessToken());
|
||||||
|
response.setHeader("New-Refresh-Token", user.getRefreshToken());
|
||||||
|
}
|
||||||
|
UserContext.setUser(user);
|
||||||
|
return true;
|
||||||
|
} catch (UserException ex) {
|
||||||
|
// Token验证失败处理
|
||||||
|
response.setContentType("application/json");
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||||
|
response.getWriter().write(
|
||||||
|
JSON.toJSONString(Result.fail(ex.getMessage()))
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,168 @@
|
|||||||
|
package com.luojia_channel.common.utils;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.ZSetOperations;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RedisUtil {
|
||||||
|
|
||||||
|
private final RedisTemplate<String, Object> redisTemplate;
|
||||||
|
private static final Long DEFAULT_TIMEOUT = 30000L;
|
||||||
|
private static final TimeUnit DEFAULT_TIME_UNIT = TimeUnit.MILLISECONDS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* redis基础操作
|
||||||
|
*/
|
||||||
|
|
||||||
|
public <T> T get(String key, Class<T> type) {
|
||||||
|
Object value = redisTemplate.opsForValue().get(key);
|
||||||
|
return value != null ? type.cast(value) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(String key, Object value) {
|
||||||
|
redisTemplate.opsForValue().set(key, value, DEFAULT_TIMEOUT, DEFAULT_TIME_UNIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(String key, Object value, long timeout, TimeUnit unit) {
|
||||||
|
redisTemplate.opsForValue().set(key, value, timeout, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void expire(String key, long time, TimeUnit timeUnit) {
|
||||||
|
redisTemplate.expire(key, time, timeUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(String key) {
|
||||||
|
redisTemplate.delete(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasKey(String key) {
|
||||||
|
Boolean result = redisTemplate.hasKey(key);
|
||||||
|
return result != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getExpire(String key, TimeUnit timeUnit){
|
||||||
|
return redisTemplate.getExpire(key, timeUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set操作
|
||||||
|
*/
|
||||||
|
private <T> List<T> convertSetToList(Set<Object> set) {
|
||||||
|
if(set == null || set.isEmpty()){
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return set.stream().map(obj -> (T) obj).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sAdd(String key, Object... values) {
|
||||||
|
redisTemplate.opsForSet().add(key, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sRemove(String key, Object... values) {
|
||||||
|
redisTemplate.opsForSet().remove(key, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> List<T> sGet(String key) {
|
||||||
|
Set<Object> members = redisTemplate.opsForSet().members(key);
|
||||||
|
return convertSetToList(members);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean sIsMember(String key, Object value){
|
||||||
|
return redisTemplate.opsForSet().isMember(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> List<T> sCommon(String key, String otherKey){
|
||||||
|
Set<Object> intersect = redisTemplate.opsForSet().intersect(key, otherKey);
|
||||||
|
return convertSetToList(intersect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* zSet操作
|
||||||
|
*/
|
||||||
|
// 带分数的结果包装类
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class ZSetItem<T> {
|
||||||
|
private T value;
|
||||||
|
private Double score;
|
||||||
|
}
|
||||||
|
private <T> List<ZSetItem<T>> convertTuples(Set<ZSetOperations.TypedTuple<Object>> tuples) {
|
||||||
|
if(tuples == null || tuples.isEmpty()){
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return tuples.stream()
|
||||||
|
.map(tuple -> new ZSetItem<T>(
|
||||||
|
(T) tuple.getValue(),
|
||||||
|
tuple.getScore() != null ? tuple.getScore() : 0.0
|
||||||
|
))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加元素
|
||||||
|
public Boolean zAdd(String key, Object value, double score) {
|
||||||
|
return redisTemplate.opsForZSet().add(key, value, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean zAdd(String key, Object value, double score, long timeout, TimeUnit unit) {
|
||||||
|
Boolean result = redisTemplate.opsForZSet().add(key, value, score);
|
||||||
|
if (Boolean.TRUE.equals(result)) {
|
||||||
|
redisTemplate.expire(key, timeout, unit);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取范围
|
||||||
|
public <T> List<T> zRange(String key, long start, long end) {
|
||||||
|
Set<Object> values = redisTemplate.opsForZSet().range(key, start, end);
|
||||||
|
return convertSetToList(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> List<T> zRevRange(String key, long start, long end) {
|
||||||
|
Set<Object> values = redisTemplate.opsForZSet().reverseRange(key, start, end);
|
||||||
|
return convertSetToList(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 带分数查询(用于热度计算)
|
||||||
|
public <T> List<ZSetItem<T>> zRangeWithScores(String key, long start, long end) {
|
||||||
|
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisTemplate.opsForZSet().rangeWithScores(key, start, end);
|
||||||
|
return convertTuples(typedTuples);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 增减分数(用于点赞数统计)
|
||||||
|
public Double zIncrScore(String key, Object value, double delta) {
|
||||||
|
return redisTemplate.opsForZSet().incrementScore(key, value, delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除元素
|
||||||
|
public Long zRemove(String key, Object... values) {
|
||||||
|
return redisTemplate.opsForZSet().remove(key, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取排名(用于热榜)
|
||||||
|
public Long zRank(String key, Object value) {
|
||||||
|
return redisTemplate.opsForZSet().rank(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long zRevRank(String key, Object value) {
|
||||||
|
return redisTemplate.opsForZSet().reverseRank(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取集合大小
|
||||||
|
public Long zCard(String key) {
|
||||||
|
return redisTemplate.opsForZSet().zCard(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.luojia_channel.common.utils;
|
||||||
|
|
||||||
|
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||||
|
import com.luojia_channel.common.domain.UserDTO;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
// 用户上下文
|
||||||
|
public final class UserContext {
|
||||||
|
|
||||||
|
private static final ThreadLocal<UserDTO> USER_THREAD_LOCAL = new TransmittableThreadLocal<>();
|
||||||
|
public static void setUser(UserDTO user) {
|
||||||
|
USER_THREAD_LOCAL.set(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Long getUserId() {
|
||||||
|
UserDTO userInfoDTO = USER_THREAD_LOCAL.get();
|
||||||
|
return Optional.ofNullable(userInfoDTO).map(UserDTO::getUserId).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getUsername() {
|
||||||
|
UserDTO userInfoDTO = USER_THREAD_LOCAL.get();
|
||||||
|
return Optional.ofNullable(userInfoDTO).map(UserDTO::getUsername).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getAccessToken() {
|
||||||
|
UserDTO userInfoDTO = USER_THREAD_LOCAL.get();
|
||||||
|
return Optional.ofNullable(userInfoDTO).map(UserDTO::getAccessToken).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getRefreshToken() {
|
||||||
|
UserDTO userInfoDTO = USER_THREAD_LOCAL.get();
|
||||||
|
return Optional.ofNullable(userInfoDTO).map(UserDTO::getRefreshToken).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeUser() {
|
||||||
|
USER_THREAD_LOCAL.remove();
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
|||||||
|
artifactId=common
|
||||||
|
groupId=com.luojia
|
||||||
|
version=1.0.0
|
@ -0,0 +1,11 @@
|
|||||||
|
com\luojia\luojia_channel\advice\GlobalExceptionHandler.class
|
||||||
|
com\luojia\luojia_channel\domain\UserDTO.class
|
||||||
|
com\luojia\luojia_channel\utils\UserContext.class
|
||||||
|
com\luojia\luojia_channel\utils\JWTUtil.class
|
||||||
|
com\luojia\luojia_channel\config\RedisConfig.class
|
||||||
|
com\luojia\luojia_channel\utils\RedisUtil$ZSetItem.class
|
||||||
|
com\luojia\luojia_channel\domain\UserDTO$UserDTOBuilder.class
|
||||||
|
com\luojia\luojia_channel\exception\BaseException.class
|
||||||
|
com\luojia\luojia_channel\utils\RedisUtil.class
|
||||||
|
com\luojia\luojia_channel\domain\Result.class
|
||||||
|
com\luojia\luojia_channel\exception\UserException.class
|
@ -0,0 +1,9 @@
|
|||||||
|
D:\javaCode\luojia_channel\common\src\main\java\com\luojia\luojia_channel\advice\GlobalExceptionHandler.java
|
||||||
|
D:\javaCode\luojia_channel\common\src\main\java\com\luojia\luojia_channel\config\RedisConfig.java
|
||||||
|
D:\javaCode\luojia_channel\common\src\main\java\com\luojia\luojia_channel\domain\Result.java
|
||||||
|
D:\javaCode\luojia_channel\common\src\main\java\com\luojia\luojia_channel\domain\UserDTO.java
|
||||||
|
D:\javaCode\luojia_channel\common\src\main\java\com\luojia\luojia_channel\exception\BaseException.java
|
||||||
|
D:\javaCode\luojia_channel\common\src\main\java\com\luojia\luojia_channel\exception\UserException.java
|
||||||
|
D:\javaCode\luojia_channel\common\src\main\java\com\luojia\luojia_channel\utils\JWTUtil.java
|
||||||
|
D:\javaCode\luojia_channel\common\src\main\java\com\luojia\luojia_channel\utils\RedisUtil.java
|
||||||
|
D:\javaCode\luojia_channel\common\src\main\java\com\luojia\luojia_channel\utils\UserContext.java
|
@ -0,0 +1,108 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
|
https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.4.3</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>com.luojia</groupId>
|
||||||
|
<artifactId>luojia_channel</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<modules>
|
||||||
|
<module>common</module>
|
||||||
|
<module>service</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
<spring-cloud.version>2024.0.0</spring-cloud.version>
|
||||||
|
<mybatis-plus.version>3.5.7</mybatis-plus.version>
|
||||||
|
<redisson.version>3.29.0</redisson.version>
|
||||||
|
<mysql.version>8.0.33</mysql.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<!-- Spring Cloud BOM -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- springboot3配套的MybatisPlus-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
|
<version>${mybatis-plus.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Redisson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
|
<version>${redisson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MySQL Driver -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>${mysql.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Lombok (全局管理) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- fastjson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.83</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- hutool -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>5.8.24</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringSecurity -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
|
https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.luojia</groupId>
|
||||||
|
<artifactId>luojia_channel</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>service</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- 公共模块依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.luojia</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MyBatis-Plus -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Redis -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- RabbitMQ -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MySQL驱动 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 分布式系统支持 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 测试依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.luojia_channel;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class LuojiaChannelApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(LuojiaChannelApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.luojia_channel.modules.user.constant;
|
||||||
|
|
||||||
|
public class UserConstant {
|
||||||
|
// 匿名用户前缀
|
||||||
|
public static final String ANONYMOUS_USER_PREFIX = "luojia_";
|
||||||
|
// 匿名用户key前缀
|
||||||
|
public static final String ANONYMOUS_KEY_PREFIX = "anon:user:";
|
||||||
|
// 过期时间
|
||||||
|
public static final long EXPIRE_TIME_MINUTES = 30L;
|
||||||
|
// 过期时间
|
||||||
|
public static final long EXPIRE_TIME = 15L;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.luojia_channel.modules.user.controller;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/user/info")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UserInfoController {
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.luojia_channel.modules.user.controller;
|
||||||
|
|
||||||
|
import com.luojia_channel.common.domain.Result;
|
||||||
|
import com.luojia_channel.common.domain.UserDTO;
|
||||||
|
import com.luojia_channel.modules.user.dto.UserLoginDTO;
|
||||||
|
import com.luojia_channel.modules.user.dto.UserRegisterDTO;
|
||||||
|
import com.luojia_channel.modules.user.service.UserLoginService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/user")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UserLoginController {
|
||||||
|
private final UserLoginService userLoginService;
|
||||||
|
@PostMapping("/login")
|
||||||
|
public Result<UserDTO> login(@RequestBody UserLoginDTO userLoginDTO){
|
||||||
|
return Result.success(userLoginService.login(userLoginDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/register")
|
||||||
|
public Result<UserDTO> register(@RequestBody UserRegisterDTO userRegisterDTO){
|
||||||
|
return Result.success(userLoginService.register(userRegisterDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/logout")
|
||||||
|
public Result logout(@RequestParam String accessToken){
|
||||||
|
userLoginService.logout(accessToken);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/hello")
|
||||||
|
public Result<String> hello(){
|
||||||
|
return Result.success("hello");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.luojia_channel.modules.user.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserLoginDTO {
|
||||||
|
// 用户标志,支持学号,手机号,邮箱
|
||||||
|
private String userFlag;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.luojia_channel.modules.user.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserRegisterDTO {
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
private String studentId;
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.luojia_channel.modules.user.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.luojia_channel.modules.user.entity.User;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UserMapper extends BaseMapper<User> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.luojia_channel.modules.user.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.luojia_channel.modules.user.entity.User;
|
||||||
|
|
||||||
|
public interface UserInfoService extends IService<User> {
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.luojia_channel.modules.user.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.luojia_channel.common.domain.UserDTO;
|
||||||
|
import com.luojia_channel.modules.user.dto.UserLoginDTO;
|
||||||
|
import com.luojia_channel.modules.user.dto.UserRegisterDTO;
|
||||||
|
import com.luojia_channel.modules.user.entity.User;
|
||||||
|
|
||||||
|
public interface UserLoginService extends IService<User> {
|
||||||
|
|
||||||
|
UserDTO login(UserLoginDTO userLoginDTO);
|
||||||
|
|
||||||
|
UserDTO checkLogin(String accessToken, String refreshToken);
|
||||||
|
|
||||||
|
void logout(String accessToken);
|
||||||
|
|
||||||
|
UserDTO register(UserRegisterDTO userRegisterDTO);
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.luojia_channel.modules.user.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.luojia_channel.modules.user.entity.User;
|
||||||
|
import com.luojia_channel.modules.user.mapper.UserMapper;
|
||||||
|
import com.luojia_channel.modules.user.service.UserInfoService;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserInfoServiceImpl extends ServiceImpl<UserMapper, User> implements UserInfoService {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
lj:
|
@ -0,0 +1,14 @@
|
|||||||
|
# 本地开发环境
|
||||||
|
lj:
|
||||||
|
db:
|
||||||
|
host: 192.168.59.129
|
||||||
|
password: Forely123!
|
||||||
|
redis:
|
||||||
|
host: 192.168.59.129
|
||||||
|
port: 6379
|
||||||
|
password: Forely123!
|
||||||
|
rabbitmq:
|
||||||
|
host: 192.168.59.129
|
||||||
|
port: 5672
|
||||||
|
username: admin
|
||||||
|
password: Forely123!
|
@ -0,0 +1,51 @@
|
|||||||
|
server:
|
||||||
|
port: 8081
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: service
|
||||||
|
profiles:
|
||||||
|
active: local
|
||||||
|
# 数据库
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://${lj.db.host}:3306/luojia_channel?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
username: root
|
||||||
|
password: ${lj.db.password}
|
||||||
|
# redis配置
|
||||||
|
data:
|
||||||
|
redis:
|
||||||
|
host: ${lj.redis.host}
|
||||||
|
port: ${lj.redis.port}
|
||||||
|
password: ${lj.redis.password}
|
||||||
|
lettuce:
|
||||||
|
pool:
|
||||||
|
max-active: 10
|
||||||
|
max-idle: 10
|
||||||
|
min-idle: 1
|
||||||
|
time-between-eviction-runs: 10s
|
||||||
|
# rabbitmq配置
|
||||||
|
rabbitmq:
|
||||||
|
host: ${lj.rabbitmq.host}
|
||||||
|
port: ${lj.rabbitmq.port}
|
||||||
|
username: ${lj.rabbitmq.username}
|
||||||
|
password: ${lj.rabbitmq.password}
|
||||||
|
virtual-host: /
|
||||||
|
listener:
|
||||||
|
simple:
|
||||||
|
acknowledge-mode: manual
|
||||||
|
concurrency: 5
|
||||||
|
max-concurrency: 10
|
||||||
|
prefetch: 1
|
||||||
|
|
||||||
|
mybatis-plus:
|
||||||
|
configuration:
|
||||||
|
default-enum-type-handler: com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler
|
||||||
|
global-config:
|
||||||
|
db-config:
|
||||||
|
update-strategy: not_null
|
||||||
|
id-type: auto
|
||||||
|
mapper-locations: classpath*:mapper/**/*.xml
|
||||||
|
type-aliases-package: com.luojia.luojia_channel.modules.*.entity
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.luojia_channel.modules.user.mapper.UserMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.luojia.luojia_channel;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class LuojiaChannelApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
lj:
|
@ -0,0 +1,14 @@
|
|||||||
|
# 本地开发环境
|
||||||
|
lj:
|
||||||
|
db:
|
||||||
|
host: 192.168.59.129
|
||||||
|
password: Forely123!
|
||||||
|
redis:
|
||||||
|
host: 192.168.59.129
|
||||||
|
port: 6379
|
||||||
|
password: Forely123!
|
||||||
|
rabbitmq:
|
||||||
|
host: 192.168.59.129
|
||||||
|
port: 5672
|
||||||
|
username: admin
|
||||||
|
password: Forely123!
|
@ -0,0 +1,51 @@
|
|||||||
|
server:
|
||||||
|
port: 8081
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: service
|
||||||
|
profiles:
|
||||||
|
active: local
|
||||||
|
# 数据库
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://${lj.db.host}:3306/luojia_channel?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
username: root
|
||||||
|
password: ${lj.db.password}
|
||||||
|
# redis配置
|
||||||
|
data:
|
||||||
|
redis:
|
||||||
|
host: ${lj.redis.host}
|
||||||
|
port: ${lj.redis.port}
|
||||||
|
password: ${lj.redis.password}
|
||||||
|
lettuce:
|
||||||
|
pool:
|
||||||
|
max-active: 10
|
||||||
|
max-idle: 10
|
||||||
|
min-idle: 1
|
||||||
|
time-between-eviction-runs: 10s
|
||||||
|
# rabbitmq配置
|
||||||
|
rabbitmq:
|
||||||
|
host: ${lj.rabbitmq.host}
|
||||||
|
port: ${lj.rabbitmq.port}
|
||||||
|
username: ${lj.rabbitmq.username}
|
||||||
|
password: ${lj.rabbitmq.password}
|
||||||
|
virtual-host: /
|
||||||
|
listener:
|
||||||
|
simple:
|
||||||
|
acknowledge-mode: manual
|
||||||
|
concurrency: 5
|
||||||
|
max-concurrency: 10
|
||||||
|
prefetch: 1
|
||||||
|
|
||||||
|
mybatis-plus:
|
||||||
|
configuration:
|
||||||
|
default-enum-type-handler: com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler
|
||||||
|
global-config:
|
||||||
|
db-config:
|
||||||
|
update-strategy: not_null
|
||||||
|
id-type: auto
|
||||||
|
mapper-locations: classpath*:mapper/**/*.xml
|
||||||
|
type-aliases-package: com.luojia.luojia_channel.modules.*.entity
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.luojia_channel.modules.user.mapper.UserMapper">
|
||||||
|
|
||||||
|
</mapper>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue