初始化

master
Sheyu-yao 2024-01-12 14:23:01 +08:00
commit 5ad9419e4e
47 changed files with 1803 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="UTF-8">
<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$/ysy-auth/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ysy-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ysy-gateway/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ysy-modules/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ysy-modules/ysy-apply/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ysy-modules/ysy-system/src/main/java" charset="UTF-8" />
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

14
.idea/misc.xml 100644
View File

@ -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_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View 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>

184
.idea/workspace.xml 100644
View File

@ -0,0 +1,184 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="88964528-da9b-4dce-b2e1-90e4281b93bb" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
<option value="Interface" />
</list>
</option>
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="mavenHome" value="D:/Maven/apache-maven-3.9.4-bin/apache-maven-3.9.4" />
<option name="userSettingsFile" value="D:\Maven\apache-maven-3.9.4-bin\apache-maven-3.9.4\conf\settings.xml" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 6
}]]></component>
<component name="ProjectId" id="2apjXkTQBGD1Lya9b7KwYJoFZ8H" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RequestMappingsPanelOrder0": "0",
"RequestMappingsPanelOrder1": "1",
"RequestMappingsPanelWidth0": "75",
"RequestMappingsPanelWidth1": "75",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"jdk.selected.JAVA_MODULE": "17",
"last_opened_file_path": "C:/Users/Hasee/Desktop/senior_grade5_week01/ysy-modules/ysy-apply/src/main/resources",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"project.structure.last.edited": "Modules",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.0",
"settings.editor.selected.configurable": "editor.preferences.tabs",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="ReactorSettings">
<option name="notificationShown" value="true" />
</component>
<component name="RecentsManager">
<key name="CreateClassDialog.RecentsKey">
<recent name="com.ysy.mapper" />
<recent name="com.ysy.service" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\Hasee\Desktop\senior_grade5_week01\ysy-modules\ysy-apply\src\main\resources" />
<recent name="C:\Users\Hasee\Desktop\senior_grade5_week01\ysy-gateway\src\main\java\com\ysy\config" />
<recent name="C:\Users\Hasee\Desktop\senior_grade5_week01\ysy-gateway\src\main\resources" />
<recent name="C:\Users\Hasee\Desktop\senior_grade5_week01\ysy-auth\src\main\resources" />
<recent name="C:\Users\Hasee\Desktop\senior_grade5_week01\ysy-modules\ysy-system\src\main\resources" />
</key>
</component>
<component name="RunDashboard">
<option name="configurationTypes">
<set>
<option value="SpringBootApplicationConfigurationType" />
</set>
</option>
</component>
<component name="RunManager" selected="Spring Boot.ApplyServiceApplication">
<configuration name="SystemServiceApplication" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.ysy.SystemServiceApplication" />
<module name="ysy-system" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.ysy.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="ApplyServiceApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
<module name="ysy-apply" />
<option name="SPRING_BOOT_MAIN_CLASS" value="com.ysy.ApplyServiceApplication" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.ysy.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="AuthServiceApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
<module name="ysy-auth" />
<option name="SPRING_BOOT_MAIN_CLASS" value="com.ysy.AuthServiceApplication" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.ysy.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="GatewayApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
<module name="ysy-gateway" />
<option name="SPRING_BOOT_MAIN_CLASS" value="com.ysy.GatewayApplication" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.ysy.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="SystemServiceApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
<module name="ysy-system" />
<option name="SPRING_BOOT_MAIN_CLASS" value="com.ysy.SystemServiceApplication" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.ysy.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Spring Boot.SystemServiceApplication" />
<item itemvalue="Spring Boot.GatewayApplication" />
<item itemvalue="Spring Boot.AuthServiceApplication" />
<item itemvalue="Spring Boot.ApplyServiceApplication" />
<item itemvalue="Application.SystemServiceApplication" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="88964528-da9b-4dce-b2e1-90e4281b93bb" name="Changes" comment="" />
<created>1705022459502</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1705022459502</updated>
<workItem from="1705022460543" duration="16480000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/ysy-auth/src/main/java/com/ysy/service/impl/AuthServiceImpl.java</url>
<line>30</line>
<option name="timeStamp" value="6" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

