周考后台代码
commit
2a2500001d
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,8 @@
|
|||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
|
||||
<file url="file://$PROJECT_DIR$/bwie-auth/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-gateway/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-module/bwie-bicycle/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-module/bwie-record/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-module/bwie-system/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-module/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/bwie-module/src/main/resources" 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" />
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
<?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>
|
||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,27 @@
|
|||
<?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.bwie</groupId>
|
||||
<artifactId>weekone</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-auth</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- common -->
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
</dependency>
|
||||
<!-- web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,24 @@
|
|||
package com.bwie.auth;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
|
||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||
@EnableFeignClients
|
||||
public class AuthApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthApplication.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BCryptPasswordEncoder bCryptPasswordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.bwie.auth.controller;
|
||||
|
||||
import com.bwie.auth.service.AuthService;
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserRequest;
|
||||
import com.bwie.common.domain.response.TokenResponse;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/authUser")
|
||||
public class AuthController {
|
||||
|
||||
@Autowired
|
||||
private AuthService service;
|
||||
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public Result<TokenResponse> login(@RequestBody UserRequest request){
|
||||
TokenResponse login = service.login(request);
|
||||
return Result.success(login);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
public Result<User> info(){
|
||||
User info = service.info();
|
||||
return Result.success(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
@GetMapping("/logout")
|
||||
public Result<Void> logout(){
|
||||
service.logout();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.bwie.auth.remote;
|
||||
|
||||
import com.bwie.auth.remote.impl.Fusing;
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(name = "bwie-system",fallbackFactory = Fusing.class)
|
||||
public interface AuthRemote {
|
||||
/**
|
||||
* 根据手机号查询用户信息
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/user/findByPhone")
|
||||
public Result<User> findByPhone(@RequestParam String phone);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.bwie.auth.remote.impl;
|
||||
|
||||
import com.bwie.auth.remote.AuthRemote;
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 熔断处理类
|
||||
*/
|
||||
@Component
|
||||
public class Fusing implements FallbackFactory<AuthRemote> {
|
||||
@Override
|
||||
public AuthRemote create(Throwable cause) {
|
||||
return new AuthRemote() {
|
||||
@Override
|
||||
public Result<User> findByPhone(String phone) {
|
||||
throw new RuntimeException("远程调用失败");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.bwie.auth.service;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserRequest;
|
||||
import com.bwie.common.domain.response.TokenResponse;
|
||||
|
||||
public interface AuthService {
|
||||
//登录
|
||||
TokenResponse login(UserRequest request);
|
||||
//获取用户信息
|
||||
User info();
|
||||
//退出登录
|
||||
void logout();
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package com.bwie.auth.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.auth.remote.AuthRemote;
|
||||
import com.bwie.auth.service.AuthService;
|
||||
import com.bwie.common.constants.JwtConstants;
|
||||
import com.bwie.common.constants.TokenConstants;
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.UserRequest;
|
||||
import com.bwie.common.domain.response.TokenResponse;
|
||||
import com.bwie.common.utils.JwtUtils;
|
||||
import com.bwie.common.utils.StringUtils;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@Service
|
||||
public class AuthServiceImpl implements AuthService {
|
||||
|
||||
@Autowired
|
||||
private AuthRemote remote;
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Autowired
|
||||
private BCryptPasswordEncoder bCryptPasswordEncoder;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public TokenResponse login(UserRequest request) {
|
||||
if (StringUtils.isAnyBlank(request.getPhone(), request.getUserPwd())){
|
||||
throw new RuntimeException("手机号码和密码不能为空");
|
||||
}
|
||||
User user = remote.findByPhone(request.getPhone()).getData();
|
||||
if (user == null){
|
||||
throw new RuntimeException("请注册");
|
||||
}
|
||||
|
||||
// String encode = bCryptPasswordEncoder.encode("8023520");
|
||||
// System.out.println(encode);
|
||||
// String encode1 = bCryptPasswordEncoder.encode("1314520");
|
||||
// System.out.println(encode1);
|
||||
// String encode2 = bCryptPasswordEncoder.encode("997752");
|
||||
// System.out.println(encode2);
|
||||
|
||||
if (!bCryptPasswordEncoder.matches(request.getUserPwd(), user.getUserPwd())){
|
||||
throw new RuntimeException("密码错误");
|
||||
}
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
String userKey = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
map.put(JwtConstants.USER_KEY,userKey);
|
||||
String token = JwtUtils.createToken(map);
|
||||
redisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+userKey, JSONObject.toJSONString(user),30, TimeUnit.MINUTES);
|
||||
TokenResponse response = new TokenResponse();
|
||||
response.setToken(token);
|
||||
response.setExpireTime("30MINUTES");
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public User info() {
|
||||
String token = httpServletRequest.getHeader(TokenConstants.TOKEN);
|
||||
String userKey = JwtUtils.getUserKey(token);
|
||||
String user = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||
User user1 = JSONObject.parseObject(user, User.class);
|
||||
return user1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*/
|
||||
@Override
|
||||
public void logout() {
|
||||
String token = httpServletRequest.getHeader(TokenConstants.TOKEN);
|
||||
String userKey = JwtUtils.getUserKey(token);
|
||||
redisTemplate.delete(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9001
|
||||
# Spring
|
||||
spring:
|
||||
rabbitmq:
|
||||
host: 118.25.94.40
|
||||
port: 5672
|
||||
username: guest
|
||||
password: guest
|
||||
virtual-host: /
|
||||
listener:
|
||||
simple:
|
||||
retry:
|
||||
enabled: true
|
||||
prefetch: 1 #配置多劳多得 每次取出一条消息 消息完毕取下一条
|
||||
acknowledge-mode: manual #设置消费端手动ack确认
|
||||
publisher-confirm-type: correlated #确认消息已发送到交换机(exchange)或者broker
|
||||
publisher-returns: true #开启消息发送到队列的确认
|
||||
main:
|
||||
allow-circular-references: true #允许循环依赖
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-auth
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 118.25.94.40:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 118.25.94.40:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,122 @@
|
|||
<?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.bwie</groupId>
|
||||
<artifactId>weekone</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- bootstrap 启动器 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<!-- lombok依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<!-- 负载均衡-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Openfeign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<!-- JWT -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
</dependency>
|
||||
<!-- Alibaba Fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringBoot Boot Redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--Hibernate Validator-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-validation</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- Apache Lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
<!-- 阿里大鱼 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dysmsapi20170525</artifactId>
|
||||
</dependency>
|
||||
<!-- Druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<!-- Mybatis 依赖配置 -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- Pagehelper -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- rabbitmq -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.tobato</groupId>
|
||||
<artifactId>fastdfs-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- oss -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.16.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
package com.bwie.common.config;
|
||||
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class RabbitMQConfig {
|
||||
// 消息转换配置
|
||||
@Bean
|
||||
public MessageConverter jsonMessageConverter() {
|
||||
// SimpleMessageConverter 默认的消息转换器 String byte[] serializer
|
||||
return new Jackson2JsonMessageConverter();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.bwie.common.constants;
|
||||
|
||||
/**
|
||||
* @description: 系统常量
|
||||
*/
|
||||
public class Constants {
|
||||
/**
|
||||
* 成功标记
|
||||
*/
|
||||
public static final Integer SUCCESS = 200;
|
||||
public static final String SUCCESS_MSG = "操作成功";
|
||||
/**
|
||||
* 失败标记
|
||||
*/
|
||||
public static final Integer ERROR = 500;
|
||||
public static final String ERROR_MSG = "操作异常";
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.bwie.common.constants;
|
||||
|
||||
/**
|
||||
* @description: Jwt常量
|
||||
*/
|
||||
public class JwtConstants {
|
||||
|
||||
/**
|
||||
* 用户ID字段
|
||||
*/
|
||||
public static final String DETAILS_USER_ID = "user_id";
|
||||
|
||||
/**
|
||||
* 用户名字段
|
||||
*/
|
||||
public static final String DETAILS_USERNAME = "username";
|
||||
|
||||
/**
|
||||
* 用户标识
|
||||
*/
|
||||
public static final String USER_KEY = "user_key";
|
||||
|
||||
/**
|
||||
* 令牌秘钥
|
||||
*/
|
||||
public final static String SECRET = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.bwie.common.constants;
|
||||
|
||||
public class RabbitMQQueueNameConstants {
|
||||
|
||||
/**
|
||||
* 短信队列名称
|
||||
*/
|
||||
public static final String SEND_SMS_QUEUE = "SEND_SMS_QUEUE";
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.bwie.common.constants;
|
||||
|
||||
/**
|
||||
* @description: 令牌常量
|
||||
*/
|
||||
public class TokenConstants {
|
||||
/**
|
||||
* 缓存有效期,默认720(分钟)
|
||||
*/
|
||||
public final static long EXPIRATION = 720;
|
||||
/**
|
||||
* 缓存刷新时间,默认120(分钟)
|
||||
*/
|
||||
public final static long REFRESH_TIME = 120;
|
||||
/**
|
||||
* 权限缓存前缀
|
||||
*/
|
||||
public final static String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||
/**
|
||||
* token标识
|
||||
*/
|
||||
public static final String TOKEN = "token";
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 自行车
|
||||
*/
|
||||
@Data
|
||||
public class Bicycle {
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
private Integer bicycleId;
|
||||
/**
|
||||
* 车辆编号
|
||||
*/
|
||||
private String bicycleNumber;
|
||||
/**
|
||||
* 类型1.入门公路车2.入门山地车3.专业公路车4.专业山地车
|
||||
*/
|
||||
private Integer bicycleType;
|
||||
/**
|
||||
* 1.未出租2.已出租
|
||||
*/
|
||||
private Integer bicycleFlag;
|
||||
/**
|
||||
* 租车主名称
|
||||
*/
|
||||
private String bicycleName;
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
private BigDecimal balance;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 行车记录表
|
||||
*/
|
||||
@Data
|
||||
public class Record {
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
private Integer recordId;
|
||||
/**
|
||||
* 车辆编号
|
||||
*/
|
||||
private String recordNumber;
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private Integer recordType;
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String recordUserName;
|
||||
/**
|
||||
* 开始用车时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date recordStartTime;
|
||||
/**
|
||||
* 用车时长(分钟)
|
||||
*/
|
||||
private Integer recordDrivingTime;
|
||||
/**
|
||||
* 行驶距离(km)
|
||||
*/
|
||||
private Double recordTravelDistance;
|
||||
/**
|
||||
* 费用
|
||||
*/
|
||||
private BigDecimal recordPrice;
|
||||
/**
|
||||
* 状态1.骑行中2.已结束
|
||||
*/
|
||||
private Integer recordFlag;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.bwie.common.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户表
|
||||
*/
|
||||
@Data
|
||||
public class User {
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String userPwd;
|
||||
/**
|
||||
* 用户手机号
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
* 用户角色1.管理员2.普通用户
|
||||
*/
|
||||
private Integer userRole;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bwie.common.domain.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 自行车请求参数
|
||||
*/
|
||||
@Data
|
||||
public class BicycleRequest {
|
||||
/**
|
||||
* 类型1.入门公路车2.入门山地车3.专业公路车4.专业山地车
|
||||
*/
|
||||
private Integer bicycleType;
|
||||
/**
|
||||
* 1.未出租2.已出租
|
||||
*/
|
||||
private Integer bicycleFlag;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bwie.common.domain.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户请求
|
||||
*/
|
||||
@Data
|
||||
public class UserRequest {
|
||||
/**
|
||||
* 用户手机号
|
||||
*/
|
||||
private String phone;
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String userPwd;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bwie.common.domain.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 返回用户数据
|
||||
*/
|
||||
@Data
|
||||
public class TokenResponse {
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private String expireTime;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.bwie.common.exception;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* TODO 自定义异常
|
||||
*/
|
||||
@Data
|
||||
public class CustomException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 初始化构造方法
|
||||
* @param code 错误码
|
||||
* @param msg 错误提示消息
|
||||
*/
|
||||
public CustomException(int code, String msg) {
|
||||
super(msg);
|
||||
this.code = code;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.bwie.common.handle;
|
||||
|
||||
import com.bwie.common.exception.CustomException;
|
||||
import com.bwie.common.result.Result;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* TODO 全局异常处理器
|
||||
*/
|
||||
@Log4j2
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
/**
|
||||
* 自定义异常处理器
|
||||
*/
|
||||
@ExceptionHandler(CustomException.class)
|
||||
public Result customExceptionHandler(CustomException e) {
|
||||
log.error("功能异常,异常信息:{}", e.getMessage());
|
||||
return Result.error(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.bwie.common.result;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: 列表返回结果集
|
||||
*/
|
||||
@Data
|
||||
public class PageResult<T> implements Serializable {
|
||||
/**
|
||||
* 总条数
|
||||
*/
|
||||
private long total;
|
||||
/**
|
||||
* 结果集合
|
||||
*/
|
||||
private List<T> list;
|
||||
|
||||
public PageResult() {
|
||||
}
|
||||
|
||||
public PageResult(long total, List<T> list) {
|
||||
this.total = total;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public static <T> PageResult<T> toPageResult(long total, List<T> list) {
|
||||
return new PageResult(total, list);
|
||||
}
|
||||
|
||||
public static <T> Result<PageResult<T>> toResult(long total, List<T> list) {
|
||||
return Result.success(PageResult.toPageResult(total, list));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.bwie.common.result;
|
||||
|
||||
import com.bwie.common.constants.Constants;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description: 响应信息主体
|
||||
*/
|
||||
@Data
|
||||
public class Result<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
public static final int SUCCESS = Constants.SUCCESS;
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
public static final int FAIL = Constants.ERROR;
|
||||
/**
|
||||
* 返回状态码
|
||||
*/
|
||||
private int code;
|
||||
/**
|
||||
* 响应信息
|
||||
*/
|
||||
private String msg;
|
||||
/**
|
||||
* 响应数据
|
||||
*/
|
||||
private T data;
|
||||
|
||||
public static <T> Result<T> success() {
|
||||
return restResult(null, SUCCESS, Constants.SUCCESS_MSG);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(T data) {
|
||||
return restResult(data, SUCCESS, Constants.SUCCESS_MSG);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(T data, String msg) {
|
||||
return restResult(data, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error() {
|
||||
return restResult(null, FAIL, Constants.ERROR_MSG);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(String msg) {
|
||||
return restResult(null, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(T data) {
|
||||
return restResult(data, FAIL, Constants.ERROR_MSG);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(T data, String msg) {
|
||||
return restResult(data, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(int code, String msg) {
|
||||
return restResult(null, code, msg);
|
||||
}
|
||||
|
||||
private static <T> Result<T> restResult(T data, int code, String msg) {
|
||||
Result<T> apiResult = new Result<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(msg);
|
||||
return apiResult;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package com.bwie.common.utils;
|
||||
|
||||
import com.bwie.common.constants.JwtConstants;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description: Jwt工具类
|
||||
*/
|
||||
public class JwtUtils {
|
||||
|
||||
/**
|
||||
* 秘钥
|
||||
*/
|
||||
public static String secret = JwtConstants.SECRET;
|
||||
|
||||
/**
|
||||
* 从数据声明生成令牌
|
||||
*
|
||||
* @param claims 数据声明
|
||||
* @return 令牌
|
||||
*/
|
||||
public static String createToken(Map<String, Object> claims){
|
||||
String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact();
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从令牌中获取数据声明
|
||||
*
|
||||
* @param token 令牌
|
||||
* @return 数据声明
|
||||
*/
|
||||
public static Claims parseToken(String token){
|
||||
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
|
||||
}
|
||||
/**
|
||||
* 根据令牌获取用户标识
|
||||
*
|
||||
* @param token 令牌
|
||||
* @return 用户ID
|
||||
*/
|
||||
public static String getUserKey(String token){
|
||||
Claims claims = parseToken(token);
|
||||
return getValue(claims, JwtConstants.USER_KEY);
|
||||
}
|
||||
/**
|
||||
* 根据令牌获取用户标识
|
||||
*
|
||||
* @param claims 身份信息
|
||||
* @return 用户ID
|
||||
*/
|
||||
public static String getUserKey(Claims claims){
|
||||
return getValue(claims, JwtConstants.USER_KEY);
|
||||
}
|
||||
/**
|
||||
* 根据令牌获取用户ID
|
||||
*
|
||||
* @param token 令牌
|
||||
* @return 用户ID
|
||||
*/
|
||||
public static String getUserId(String token){
|
||||
Claims claims = parseToken(token);
|
||||
return getValue(claims, JwtConstants.DETAILS_USER_ID);
|
||||
}
|
||||
/**
|
||||
* 根据身份信息获取用户ID
|
||||
*
|
||||
* @param claims 身份信息
|
||||
* @return 用户ID
|
||||
*/
|
||||
public static String getUserId(Claims claims){
|
||||
return getValue(claims, JwtConstants.DETAILS_USER_ID);
|
||||
}
|
||||
/**
|
||||
* 根据令牌获取用户名
|
||||
*
|
||||
* @param token 令牌
|
||||
* @return 用户名
|
||||
*/
|
||||
public static String getUserName(String token){
|
||||
Claims claims = parseToken(token);
|
||||
return getValue(claims, JwtConstants.DETAILS_USERNAME);
|
||||
}
|
||||
/**
|
||||
* 根据身份信息获取用户名
|
||||
*
|
||||
* @param claims 身份信息
|
||||
* @return 用户名
|
||||
*/
|
||||
public static String getUserName(Claims claims){
|
||||
return getValue(claims, JwtConstants.DETAILS_USERNAME);
|
||||
}
|
||||
/**
|
||||
* 根据身份信息获取键值
|
||||
*
|
||||
* @param claims 身份信息
|
||||
* @param key 键
|
||||
* @return 值
|
||||
*/
|
||||
public static String getValue(Claims claims, String key){
|
||||
Object obj = claims.get(key);
|
||||
return obj == null ? "" : obj.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.bwie.common.utils;
|
||||
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @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是否为空, 包含List,Set,Queue
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.bwie.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.dysmsapi20170525.Client;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 短信工具类
|
||||
*/
|
||||
@Log4j2
|
||||
public class TelSmsUtils {
|
||||
|
||||
/**
|
||||
* 阿里云主账号AccessKey,accessKeySecret拥有所有API的访问权限
|
||||
*/
|
||||
private static String accessKeyId = "LTAI5tDbRqXkC5i3SMrCSDcX";
|
||||
|
||||
private static String accessKeySecret = "XUzMZoHPLsjNLafHsdQnMElBWZATsu";
|
||||
|
||||
/**
|
||||
* 短信访问域名
|
||||
*/
|
||||
private static String endpoint = "dysmsapi.aliyuncs.com";
|
||||
/**
|
||||
* 短信签名
|
||||
*/
|
||||
private static String signName = "乐优购";
|
||||
|
||||
private static String templateCode = "SMS_163851467";
|
||||
|
||||
/**
|
||||
* 实例化短信对象
|
||||
*/
|
||||
private static Client client;
|
||||
|
||||
static {
|
||||
log.info("初始化短信服务开始");
|
||||
long startTime = System.currentTimeMillis();
|
||||
try {
|
||||
client = initClient();
|
||||
log.info("初始化短信成功:{}", signName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log.info("初始化短信服务结束:耗时:{}MS", (System.currentTimeMillis() - startTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化短信对象
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static Client initClient() throws Exception {
|
||||
Config config = new Config()
|
||||
// 您的AccessKey ID
|
||||
.setAccessKeyId(accessKeyId)
|
||||
// 您的AccessKey Secret
|
||||
.setAccessKeySecret(accessKeySecret);
|
||||
// 访问的域名
|
||||
config.endpoint = endpoint;
|
||||
return new Client(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送单条短信
|
||||
*
|
||||
* @param tel
|
||||
*/
|
||||
public static SendSmsResponseBody sendSms(String tel, Map<String, String> sendDataMap) {
|
||||
SendSmsRequest sendSmsRequest = new SendSmsRequest()
|
||||
.setPhoneNumbers(tel)
|
||||
.setSignName(signName)
|
||||
.setTemplateCode(templateCode)
|
||||
.setTemplateParam(JSONObject.toJSONString(sendDataMap));
|
||||
SendSmsResponse sendSmsResponse = null;
|
||||
try {
|
||||
log.info("发送短信验证码:消息内容是:【{}】", JSONObject.toJSONString(sendDataMap));
|
||||
sendSmsResponse = client.sendSms(sendSmsRequest);
|
||||
} catch (Exception e) {
|
||||
log.error("短信发送异常,手机号:【{}】,短信内容:【{}】,异常信息:【{}】", tel, sendDataMap, e);
|
||||
}
|
||||
return sendSmsResponse.getBody();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?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.bwie</groupId>
|
||||
<artifactId>weekone</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-gateway</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- 公共模块 -->
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
</dependency>
|
||||
<!-- 网关依赖 -->
|
||||
<!-- SpringCloud Gateway -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Sentinel Gateway -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
|
||||
</dependency>
|
||||
<!-- 引入阿里巴巴sentinel限流 依赖-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.csp</groupId>
|
||||
<artifactId>sentinel-spring-cloud-gateway-adapter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie.gateway;
|
||||
|
||||
import com.alibaba.cloud.sentinel.gateway.SentinelGatewayAutoConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
@SpringBootApplication(exclude = {SentinelGatewayAutoConfiguration.class, DataSourceAutoConfiguration.class})
|
||||
public class GatewayApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GatewayApplication.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.bwie.gateway.config;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description: 放行白名单配置
|
||||
*/
|
||||
@Configuration
|
||||
@RefreshScope
|
||||
@ConfigurationProperties(prefix = "ignore")
|
||||
@Data
|
||||
@Log4j2
|
||||
public class IgnoreWhiteConfig {
|
||||
/**
|
||||
* 放行白名单配置,网关不校验此处的白名单
|
||||
*/
|
||||
private List<String> whites = new ArrayList<>();
|
||||
|
||||
public void setWhites(List<String> whites) {
|
||||
log.info("加载网关路径白名单:{}", JSONObject.toJSONString(whites));
|
||||
this.whites = whites;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package com.bwie.gateway.filters;
|
||||
|
||||
import com.bwie.common.constants.TokenConstants;
|
||||
import com.bwie.common.utils.JwtUtils;
|
||||
import com.bwie.common.utils.StringUtils;
|
||||
import com.bwie.gateway.config.IgnoreWhiteConfig;
|
||||
import com.bwie.gateway.utils.GatewayUtils;
|
||||
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.Ordered;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 鉴权过滤器
|
||||
*/
|
||||
@Component
|
||||
public class AuthFilter implements GlobalFilter, Ordered {
|
||||
|
||||
@Autowired
|
||||
private IgnoreWhiteConfig ignoreWhiteConfig;
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
List<String> whites = ignoreWhiteConfig.getWhites();
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
String path = request.getURI().getPath();
|
||||
if (StringUtils.matches(path, whites)) {
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
String token = request.getHeaders().getFirst(TokenConstants.TOKEN);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return GatewayUtils.errorResponse(exchange, "无权访问");
|
||||
}
|
||||
try {
|
||||
JwtUtils.parseToken(token);
|
||||
} catch (Exception ex) {
|
||||
return GatewayUtils.errorResponse(exchange, "token不合法");
|
||||
}
|
||||
String userKey = JwtUtils.getUserKey(token);
|
||||
if (!redisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY + userKey)) {
|
||||
return GatewayUtils.errorResponse(exchange, "token过期");
|
||||
} else {
|
||||
Long remainingExpireTime = redisTemplate.getExpire(TokenConstants.LOGIN_TOKEN_KEY + userKey, TimeUnit.SECONDS);
|
||||
if (remainingExpireTime <= 600) {
|
||||
redisTemplate.expire(TokenConstants.LOGIN_TOKEN_KEY + userKey, 900, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package com.bwie.gateway.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.common.utils.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;
|
||||
|
||||
/**
|
||||
* @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, HttpStatus httpStatus) {
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
//设置HTTP响应头状态
|
||||
response.setStatusCode(httpStatus);
|
||||
//设置HTTP响应头文本格式
|
||||
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json");
|
||||
//定义响应内容
|
||||
Result<?> result = Result.error(msg);
|
||||
String resultJson = JSONObject.toJSONString(result);
|
||||
log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson);
|
||||
DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes());
|
||||
//进行响应
|
||||
return response.writeWith(Mono.just(dataBuffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误结果响应
|
||||
* @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");
|
||||
//定义响应内容
|
||||
Result<?> result = Result.error(msg);
|
||||
String resultJson = JSONObject.toJSONString(result);
|
||||
log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson);
|
||||
DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes());
|
||||
//进行响应
|
||||
return response.writeWith(Mono.just(dataBuffer));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 18080
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-gateway
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
main:
|
||||
# 允许使用循环引用
|
||||
allow-circular-references: true
|
||||
# 允许定义相同的bean对象 去覆盖原有的
|
||||
allow-bean-definition-overriding: true
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 118.25.94.40:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 118.25.94.40:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,25 @@
|
|||
<?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.bwie</groupId>
|
||||
<artifactId>bwie-module</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-bicycle</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie.bicycle;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.bwie.bicycle.mapper")
|
||||
@EnableFeignClients
|
||||
public class BicycleApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BicycleApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.bwie.bicycle.controller;
|
||||
|
||||
import com.bwie.bicycle.service.BicycleService;
|
||||
import com.bwie.common.domain.Bicycle;
|
||||
import com.bwie.common.domain.request.BicycleRequest;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class BicycleController {
|
||||
|
||||
@Autowired
|
||||
private BicycleService service;
|
||||
|
||||
/**
|
||||
* 查询自行车列表
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/queryBicycle")
|
||||
public Result<List<Bicycle>> queryBicycle(@RequestBody BicycleRequest request){
|
||||
List<Bicycle> bicycles = service.queryBicycle(request);
|
||||
return Result.success(bicycles);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开始用车
|
||||
* @param bicycleId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/startUseCar")
|
||||
public Result<Bicycle> startUseCar(@RequestParam Integer bicycleId){
|
||||
Bicycle bicycle = service.startUseCar(bicycleId);
|
||||
return Result.success(bicycle);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 结束行程之后让自行车可以使用
|
||||
* @param bicycleId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/updateBicycleFlag")
|
||||
public Result<Void> updateBicycleFlag(@RequestParam Integer bicycleId){
|
||||
service.updateBicycleFlag(bicycleId);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.bwie.bicycle.mapper;
|
||||
|
||||
import com.bwie.common.domain.Bicycle;
|
||||
import com.bwie.common.domain.request.BicycleRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public interface BicycleMapper {
|
||||
//查询自行车列表
|
||||
List<Bicycle> queryBicycle(BicycleRequest bicycleRequest);
|
||||
//开始用车
|
||||
Bicycle startUseCar(@Param("bicycleId") Integer bicycleId);
|
||||
//出租
|
||||
void updateFlag(Integer bicycleId);
|
||||
//结束行程之后让自行车可以使用
|
||||
void updateBicycleFlag(@Param("bicycleId") Integer bicycleId);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.bwie.bicycle.remote;
|
||||
|
||||
import com.bwie.bicycle.remote.impl.Fusing;
|
||||
import com.bwie.common.domain.Record;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(name = "bwie-record",fallbackFactory = Fusing.class)
|
||||
public interface RecordRemote {
|
||||
/**
|
||||
* 添加记录
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/saveRecord")
|
||||
public Result<Integer> saveRecord(@RequestBody Record record);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.bwie.bicycle.remote.impl;
|
||||
|
||||
import com.bwie.bicycle.remote.RecordRemote;
|
||||
import com.bwie.common.domain.Record;
|
||||
import com.bwie.common.result.Result;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Fusing implements FallbackFactory<RecordRemote> {
|
||||
@Override
|
||||
public RecordRemote create(Throwable cause) {
|
||||
return new RecordRemote() {
|
||||
@Override
|
||||
public Result<Integer> saveRecord(Record record) {
|
||||
throw new RuntimeException("远程调用失败");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.bwie.bicycle.service;
|
||||
|
||||
import com.bwie.common.domain.Bicycle;
|
||||
import com.bwie.common.domain.request.BicycleRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BicycleService {
|
||||
//查询自行车列表
|
||||
List<Bicycle> queryBicycle(BicycleRequest request);
|
||||
//开始用车
|
||||
Bicycle startUseCar(Integer bicycleId);
|
||||
//结束行程之后让自行车可以使用
|
||||
void updateBicycleFlag(Integer bicycleId);
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package com.bwie.bicycle.service.impl;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.bicycle.mapper.BicycleMapper;
|
||||
import com.bwie.bicycle.remote.RecordRemote;
|
||||
import com.bwie.bicycle.service.BicycleService;
|
||||
import com.bwie.common.constants.TokenConstants;
|
||||
import com.bwie.common.domain.Bicycle;
|
||||
import com.bwie.common.domain.Record;
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.domain.request.BicycleRequest;
|
||||
import com.bwie.common.utils.JwtUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@Service
|
||||
public class BicycleServiceImpl implements BicycleService {
|
||||
|
||||
@Resource
|
||||
private BicycleMapper bicycleMapper;
|
||||
|
||||
@Autowired
|
||||
private RecordRemote recordRemote;
|
||||
|
||||
/**
|
||||
* 查询自行车列表
|
||||
* @param bicycleRequest
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Bicycle> queryBicycle(BicycleRequest bicycleRequest) {
|
||||
List<Bicycle> bicycles = bicycleMapper.queryBicycle(bicycleRequest);
|
||||
if (bicycles == null){
|
||||
throw new RuntimeException("查询自行车列表失败");
|
||||
}
|
||||
return bicycles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始用车
|
||||
* @param bicycleId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Bicycle startUseCar(Integer bicycleId) {
|
||||
Bicycle bicycle = bicycleMapper.startUseCar(bicycleId);
|
||||
if (bicycle == null){
|
||||
throw new RuntimeException(" bicycleId="+bicycleId+" bicycle不存在");
|
||||
}
|
||||
Record record = new Record();
|
||||
record.setRecordNumber(bicycle.getBicycleNumber());
|
||||
record.setRecordType(bicycle.getBicycleType());
|
||||
record.setRecordUserName(userInfo().getUserName());
|
||||
record.setRecordStartTime(new Date());
|
||||
record.setRecordDrivingTime(52);
|
||||
double randomDouble = RandomUtil.randomDouble();
|
||||
record.setRecordTravelDistance(randomDouble);
|
||||
BigDecimal bigDecimal = RandomUtil.randomBigDecimal();
|
||||
record.setRecordPrice(bigDecimal);
|
||||
record.setRecordFlag(1);
|
||||
recordRemote.saveRecord(record);
|
||||
|
||||
bicycleMapper.updateFlag(bicycle.getBicycleId());
|
||||
|
||||
return bicycle;
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
public User userInfo(){
|
||||
String token = httpServletRequest.getHeader(TokenConstants.TOKEN);
|
||||
String userKey = JwtUtils.getUserKey(token);
|
||||
String user = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||
User user1 = JSONObject.parseObject(user, User.class);
|
||||
return user1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束行程之后让自行车可以使用
|
||||
* @param bicycleId
|
||||
*/
|
||||
@Override
|
||||
public void updateBicycleFlag(Integer bicycleId) {
|
||||
bicycleMapper.updateBicycleFlag(bicycleId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9003
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-bicycle
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 118.25.94.40:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 118.25.94.40:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,56 @@
|
|||
<?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">
|
||||
<!--
|
||||
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||
-->
|
||||
<mapper namespace="com.bwie.bicycle.mapper.BicycleMapper">
|
||||
|
||||
<!--查询自行车列表-->
|
||||
<select id="queryBicycle" resultType="com.bwie.common.domain.Bicycle">
|
||||
SELECT
|
||||
bicycle_id,
|
||||
bicycle_name,
|
||||
bicycle_number,
|
||||
bicycle_type,
|
||||
bicycle_flag,
|
||||
balance
|
||||
FROM
|
||||
tb_bicycle
|
||||
<where>
|
||||
<if test="bicycleType != null">
|
||||
and bicycle_type = #{bicycleType}
|
||||
</if>
|
||||
<if test="bicycleFlag != null">
|
||||
and bicycle_flag = #{bicycleFlag}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--开始用车-->
|
||||
<select id="startUseCar" resultType="com.bwie.common.domain.Bicycle">
|
||||
SELECT
|
||||
bicycle_id,
|
||||
bicycle_name,
|
||||
bicycle_number,
|
||||
bicycle_type,
|
||||
bicycle_flag,
|
||||
balance
|
||||
FROM
|
||||
tb_bicycle
|
||||
where bicycle_id = #{bicycleId}
|
||||
</select>
|
||||
|
||||
<!--出租-->
|
||||
<update id="updateFlag">
|
||||
update tb_bicycle set bicycle_flag = 2 where bicycle_id = #{bicycleId}
|
||||
</update>
|
||||
|
||||
<!--结束行程之后让自行车可以使用-->
|
||||
<update id="updateBicycleFlag">
|
||||
update tb_bicycle set bicycle_flag = 1 where bicycle_id = #{bicycleId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,24 @@
|
|||
<?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.bwie</groupId>
|
||||
<artifactId>bwie-module</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-record</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
package com.bwie.record;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.bwie.record.mapper")
|
||||
@EnableFeignClients
|
||||
public class RecordApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RecordApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.bwie.record.controller;
|
||||
|
||||
import com.bwie.common.domain.Record;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.record.service.RecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class RecordController {
|
||||
|
||||
@Autowired
|
||||
private RecordService recordService;
|
||||
|
||||
|
||||
/**
|
||||
* 添加记录
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/saveRecord")
|
||||
public Result<Integer> saveRecord(@RequestBody Record record){
|
||||
Integer i = recordService.saveRecord(record);
|
||||
return Result.success(i);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询记录
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryRecord")
|
||||
public Result<List<Record>> queryRecord(){
|
||||
List<Record> records = recordService.queryRecord();
|
||||
return Result.success(records);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 结束行程
|
||||
* @param recordId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/finish")
|
||||
public Result<Record> finish(@RequestParam Integer recordId){
|
||||
Record finish = recordService.finish(recordId);
|
||||
return Result.success(finish);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.bwie.record.mapper;
|
||||
|
||||
import com.bwie.common.domain.Record;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public interface RecordMapper {
|
||||
//添加记录
|
||||
Integer saveRecord(Record record);
|
||||
//查询记录
|
||||
List<Record> queryRecord();
|
||||
//结束行程
|
||||
Record finish(Integer recordId);
|
||||
|
||||
void updateDrivingTime(Integer recordId);
|
||||
|
||||
void updateRecordTravelDistance(Integer recordId);
|
||||
|
||||
void updateRecordPrice(Integer recordId);
|
||||
|
||||
void updateRecordFlag(Integer recordId);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bwie.record.remote;
|
||||
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.record.remote.impl.Fusing;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(name = "bwie-bicycle",fallbackFactory = Fusing.class)
|
||||
public interface BicycleRemote {
|
||||
/**
|
||||
* 结束行程之后让自行车可以使用
|
||||
* @param bicycleId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/updateBicycleFlag")
|
||||
public Result<Void> updateBicycleFlag(@RequestParam Integer bicycleId);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.bwie.record.remote.impl;
|
||||
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.record.remote.BicycleRemote;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
public class Fusing implements FallbackFactory<BicycleRemote> {
|
||||
@Override
|
||||
public BicycleRemote create(Throwable cause) {
|
||||
return new BicycleRemote() {
|
||||
@Override
|
||||
public Result<Void> updateBicycleFlag(Integer bicycleId) {
|
||||
throw new RuntimeException("服务异常");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.bwie.record.service;
|
||||
|
||||
import com.bwie.common.domain.Record;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RecordService {
|
||||
//添加记录
|
||||
Integer saveRecord(Record record);
|
||||
//查询记录
|
||||
List<Record> queryRecord();
|
||||
//结束行程
|
||||
Record finish(Integer recordId);
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package com.bwie.record.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.common.domain.Record;
|
||||
import com.bwie.common.utils.TelSmsUtils;
|
||||
import com.bwie.record.mapper.RecordMapper;
|
||||
import com.bwie.record.remote.BicycleRemote;
|
||||
import com.bwie.record.service.RecordService;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static javax.swing.UIManager.put;
|
||||
|
||||
@Service
|
||||
public class RecordServiceImpl implements RecordService {
|
||||
|
||||
@Resource
|
||||
private RecordMapper recordMapper;
|
||||
|
||||
/**
|
||||
* 添加记录
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Integer saveRecord(Record record) {
|
||||
Integer i = recordMapper.saveRecord(record);
|
||||
if (i < 0){
|
||||
throw new RuntimeException("添加记录失败");
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询记录
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Record> queryRecord() {
|
||||
List<Record> records = recordMapper.queryRecord();
|
||||
return records;
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private BicycleRemote bicycleRemote;
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
* 结束行程
|
||||
* @param recordId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Record finish(Integer recordId) {
|
||||
Record record = recordMapper.finish(recordId);
|
||||
|
||||
// 用车时长:当前时间-用车开始时间,单位为分钟,数据计算正确
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
Date startTime = record.getRecordStartTime();
|
||||
if (startTime != null){
|
||||
long time = currentTimeMillis - startTime.getTime();
|
||||
long minutes = time / (1000 * 60);
|
||||
record.setRecordDrivingTime(Integer.parseInt(String.valueOf(minutes)));
|
||||
//行驶距离:用车时长×0.8,结果计算正确
|
||||
record.setRecordTravelDistance(Double.parseDouble(String.valueOf(minutes * 0.8)));
|
||||
//费用计算公式:(车型公里单价)×公里数+0.1×用车时间(单位分钟),车型公里单价(入门山地每公里1元,入门公路车每公里1.2元,专业山地车每公里1.3元,专业公路车每公里1.6元)
|
||||
record.setRecordPrice(BigDecimal.valueOf(Double.parseDouble(String.valueOf(record.getRecordType() * record.getRecordTravelDistance() + 0.1 * record.getRecordDrivingTime()))));
|
||||
|
||||
}
|
||||
|
||||
//点击结束行程,自行车列表对应自行车状态变更为未使用
|
||||
bicycleRemote.updateBicycleFlag(recordId);
|
||||
|
||||
recordMapper.updateDrivingTime(recordId);
|
||||
recordMapper.updateRecordTravelDistance(recordId);
|
||||
recordMapper.updateRecordPrice(recordId);
|
||||
recordMapper.updateRecordFlag(recordId);
|
||||
|
||||
|
||||
TelSmsUtils.sendSms(String.valueOf(record), new HashMap<String, String>() {{
|
||||
put("record", String.valueOf(record));
|
||||
}});
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9004
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-record
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 118.25.94.40:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 118.25.94.40:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,70 @@
|
|||
<?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">
|
||||
<!--
|
||||
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||
-->
|
||||
<mapper namespace="com.bwie.record.mapper.RecordMapper">
|
||||
|
||||
<!--添加记录-->
|
||||
<insert id="saveRecord">
|
||||
insert into tb_record(record_number,record_type,record_user_name,record_start_time,record_driving_time,record_travel_distance,record_price,record_flag)
|
||||
values(#{recordNumber},#{recordType},#{recordUserName},#{recordStartTime},#{recordDrivingTime},#{recordTravelDistance},#{recordPrice},#{recordFlag})
|
||||
</insert>
|
||||
|
||||
|
||||
<!--查询记录-->
|
||||
<select id="queryRecord" resultType="com.bwie.common.domain.Record">
|
||||
SELECT
|
||||
record_id,
|
||||
record_number,
|
||||
record_type,
|
||||
record_user_name,
|
||||
record_start_time,
|
||||
record_driving_time,
|
||||
record_travel_distance,
|
||||
record_price,
|
||||
record_flag
|
||||
FROM
|
||||
tb_record
|
||||
</select>
|
||||
|
||||
<!--结束行程-->
|
||||
<select id="finish" resultType="com.bwie.common.domain.Record">
|
||||
SELECT
|
||||
record_id,
|
||||
record_number,
|
||||
record_type,
|
||||
record_user_name,
|
||||
record_start_time,
|
||||
record_driving_time,
|
||||
record_travel_distance,
|
||||
record_price,
|
||||
record_flag
|
||||
FROM
|
||||
tb_record
|
||||
where record_id = #{recordId}
|
||||
</select>
|
||||
|
||||
<update id="updateDrivingTime">
|
||||
update tb_record set record_driving_time = #{recordDrivingTime} where record_id = #{recordId}
|
||||
</update>
|
||||
|
||||
|
||||
<update id="updateRecordTravelDistance">
|
||||
update tb_record set record_travel_distance = #{recordTravelDistance} where record_id = #{recordId}
|
||||
</update>
|
||||
|
||||
|
||||
<update id="updateRecordPrice">
|
||||
update tb_record set record_price = #{recordPrice} where record_id = #{recordId}
|
||||
</update>
|
||||
|
||||
<update id="updateRecordFlag">
|
||||
update tb_record set record_flag = 2 where record_id = #{recordId}
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,25 @@
|
|||
<?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.bwie</groupId>
|
||||
<artifactId>bwie-module</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-system</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package com.bwie.system;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.bwie.system.mapper")
|
||||
public class SystemApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SystemApplication.class,args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.bwie.system.controller;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.system.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService service;
|
||||
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户信息
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/findByPhone")
|
||||
public Result<User> findByPhone(@RequestParam String phone){
|
||||
User byPhone = service.findByPhone(phone);
|
||||
return Result.success(byPhone);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.bwie.system.mapper;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public interface UserMapper {
|
||||
// 根据手机号查询用户信息
|
||||
User findByPhone(@Param("phone") String phone);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.bwie.system.service;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
|
||||
public interface UserService {
|
||||
//根据手机号查询用户
|
||||
User findByPhone(String phone);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.bwie.system.service.impl;
|
||||
|
||||
import com.bwie.common.domain.User;
|
||||
import com.bwie.system.mapper.UserMapper;
|
||||
import com.bwie.system.service.UserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Resource
|
||||
private UserMapper mapper;
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public User findByPhone(String phone) {
|
||||
User byPhone = mapper.findByPhone(phone);
|
||||
return byPhone;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9002
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-system
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 118.25.94.40:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 118.25.94.40:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,15 @@
|
|||
<?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">
|
||||
<!--
|
||||
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||
-->
|
||||
<mapper namespace="com.bwie.system.mapper.UserMapper">
|
||||
|
||||
<!--根据手机号查询用户信息-->
|
||||
<select id="findByPhone" resultType="com.bwie.common.domain.User">
|
||||
select user_id,phone,user_name,user_pwd,user_role from t_user where phone = #{phone}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,26 @@
|
|||
<?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.bwie</groupId>
|
||||
<artifactId>weekone</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-module</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>bwie-system</module>
|
||||
<module>bwie-bicycle</module>
|
||||
<module>bwie-record</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,114 @@
|
|||
<?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.bwie</groupId>
|
||||
<artifactId>weekone</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>bwie-common</module>
|
||||
<module>bwie-gateway</module>
|
||||
<module>bwie-auth</module>
|
||||
<module>bwie-module</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring-cloud.version>2021.0.0</spring-cloud.version>
|
||||
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
|
||||
<jjwt.version>0.9.1</jjwt.version>
|
||||
<fastjson.version>1.2.80</fastjson.version>
|
||||
<hutool.version>5.8.3</hutool.version>
|
||||
<alidy.version>2.0.1</alidy.version>
|
||||
<fastdfs-client>1.26.5</fastdfs-client>
|
||||
</properties>
|
||||
|
||||
<!-- 规定SpringBoot版本 -->
|
||||
<parent>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<version>2.6.2</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- SpringCloud 微服务 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba 微服务 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>${spring-cloud-alibaba.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- JWT -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
</dependency>
|
||||
<!-- Alibaba Fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- 阿里大鱼 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dysmsapi20170525</artifactId>
|
||||
<version>${alidy.version}</version>
|
||||
</dependency>
|
||||
<!-- Druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.2.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
<!-- Pagehelper -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
<!-- 公共模块 -->
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.tobato</groupId>
|
||||
<artifactId>fastdfs-client</artifactId>
|
||||
<version>${fastdfs-client}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
Loading…
Reference in New Issue