58
pom.xml 100644
View File

@ -0,0 +1,58 @@
<?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>com.ysy</groupId>
<artifactId>senior_grade5_week01</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>ysy-modules</module>
<module>ysy-modules/ysy-system</module>
<module>ysy-modules/ysy-apply</module>
<module>ysy-auth</module>
<module>ysy-gateway</module>
<module>ysy-common</module>
</modules>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<relativePath/>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2022.0.0.0-RC2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2022.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.ysy</groupId>
<artifactId>ysy-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

41
ysy-auth/pom.xml 100644
View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ysy</groupId>
<artifactId>senior_grade5_week01</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>ysy-auth</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 自定义公共模块 -->
<dependency>
<groupId>com.ysy</groupId>
<artifactId>ysy-common</artifactId>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,16 @@
package com.ysy;
import com.ysy.exception.GlobalExceptionHandler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Import;
@SpringBootApplication
@EnableFeignClients(basePackages = "com.ysy.remote")
@Import({GlobalExceptionHandler.class})
public class AuthServiceApplication {
public static void main(String[] args) {
SpringApplication.run(AuthServiceApplication.class, args);
}
}

View File

@ -0,0 +1,25 @@
package com.ysy.controller;
import com.ysy.domain.result.R;
import com.ysy.domain.vo.RiderVO;
import com.ysy.service.AuthService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/auth")
public class AuthController {
private final AuthService authService;
public AuthController(AuthService authService) {
this.authService = authService;
}
@PostMapping("/login")
public R authLogin(@RequestBody @Validated RiderVO riderVO) {
return authService.authLoginByRiderVO(riderVO);
}
}

View File

@ -0,0 +1,8 @@
package com.ysy.service;
import com.ysy.domain.result.R;
import com.ysy.domain.vo.RiderVO;
public interface AuthService {
R authLoginByRiderVO(RiderVO riderVO);
}

View File

@ -0,0 +1,52 @@
package com.ysy.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson2.JSON;
import com.ysy.domain.po.Rider;
import com.ysy.domain.result.R;
import com.ysy.domain.vo.RiderVO;
import com.ysy.remote.SystemClientRemote;
import com.ysy.service.AuthService;
import com.ysy.utils.jwt.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Service
public class AuthServiceImpl implements AuthService {
@Autowired
private SystemClientRemote systemClientRemote;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Override
public R authLoginByRiderVO(RiderVO riderVO) {
//服务远程调用
R result = systemClientRemote.riderByRiderName(riderVO.getRiderName());
//不存在用户
Assert.notNull(result.getData(), "不存在该用户");
Rider rider = JSON.parseObject(JSON.toJSONString(result.getData().get("rider")), Rider.class);
//密码错误
Assert.isTrue(rider.getPassword().equals(riderVO.getPassword()), "密码错误");
//生成token
Map<String, Object> tokenMap = BeanUtil.beanToMap(rider, new HashMap<>(), false, false);
String token = JwtUtil.getToken("rider", tokenMap);
//登录成功存入缓存
stringRedisTemplate.opsForValue().set(token,
JSON.toJSONString(rider),
30, TimeUnit.MINUTES);
return R.ok("登录成功","token", token);
}
}

View File

@ -0,0 +1,9 @@
██ ██ ████████ ██ ██
░░██ ██ ██░░░░░░ ░░██ ██
░░████ ░██ ░░████
░░██ ░█████████ ░░██
░██ ░░░░░░░░██ ░██
░██ ░██ ░██
░██ ████████ ░██
░░ ░░░░░░░░ ░░
:: ysy boot :: version 1.0

View File

@ -0,0 +1,42 @@
server:
#服务端口
port: 10002
spring:
application:
#服务名称
name: authService
profiles:
#配置文件生效环境
active: dev
cloud:
nacos:
#nacos服务器地址
server-addr: http://124.70.132.13:8848
#nacos服务发现配置
discovery:
#nacos服务注册命名空间ID默认为public
namespace: 2e6a4975-46b3-4035-b77d-92b05ae48a66
#cluster-name: SH #服务集群设置
config:
#指定读取命名空间配置默认为public
namespace: ${spring.cloud.nacos.discovery.namespace}
#nacos配置文件类型
file-extension: yaml
#共享配置
shared-configs:
- data-id: common.yaml
group: SPRING_CLOUD_COMMONS
refresh: true
- data-id: common-mysql.yaml
group: SPRING_CLOUD_COMMONS
refresh: true
- data-id: common-redis.yaml
group: SPRING_CLOUD_COMMONS
refresh: true

176
ysy-common/pom.xml 100644
View File

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ysy</groupId>
<artifactId>senior_grade5_week01</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>ysy-common</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- nacos服务发现依赖 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- loadbalancer负载均衡 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<!-- nacos配置文件 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- bootstrap优先启动文件 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<!-- feign客户端 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- feign的httpclient客户端 -->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
<!-- amqp -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!-- kafka -->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<!-- elasticsearch -->
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>8.11.1</version>
</dependency>
<!-- jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.3</version>
</dependency>
<!-- jwt令牌校验 -->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>4.4.0</version>
</dependency>
<!-- mysql -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<!-- mybatisPlus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.4.1</version>
</dependency>
<!-- druid连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.20</version>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- redis连接池 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<!-- fastjson -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.42</version>
</dependency>
<!-- Apache Lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- hutool工具包 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.20</version>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,30 @@
package com.ysy.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author DongZl
* @description: Mybatis-Plus
* @Date 2024-1-10 05:12
*/
@Configuration
public class MybatisPlusConfig {
public MybatisPlusConfig () {
System.out.println("初始化-----------");
}
/**
*
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
}

View File

@ -0,0 +1,49 @@
package com.ysy.domain.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("tb_apply")
public class Apply {
@TableId(value = "apply_id", type = IdType.AUTO)
private Long applyId;
@TableField("username")
private String username;
@TableField("phone")
private String phone;
@TableField("take_kilo")
private Integer takeKilo;
@TableField("take_price")
private Integer takePrice;
@TableField("order_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date orderTime;
@TableField("assume_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date assumeTime;
@TableField("state")
private Boolean state;
@TableField("rider_id")
private Long riderId;
}

View File

@ -0,0 +1,29 @@
package com.ysy.domain.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("tb_record")
public class Record {
@TableId(value = "rid", type = IdType.AUTO)
private Long rid;
@TableField("apply_id")
private Long applyId;
@TableField("rider_id")
private Long riderId;
@TableField("is_finished")
private Boolean isFinished;
}

View File

@ -0,0 +1,34 @@
package com.ysy.domain.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("tb_rider")
public class Rider {
@TableId("rider_id")
private Long riderId;
@TableField("rider_name")
private String riderName;
@TableField("password")
private String password;
@TableField("kilometer")
private Integer kilometer;
@TableField("left_money")
private Integer leftMoney;
@TableField("state")
private Boolean state;
}

View File

@ -0,0 +1,49 @@
package com.ysy.domain.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.HashMap;
import java.util.Map;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {
private Integer code;
private String msg;
private Map<String, Object> data;
public R(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public R(Integer code, String msg, String key, Object value) {
this.code = code;
this.msg = msg;
this.data = new HashMap<>();
this.data.put(key, value);
}
public static R ok(String msg) {
return new R(200, msg);
}
public static R ok(Map<String, Object> data) {
return new R(200, "ok", data);
}
public static R ok(String key, Object value) {
return new R(200, "ok", key, value);
}
public static R ok(String msg, String key, Object value) {
return new R(200, msg, key, value);
}
public static R fail(String msg) {
return new R(300, msg);
}
}

View File

@ -0,0 +1,19 @@
package com.ysy.domain.vo;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RiderVO {
@NotBlank(message = "用户名不能为空")
private String riderName;
@NotBlank(message = "密码不能为空")
private String password;
}

View File

@ -0,0 +1,20 @@
package com.ysy.exception;
import com.ysy.domain.result.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.Arrays;
@RestControllerAdvice
@Configuration
@Slf4j
public class GlobalExceptionHandler {
@ExceptionHandler(IllegalArgumentException.class)
public R illegalArgumentExceptionHandler(IllegalArgumentException e) {
log.error("服务端报错:[{}]", e.getMessage(), e.getLocalizedMessage(), e);
return R.fail(e.getMessage());
}
}

View File

@ -0,0 +1,14 @@
package com.ysy.remote;
import com.ysy.domain.result.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FeignClient(value = "systemService", path = "/system")
public interface SystemClientRemote {
@GetMapping("/rider/{riderName}")
public R riderByRiderName(@PathVariable String riderName);
}

View File

@ -0,0 +1,75 @@
package com.ysy.utils.gateway;
import com.alibaba.fastjson2.JSON;
import com.ysy.domain.result.R;
import com.ysy.utils.tools.StringUtils;
import lombok.extern.log4j.Log4j2;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
/**
* @author DongZl
* @description:
*/
@Log4j2
public class GatewayUtils {
/**
*
* @param mutate
* @param key
* @param value
*/
public static void addHeader(ServerHttpRequest.Builder mutate, String key, Object value) {
if (StringUtils.isEmpty(key)){
log.warn("添加请求头参数键不可以为空");
return;
}
if (value == null) {
log.warn("添加请求头参数:[{}]值为空",key);
return;
}
String valueStr = value.toString();
mutate.header(key, valueStr);
log.info("添加请求头参数成功 - 键:[{}] , 值:[{}]", key , value);
}
/**
*
* @param mutate
* @param key
*/
public static void removeHeader(ServerHttpRequest.Builder mutate, String key) {
if (StringUtils.isEmpty(key)){
log.warn("删除请求头参数键不可以为空");
return;
}
mutate.headers(httpHeaders -> httpHeaders.remove(key)).build();
log.info("删除请求头参数 - 键:[{}]",key);
}
/**
*
* @param exchange
* @param msg
* @return
*/
public static Mono<Void> errorResponse(ServerWebExchange exchange, String msg) {
ServerHttpResponse response = exchange.getResponse();
//设置HTTP响应头状态
response.setStatusCode(HttpStatus.OK);
//设置HTTP响应头文本格式
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json");
//定义响应内容
R result = R.fail(msg);
String resultJson = JSON.toJSONString(result);
log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson);
DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes());
//进行响应
return response.writeWith(Mono.just(dataBuffer));
}
}

View File

@ -0,0 +1,35 @@
package com.ysy.utils.jwt;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import java.util.Date;
import java.util.Map;
public class JwtUtil {
private final static String SECRET = "qwertyuiopasdfghjkl";
public static String getToken(String name, Map<String, Object> claim) {
String token = JWT.create()
.withClaim(name, claim)
// .withExpiresAt(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24))
.sign(Algorithm.HMAC256(SECRET));
return token;
}
public static DecodedJWT decodedJWT(String token) {
JWTVerifier build = JWT.require(Algorithm.HMAC256(SECRET))
.build();
DecodedJWT decodedJWT = build.verify(token);
return decodedJWT;
}
public static Claim getClaim(String token, String name) {
DecodedJWT decodedJWT = decodedJWT(token);
Map<String, Claim> claims = decodedJWT.getClaims();
return claims.get(name);
}
}

View File

@ -0,0 +1,68 @@
package com.ysy.utils.tools;
import org.springframework.util.AntPathMatcher;
import java.util.Collection;
import java.util.List;
/**
* @author DongZl
* @description:
*/
public class StringUtils extends org.apache.commons.lang3.StringUtils {
/**
* *
*
* @param object Object
* @return true false
*/
public static boolean isNull(Object object) {
return object == null;
}
/**
* * Collection ListSetQueue
*
* @param coll Collection
* @return true false
*/
public static boolean isEmpty(Collection<?> coll) {
return isNull(coll) || coll.isEmpty();
}
/**
*
*
* @param str
* @param strs
* @return
*/
public static boolean matches(String str, List<String> strs) {
if (isEmpty(str) || isEmpty(strs)) {
return false;
}
for (String pattern : strs) {
if (isMatch(pattern, str))
{
return true;
}
}
return false;
}
/**
* url:
* ? ;
* * ;
* ** ;
*
* @param pattern
* @param url url
* @return
*/
public static boolean isMatch(String pattern, String url) {
AntPathMatcher matcher = new AntPathMatcher();
return matcher.match(pattern, url);
}
}

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ysy</groupId>
<artifactId>senior_grade5_week01</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>ysy-gateway</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.ysy</groupId>
<artifactId>ysy-common</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 网关依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,13 @@
package com.ysy;
import com.ysy.exception.GlobalExceptionHandler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
@SpringBootApplication
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}

View File

@ -0,0 +1,17 @@
package com.ysy.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import java.util.List;
@Data
@ConfigurationProperties(prefix = "auth")
@Component
@RefreshScope
public class AuthProperties {
private List<String> excludePaths;
private List<String> includePaths;
}

View File

@ -0,0 +1,59 @@
package com.ysy.filter;
import com.ysy.config.AuthProperties;
import com.ysy.utils.gateway.GatewayUtils;
import com.ysy.utils.jwt.JwtUtil;
import com.ysy.utils.tools.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
@Component
@Order(1)
@Slf4j
public class GlobalAuthFilter implements GlobalFilter {
@Autowired
private AuthProperties authProperties;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
//获取访问路径
String path = exchange.getRequest().getPath().toString();
log.info("访问服务路径:" + path);
//匹配白名单
boolean matches = StringUtils.matches(path, authProperties.getExcludePaths());
//放行
if (matches) {
return chain.filter(exchange);
}
//获取token
String token = exchange.getRequest().getHeaders().get("token").get(0);
if (token == null)
GatewayUtils.errorResponse(exchange, "请先登录");
//jwt解析出错
try {
JwtUtil.decodedJWT(token);
} catch (Exception e) {
GatewayUtils.errorResponse(exchange, "身份不合法");
}
//缓存时间失效
if (Boolean.FALSE.equals(stringRedisTemplate.hasKey(token)))
GatewayUtils.errorResponse(exchange, "会话已过期,请重新登录");
return chain.filter(exchange);
}
}

View File

@ -0,0 +1,9 @@
██ ██ ████████ ██ ██
░░██ ██ ██░░░░░░ ░░██ ██
░░████ ░██ ░░████
░░██ ░█████████ ░░██
░██ ░░░░░░░░██ ░██
░██ ░██ ░██
░██ ████████ ░██
░░ ░░░░░░░░ ░░
:: ysy boot :: version 1.0

View File

@ -0,0 +1,59 @@
server:
port: 10010
spring:
application:
#服务名称
name: gateway
profiles:
#配置文件生效环境
active: dev
cloud:
nacos:
#nacos服务器地址
server-addr: http://124.70.132.13:8848
#nacos服务发现配置
discovery:
#nacos服务注册命名空间ID默认为public
namespace: 2e6a4975-46b3-4035-b77d-92b05ae48a66
#nacos配置文件配置
config:
#指定读取命名空间配置默认为public
namespace: ${spring.cloud.nacos.discovery.namespace}
#nacos配置文件类型
file-extension: yaml
#共享配置
shared-configs:
- data-id: common-redis.yaml
group: SPRING_CLOUD_COMMONS
refresh: true
- data-id: common-mysql.yaml
group: SPRING_CLOUD_COMMONS
refresh: true
loadbalancer:
nacos:
#开启nacos权重生效
enabled: true
#网关配置
gateway:
#路由配置
routes:
#路由标识,全局唯一
- id: auth-service
#路由目标地址lb代表负载均衡+服务名称
uri: lb://authService
#路由路径匹配规则
predicates:
- Path=/auth/**
- id: system-service
uri: lb://systemService
predicates:
- Path=/system/**
- id: apply-service
uri: lb://applyService
predicates:
- Path=/apply/**

View 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>com.ysy</groupId>
<artifactId>senior_grade5_week01</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>ysy-modules</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View 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>com.ysy</groupId>
<artifactId>senior_grade5_week01</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>ysy-apply</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 自定义公共模块 -->
<dependency>
<groupId>com.ysy</groupId>
<artifactId>ysy-common</artifactId>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,15 @@
package com.ysy;
import com.ysy.config.MybatisPlusConfig;
import com.ysy.exception.GlobalExceptionHandler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
@SpringBootApplication
@Import({GlobalExceptionHandler.class, MybatisPlusConfig.class})
public class ApplyServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ApplyServiceApplication.class, args);
}
}

View File

@ -0,0 +1,21 @@
package com.ysy.controller;
import com.ysy.domain.result.R;
import com.ysy.service.ApplyService;
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;
@RestController
@RequestMapping("/apply")
public class ApplyController {
@Autowired
private ApplyService applyService;
@GetMapping("/list/{pageNum}")
public R applyList(@PathVariable Integer pageNum) {
return applyService.getApplyList(pageNum);
}
}

View File

@ -0,0 +1,9 @@
package com.ysy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ysy.domain.po.Apply;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ApplyMapper extends BaseMapper<Apply> {
}

View File

@ -0,0 +1,9 @@
package com.ysy.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ysy.domain.po.Apply;
import com.ysy.domain.result.R;
public interface ApplyService extends IService<Apply> {
R getApplyList(Integer pageNum);
}

View File

@ -0,0 +1,53 @@
package com.ysy.service.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysy.domain.po.Apply;
import com.ysy.domain.po.Rider;
import com.ysy.domain.result.R;
import com.ysy.mapper.ApplyMapper;
import com.ysy.service.ApplyService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.function.Consumer;
@Service
public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements ApplyService {
@Autowired
private ApplyMapper applyMapper;
@Autowired
private HttpServletRequest request;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Override
public R getApplyList(Integer pageNum) {
String token = request.getHeader("token");
String jsonString = stringRedisTemplate.opsForValue().get(token);
Rider rider = JSON.parseObject(jsonString, Rider.class);
// IPage<Apply> iPage = new Page<>(pageNum, 3);
QueryWrapper<Apply> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("rider_id", 0)
.or(a ->
a.eq("rider_id", rider.getRiderId())
.eq("state", 0))
.orderByDesc("order_time");
List<Apply> applyList = applyMapper.selectList(queryWrapper);
// IPage<Apply> iPage1 = iPage.setRecords(applyList);
return R.ok("applyList", applyList);
}
}

View File

@ -0,0 +1,9 @@
██ ██ ████████ ██ ██
░░██ ██ ██░░░░░░ ░░██ ██
░░████ ░██ ░░████
░░██ ░█████████ ░░██
░██ ░░░░░░░░██ ░██
░██ ░██ ░██
░██ ████████ ░██
░░ ░░░░░░░░ ░░
:: ysy boot :: version 1.0

View File

@ -0,0 +1,42 @@
server:
#服务端口
port: 10003
spring:
application:
#服务名称
name: applyService
profiles:
#配置文件生效环境
active: dev
cloud:
nacos:
#nacos服务器地址
server-addr: http://124.70.132.13:8848
#nacos服务发现配置
discovery:
#nacos服务注册命名空间ID默认为public
namespace: 2e6a4975-46b3-4035-b77d-92b05ae48a66
#cluster-name: SH #服务集群设置
config:
#指定读取命名空间配置默认为public
namespace: ${spring.cloud.nacos.discovery.namespace}
#nacos配置文件类型
file-extension: yaml
#共享配置
shared-configs:
- data-id: common.yaml
group: SPRING_CLOUD_COMMONS
refresh: true
- data-id: common-mysql.yaml
group: SPRING_CLOUD_COMMONS
refresh: true
- data-id: common-redis.yaml
group: SPRING_CLOUD_COMMONS
refresh: true

View 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>com.ysy</groupId>
<artifactId>senior_grade5_week01</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>ysy-system</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 自定义公共模块 -->
<dependency>
<groupId>com.ysy</groupId>
<artifactId>ysy-common</artifactId>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,15 @@
package com.ysy;
import com.ysy.config.MybatisPlusConfig;
import com.ysy.exception.GlobalExceptionHandler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
@SpringBootApplication
@Import({GlobalExceptionHandler.class, MybatisPlusConfig.class})
public class SystemServiceApplication {
public static void main(String[] args) {
SpringApplication.run(SystemServiceApplication.class, args);
}
}

View File

@ -0,0 +1,26 @@
package com.ysy.controller;
import com.ysy.domain.result.R;
import com.ysy.service.RiderService;
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;
@RestController
@RequestMapping("/system")
public class SystemController {
@Autowired
private RiderService riderService;
@GetMapping("/rider/{riderName}")
public R riderByRiderName(@PathVariable String riderName) {
return riderService.getRiderByRiderName(riderName);
}
@GetMapping("/rider")
public R rider() {
return riderService.getRiderById();
}
}

View File

@ -0,0 +1,9 @@
package com.ysy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ysy.domain.po.Rider;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RiderMapper extends BaseMapper<Rider> {
}

View File

@ -0,0 +1,11 @@
package com.ysy.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ysy.domain.po.Rider;
import com.ysy.domain.result.R;
public interface RiderService extends IService<Rider> {
R getRiderByRiderName(String riderName);
R getRiderById();
}

View File

@ -0,0 +1,42 @@
package com.ysy.service.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysy.domain.po.Rider;
import com.ysy.domain.result.R;
import com.ysy.mapper.RiderMapper;
import com.ysy.service.RiderService;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
@Service
public class RiderServiceImpl extends ServiceImpl<RiderMapper, Rider> implements RiderService {
@Autowired
private HttpServletRequest request;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Override
public R getRiderByRiderName(String riderName) {
QueryWrapper<Rider> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StringUtils.isNotBlank(riderName), "rider_name", riderName);
Rider one = getOne(queryWrapper);
return R.ok("rider", one);
}
@Override
public R getRiderById() {
String token = request.getHeader("token");
String jsonString = stringRedisTemplate.opsForValue().get(token);
Rider rider = JSON.parseObject(jsonString, Rider.class);
return R.ok("rider", rider);
}
}

View File

@ -0,0 +1,9 @@
██ ██ ████████ ██ ██
░░██ ██ ██░░░░░░ ░░██ ██
░░████ ░██ ░░████
░░██ ░█████████ ░░██
░██ ░░░░░░░░██ ░██
░██ ░██ ░██
░██ ████████ ░██
░░ ░░░░░░░░ ░░
:: ysy boot :: version 1.0

View File

@ -0,0 +1,42 @@
server:
#服务端口
port: 10001
spring:
application:
#服务名称
name: systemService
profiles:
#配置文件生效环境
active: dev
cloud:
nacos:
#nacos服务器地址
server-addr: http://124.70.132.13:8848
#nacos服务发现配置
discovery:
#nacos服务注册命名空间ID默认为public
namespace: 2e6a4975-46b3-4035-b77d-92b05ae48a66
#cluster-name: SH #服务集群设置
config:
#指定读取命名空间配置默认为public
namespace: ${spring.cloud.nacos.discovery.namespace}
#nacos配置文件类型
file-extension: yaml
#共享配置
shared-configs:
- data-id: common.yaml
group: SPRING_CLOUD_COMMONS
refresh: true
- data-id: common-mysql.yaml
group: SPRING_CLOUD_COMMONS
refresh: true
- data-id: common-redis.yaml
group: SPRING_CLOUD_COMMONS
refresh: true