week
commit
adb2c73333
|
@ -0,0 +1,32 @@
|
|||
<?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>Mp-Week2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-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.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringBoot Web-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,23 @@
|
|||
package com.bwie.auth;
|
||||
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.bwie.config.MybitsPlusConfig;
|
||||
import com.bwie.handler.GlobalExceptionHandler;
|
||||
import com.bwie.remote.user.UserFeign;
|
||||
import com.bwie.remote.user.errory.ErroryFeign;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients(value = "com.bwie.**")
|
||||
@Import({MybitsPlusConfig.class, GlobalExceptionHandler.class, ErroryFeign.class})
|
||||
public class AuthSpringBootApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthSpringBootApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.bwie.auth.controller;
|
||||
|
||||
import com.bwie.auth.service.AuthService;
|
||||
import com.bwie.domain.User;
|
||||
import com.bwie.domain.request.UserRequest;
|
||||
import com.bwie.domain.response.UserReponse;
|
||||
import com.bwie.result.Result;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/login")
|
||||
public class AuthController {
|
||||
private final AuthService authService;
|
||||
|
||||
public AuthController(AuthService authService) {
|
||||
this.authService = authService;
|
||||
}
|
||||
|
||||
@PostMapping("/loginName")
|
||||
public Result login(@RequestBody @Validated UserRequest userRequest){
|
||||
UserReponse login = authService.login(userRequest);
|
||||
return Result.success(login);
|
||||
}
|
||||
@GetMapping("/info")
|
||||
public Result<User> info(){
|
||||
User info = authService.info();
|
||||
return Result.success(info);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.bwie.auth.service;
|
||||
|
||||
import com.bwie.domain.User;
|
||||
import com.bwie.domain.request.UserRequest;
|
||||
import com.bwie.domain.response.UserReponse;
|
||||
|
||||
public interface AuthService {
|
||||
UserReponse login(UserRequest userRequest);
|
||||
|
||||
User info();
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.bwie.auth.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bwie.auth.service.AuthService;
|
||||
import com.bwie.constant.JwtConstants;
|
||||
import com.bwie.constant.TokenConstants;
|
||||
import com.bwie.domain.User;
|
||||
import com.bwie.domain.request.UserRequest;
|
||||
import com.bwie.domain.response.UserReponse;
|
||||
import com.bwie.remote.user.UserFeign;
|
||||
import com.bwie.result.Result;
|
||||
import com.bwie.utils.IdUtils;
|
||||
import com.bwie.utils.JwtUtils;
|
||||
import com.bwie.utils.SecurityUtils;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class AuthServiceImpl implements AuthService {
|
||||
private final UserFeign userFeign;
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
public AuthServiceImpl(UserFeign userFeign, StringRedisTemplate stringRedisTemplate) {
|
||||
this.userFeign = userFeign;
|
||||
this.stringRedisTemplate = stringRedisTemplate;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserReponse login(UserRequest userRequest) {
|
||||
Result<User> login = userFeign.login(userRequest.getUserName());
|
||||
Assert.isTrue(login.isSuccess(),"登录失败");
|
||||
User data = login.getData();
|
||||
Assert.notNull(data,"用户名尚未注册");
|
||||
boolean b = SecurityUtils.matchesPassword(userRequest.getUserPwd(), data.getUserSalt(), data.getUserPwd());
|
||||
Assert.isTrue(b,"用户名或密码错误");
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
String s = IdUtils.genId();
|
||||
map.put(JwtConstants.USER_KEY,s);
|
||||
map.put(JwtConstants.DETAILS_USER_ID,data.getUserId());
|
||||
map.put(JwtConstants.DETAILS_USERNAME,data.getUserName());
|
||||
String token = JwtUtils.createToken(map);
|
||||
stringRedisTemplate.opsForValue().set("token",s);
|
||||
stringRedisTemplate.opsForValue().set(TokenConstants.LOGIN_TOKEN_KEY+s, JSON.toJSONString(data),TokenConstants.EXPIRATION, TimeUnit.SECONDS);
|
||||
return UserReponse.builder()
|
||||
.token(token)
|
||||
.outTime(TokenConstants.EXPIRATION)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public User info(){
|
||||
String s1 = stringRedisTemplate.opsForValue().get("token");
|
||||
String s = stringRedisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + s1);
|
||||
User user = JSON.parseObject(s, User.class);
|
||||
return user;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9005
|
||||
# Spring
|
||||
spring:
|
||||
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: 124.223.156.14:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 124.223.156.14:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,141 @@
|
|||
<?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>Mp-Week2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-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>
|
||||
<!-- 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>
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</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>
|
||||
<version>0.9.1</version>
|
||||
</dependency>
|
||||
<!-- Alibaba Fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.80</version>
|
||||
</dependency>
|
||||
<!-- SpringBoot Boot Redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!-- Druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.2.8</version>
|
||||
</dependency>
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
<!-- Mybatis-plus 配置 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.4.1</version>
|
||||
</dependency>
|
||||
<!-- Mybatis 依赖配置 -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</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>
|
||||
<!-- lombok依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- oss 图片上传 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <!–mq 依赖–>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>-->
|
||||
<!--fastDfs文件上传-->
|
||||
<dependency>
|
||||
<groupId>com.github.tobato</groupId>
|
||||
<artifactId>fastdfs-client</artifactId>
|
||||
<version>1.26.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringBoot 测试框架 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,26 @@
|
|||
package com.bwie.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;
|
||||
|
||||
@Configuration
|
||||
public class MybitsPlusConfig {
|
||||
public MybitsPlusConfig(){
|
||||
System.out.println("初始化>>>>>");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分页插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor(){
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bwie.constant;
|
||||
|
||||
/**
|
||||
* @description: 系统常量
|
||||
* @author DongZl
|
||||
*/
|
||||
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,27 @@
|
|||
package com.bwie.constant;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @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,15 @@
|
|||
package com.bwie.constant;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 服务名称常量
|
||||
* @Date 2024-1-11 下午 07:43
|
||||
*/
|
||||
public class ServerNameConstants {
|
||||
|
||||
/**
|
||||
* 系统服务名称
|
||||
*/
|
||||
public final static String SYSTEM_NAME = "bwie-user";
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.bwie.constant;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @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,64 @@
|
|||
package com.bwie.domain;
|
||||
|
||||
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.bwie.domain.request.CarReqyest;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("car")
|
||||
public class Car {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long carId;
|
||||
|
||||
@TableField(value = "car_type")
|
||||
private String carType;
|
||||
|
||||
@TableField(value = "car_card")
|
||||
private String carCard;
|
||||
|
||||
@TableField(value = "car_ver")
|
||||
private String carVer;
|
||||
|
||||
@TableField(value = "car_place")
|
||||
private String carPlace;
|
||||
|
||||
@TableField(value = "car_flag")
|
||||
private Long carFlag;
|
||||
|
||||
@TableField(value = "car_time")
|
||||
private Date carTime;
|
||||
|
||||
@TableField(value = "car_name")
|
||||
private String carName;
|
||||
|
||||
@TableField(value = "car_phone")
|
||||
private String carPhone;
|
||||
|
||||
@TableField(value = "car_num")
|
||||
private Long carNum;
|
||||
|
||||
public static Car addCar(CarReqyest carReqyest){
|
||||
return Car.builder()
|
||||
.carTime(carReqyest.getCarTime())
|
||||
.carType(carReqyest.getCarType())
|
||||
.carName(carReqyest.getCarName())
|
||||
.carPhone(carReqyest.getCarPhone())
|
||||
.carCard(carReqyest.getCarCard())
|
||||
.carVer(carReqyest.getCarVer())
|
||||
.carPlace(carReqyest.getCarPlace())
|
||||
.carFlag(Long.valueOf(1))
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.bwie.domain;
|
||||
|
||||
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("emp")
|
||||
public class Emp {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long empId;
|
||||
|
||||
@TableField(value = "emp_name")
|
||||
private String empName;
|
||||
|
||||
@TableField(value = "emp_phone")
|
||||
private String empPhone;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.bwie.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Data
|
||||
public class Page {
|
||||
private Integer pageNum=1;
|
||||
private Integer pageSize=8;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.bwie.domain;
|
||||
|
||||
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("user")
|
||||
public class User {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long userId;
|
||||
|
||||
@TableField(value = "user_name")
|
||||
private String userName;
|
||||
|
||||
@TableField(value = "user_pwd")
|
||||
private String userPwd;
|
||||
|
||||
@TableField(value = "user_salt")
|
||||
private String userSalt;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.bwie.domain.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CarReqyest {
|
||||
private String carType;
|
||||
private String carCard;
|
||||
private String carVer;
|
||||
private String carPlace;
|
||||
private Long carFlag;
|
||||
private Date carTime;
|
||||
private String carName;
|
||||
private String carPhone;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.bwie.domain.request;
|
||||
|
||||
import com.bwie.domain.Page;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CarVo extends Page {
|
||||
private String carName;
|
||||
private String carPhone;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.bwie.domain.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("car")
|
||||
public class UserRequest {
|
||||
@NotBlank(message = "不能为空")
|
||||
private String userName;
|
||||
|
||||
@NotBlank(message = "不能为空")
|
||||
private String userPwd;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bwie.domain.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserReponse {
|
||||
private String token;
|
||||
private Long outTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.bwie.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.result.Result;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@RestControllerAdvice
|
||||
@Configuration
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
/**
|
||||
* 全局的异常处理
|
||||
* @param exception
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
||||
public Result<String> runtimeException(MethodArgumentNotValidException exception){
|
||||
return Result.error(
|
||||
JSONObject.toJSONString(
|
||||
exception.getBindingResult().getAllErrors()
|
||||
.stream()
|
||||
.map(ObjectError::getDefaultMessage)
|
||||
.toList()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.bwie.remote.user;
|
||||
|
||||
import com.bwie.constant.ServerNameConstants;
|
||||
import com.bwie.domain.User;
|
||||
import com.bwie.remote.user.errory.ErroryFeign;
|
||||
import com.bwie.result.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@FeignClient(
|
||||
name = ServerNameConstants.SYSTEM_NAME,
|
||||
fallbackFactory = ErroryFeign.class,
|
||||
path = "/user"
|
||||
)
|
||||
public interface UserFeign {
|
||||
@PostMapping("/loginName/{userName}")
|
||||
public Result<User> login(@PathVariable String userName);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.bwie.remote.user.errory;
|
||||
|
||||
import com.bwie.domain.User;
|
||||
import com.bwie.remote.user.UserFeign;
|
||||
import com.bwie.result.Result;
|
||||
import lombok.extern.java.Log;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Log4j2
|
||||
public class ErroryFeign implements FallbackFactory<UserFeign> {
|
||||
@Override
|
||||
public UserFeign create(Throwable cause) {
|
||||
return new UserFeign() {
|
||||
@Override
|
||||
public Result<User> login(String userName) {
|
||||
log.error("远程调用失败");
|
||||
return Result.error();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.bwie.result;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @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,68 @@
|
|||
package com.bwie.result;
|
||||
|
||||
import com.bwie.constant.Constants;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description: 响应信息主体
|
||||
* @author DongZl
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
/**
|
||||
* 成功
|
||||
* @return 成功 true
|
||||
*/
|
||||
public boolean isSuccess(){
|
||||
return this.code == SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败
|
||||
* @return 失败 false
|
||||
*/
|
||||
public boolean isError(){
|
||||
return !isSuccess();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.bwie.utils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: ID生成工具类
|
||||
* @Date 2024-1-10 下午 08:26
|
||||
*/
|
||||
public class IdUtils {
|
||||
|
||||
/**
|
||||
* 生成UUID
|
||||
* @return UUID
|
||||
*/
|
||||
public static String genId(){
|
||||
return UUID.randomUUID().toString().replace("-", "");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package com.bwie.utils;
|
||||
|
||||
import com.bwie.constant.JwtConstants;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @description: Jwt工具类
|
||||
* @author DongZl
|
||||
*/
|
||||
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,54 @@
|
|||
package com.bwie.utils;
|
||||
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* 安全服务工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SecurityUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 生成BCryptPasswordEncoder密码
|
||||
*
|
||||
* @param password 密码
|
||||
*
|
||||
* @return 加密字符串
|
||||
*/
|
||||
public static String encryptPassword (String password, String salt) {
|
||||
return encryptMD5(password, salt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断密码是否相同
|
||||
*
|
||||
* @param rawPassword 真实密码
|
||||
* @param encodedPassword 加密后字符
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean matchesPassword (String rawPassword, String salt, String encodedPassword) {
|
||||
return encryptMD5(rawPassword, salt).equals(encodedPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算字符串的MD5加密值,并返回Base64编码的字符串。
|
||||
* @param password 要加密的字符串
|
||||
* @return 加密后的Base64编码字符串
|
||||
*/
|
||||
public static String encryptMD5(String password, String salt) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update((password + salt).getBytes()); // 加盐处理
|
||||
byte[] digest = md.digest();
|
||||
return Base64.getEncoder().encodeToString(digest);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.bwie.utils;
|
||||
|
||||
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是否为空, 包含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,43 @@
|
|||
<?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>Mp-Week2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-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.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,12 @@
|
|||
package com.bwie.gateway;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
public class GateWaySpringBootApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GateWaySpringBootApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.bwie.gateway.config;
|
||||
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.sc.exception.SentinelGatewayBlockExceptionHandler;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||
import org.springframework.web.reactive.result.view.ViewResolver;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecation: 网关限流控件
|
||||
* @author DongZl
|
||||
*/
|
||||
@Configuration
|
||||
public class GatewaySentinelConfig {
|
||||
/**
|
||||
* 查看解析器
|
||||
*/
|
||||
private final List<ViewResolver> viewResolvers;
|
||||
/**
|
||||
* 服务器编解码器配置
|
||||
*/
|
||||
private final ServerCodecConfigurer serverCodecConfigurer;
|
||||
public GatewaySentinelConfig(ObjectProvider<List<ViewResolver>> viewResolversProvider,
|
||||
ServerCodecConfigurer serverCodecConfigurer) {
|
||||
this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
|
||||
this.serverCodecConfigurer = serverCodecConfigurer;
|
||||
}
|
||||
/**
|
||||
* Sentinel 网关块异常处理程序
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public SentinelGatewayBlockExceptionHandler sentinelGatewayBlockExceptionHandler() {
|
||||
// 给 Spring Cloud Gateway 注册块异常处理程序。
|
||||
return new SentinelGatewayBlockExceptionHandler(viewResolvers, serverCodecConfigurer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化网关配置
|
||||
*/
|
||||
@PostConstruct
|
||||
public void doInit() {
|
||||
initGatewayRules();
|
||||
}
|
||||
/**
|
||||
* 配置限流规则
|
||||
*/
|
||||
private void initGatewayRules() {
|
||||
Set<GatewayFlowRule> rules = new HashSet<>();
|
||||
rules.add(new GatewayFlowRule("cloud-user")
|
||||
// 限流阈值
|
||||
.setCount(1)
|
||||
// 统计时间窗口,单位是秒,默认是 1 秒
|
||||
.setIntervalSec(5)
|
||||
);
|
||||
//添加到限流规则当中
|
||||
GatewayRuleManager.loadRules(rules);
|
||||
}
|
||||
}
|
|
@ -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: 放行白名单配置
|
||||
* @author DongZl
|
||||
*/
|
||||
@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,81 @@
|
|||
package com.bwie.gateway.filters;
|
||||
|
||||
import com.bwie.constant.JwtConstants;
|
||||
import com.bwie.constant.TokenConstants;
|
||||
import com.bwie.gateway.config.IgnoreWhiteConfig;
|
||||
import com.bwie.gateway.utils.GatewayUtils;
|
||||
import com.bwie.utils.JwtUtils;
|
||||
import com.bwie.utils.StringUtils;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
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.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Component
|
||||
@Log4j2
|
||||
public class LoginFilter implements GlobalFilter, Ordered {
|
||||
private final IgnoreWhiteConfig ignoreWhiteConfig;
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
|
||||
public LoginFilter(IgnoreWhiteConfig ignoreWhiteConfig, StringRedisTemplate stringRedisTemplate) {
|
||||
this.ignoreWhiteConfig = ignoreWhiteConfig;
|
||||
this.stringRedisTemplate = stringRedisTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
//请求头作用域
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
//获取请求头
|
||||
HttpHeaders headers = request.getHeaders();
|
||||
//获取请求方式
|
||||
HttpMethod method = request.getMethod();
|
||||
//header操作对象
|
||||
ServerHttpRequest.Builder mutate = request.mutate();
|
||||
String path = request.getURI().getPath();
|
||||
log.info("请求日志: usl: [{}], 请求方式: [{}] ",path,method);
|
||||
//后台放行方法白名单
|
||||
/**
|
||||
* 查看所请求路径是否是在nacos放行名单里的
|
||||
*/
|
||||
if(StringUtils.matches(path,ignoreWhiteConfig.getWhites())){
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
String token = headers.getFirst(TokenConstants.TOKEN);
|
||||
if(StringUtils.isEmpty(token)){
|
||||
return GatewayUtils.errorResponse(exchange,"令牌不能为空");
|
||||
}
|
||||
Claims claims = JwtUtils.parseToken(token);
|
||||
if(claims == null){
|
||||
return GatewayUtils.errorResponse(exchange,"令牌已经过期或解析不正确");
|
||||
}
|
||||
String userKey = JwtUtils.getUserKey(claims);
|
||||
Boolean idLogin = stringRedisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY + userKey);
|
||||
if(!idLogin){
|
||||
return GatewayUtils.errorResponse(exchange,"登录状态过期");
|
||||
}
|
||||
String userId = JwtUtils.getUserId(claims);
|
||||
String userName = JwtUtils.getUserName(claims);
|
||||
//设置用户信息到请求
|
||||
GatewayUtils.addHeader(mutate,JwtConstants.USER_KEY,userKey);
|
||||
GatewayUtils.addHeader(mutate,JwtConstants.DETAILS_USERNAME,userName);
|
||||
GatewayUtils.addHeader(mutate,JwtConstants.DETAILS_USER_ID,userId);
|
||||
//内部请求来源参数清楚
|
||||
GatewayUtils.removeHeader(mutate,TokenConstants.TOKEN);
|
||||
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package com.bwie.gateway.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bwie.result.Result;
|
||||
import com.bwie.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;
|
||||
|
||||
/**
|
||||
* @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, 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: 124.223.156.14:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 124.223.156.14:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,33 @@
|
|||
<?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>Mp-Week2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-expressage</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.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,17 @@
|
|||
package com.bwie.exexpressage;
|
||||
|
||||
import com.bwie.config.MybitsPlusConfig;
|
||||
import com.bwie.handler.GlobalExceptionHandler;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class ListSprigBootApplucaton {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ListSprigBootApplucaton.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.bwie.exexpressage.controller;
|
||||
|
||||
import com.bwie.domain.Car;
|
||||
import com.bwie.domain.request.CarReqyest;
|
||||
import com.bwie.domain.request.CarVo;
|
||||
import com.bwie.exexpressage.service.ListService;
|
||||
import com.bwie.result.PageResult;
|
||||
import com.bwie.result.Result;
|
||||
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("/list")
|
||||
public class ListController {
|
||||
private final ListService listService;
|
||||
|
||||
public ListController(ListService listService) {
|
||||
this.listService = listService;
|
||||
}
|
||||
|
||||
@PostMapping("/showlist")
|
||||
public Result list(@RequestBody CarVo carVo){
|
||||
PageResult<Car> list = listService.list(carVo);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody @Validated CarReqyest carReqyest){
|
||||
Result result = listService.addList(carReqyest);
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/upd")
|
||||
public Result upd(@RequestBody Car car){
|
||||
listService.upd(car);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.bwie.exexpressage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bwie.domain.Car;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ListMapper extends BaseMapper<Car> {
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.bwie.exexpressage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bwie.domain.Car;
|
||||
import com.bwie.domain.request.CarReqyest;
|
||||
import com.bwie.domain.request.CarVo;
|
||||
import com.bwie.result.PageResult;
|
||||
import com.bwie.result.Result;
|
||||
|
||||
public interface ListService extends IService<Car> {
|
||||
PageResult<Car> list(CarVo carVo);
|
||||
|
||||
Result addList(CarReqyest carReqyest);
|
||||
|
||||
|
||||
void upd(Car car);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.bwie.exexpressage.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bwie.domain.Car;
|
||||
import com.bwie.domain.request.CarReqyest;
|
||||
import com.bwie.domain.request.CarVo;
|
||||
import com.bwie.exexpressage.mapper.ListMapper;
|
||||
import com.bwie.exexpressage.service.ListService;
|
||||
import com.bwie.result.PageResult;
|
||||
import com.bwie.result.Result;
|
||||
import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class ListServiceImpl extends ServiceImpl<ListMapper, Car> implements ListService {
|
||||
|
||||
@Override
|
||||
public PageResult<Car> list(CarVo carVo) {
|
||||
Page<Car> carVoPage = new Page<>();
|
||||
carVoPage.setCurrent(carVo.getPageNum());
|
||||
carVoPage.setSize(carVo.getPageSize());
|
||||
LambdaQueryWrapper<Car> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if(carVo.getCarName()!=null && !carVo.getCarName().equals("")){
|
||||
queryWrapper.like(Car::getCarName,carVo.getCarName());
|
||||
}
|
||||
if(carVo.getCarPhone()!=null && !carVo.getCarPhone().equals("")){
|
||||
queryWrapper.eq(Car::getCarName,carVo.getCarName());
|
||||
}
|
||||
Page<Car> page = page(carVoPage, queryWrapper);
|
||||
return PageResult.toPageResult(page.getTotal(),page.getRecords());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addList(CarReqyest carReqyest) {
|
||||
save(Car.addCar(carReqyest));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upd(Car car) {
|
||||
car.setCarFlag(Long.valueOf(2));
|
||||
updateById(car);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9008
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-expressage
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 124.223.156.14:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 124.223.156.14:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -0,0 +1,33 @@
|
|||
<?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>Mp-Week2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-user</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.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,18 @@
|
|||
package com.bwie;
|
||||
|
||||
import cn.hutool.http.GlobalHeaders;
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.bwie.handler.GlobalExceptionHandler;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@Import({MybatisConfiguration.class, GlobalExceptionHandler.class})
|
||||
public class UserSpringBootApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UserSpringBootApplication.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.bwie.controller;
|
||||
|
||||
import com.bwie.domain.User;
|
||||
import com.bwie.result.Result;
|
||||
import com.bwie.service.UserService;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
private final UserService userService;
|
||||
|
||||
public UserController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
@PostMapping("/loginName/{userName}")
|
||||
public Result<User> login(@PathVariable String userName){
|
||||
User user = userService.loginName(userName);
|
||||
return Result.success(user);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.bwie.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bwie.domain.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.bwie.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bwie.domain.User;
|
||||
|
||||
public interface UserService extends IService<User> {
|
||||
User loginName(String userName);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.bwie.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bwie.domain.User;
|
||||
import com.bwie.mapper.UserMapper;
|
||||
import com.bwie.service.UserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||
@Override
|
||||
public User loginName(String userName) {
|
||||
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(User::getUserName,userName);
|
||||
User one = getOne(queryWrapper);
|
||||
return one;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9001
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: bwie-user
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 124.223.156.14:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 124.223.156.14:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
@ -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.bwie</groupId>
|
||||
<artifactId>Mp-Week2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bwie-module</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>
|
|
@ -0,0 +1,68 @@
|
|||
<?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>Mp-Week2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>bwie-common</module>
|
||||
<module>bwie-module</module>
|
||||
<module>bwie-module/bwie-expressage</module>
|
||||
<module>bwie-gateway</module>
|
||||
<module>bwie-module/bwie-user</module>
|
||||
<module>bwie-auth</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>
|
||||
<!-- 规定SpringBoot版本 -->
|
||||
<!-- 父级pom文件 主要用于规定项目依赖的各个版本,用于进行项目版本约束 -->
|
||||
<parent>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<version>2.7.15</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<!-- 依赖声明 -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- SpringCloud 微服务 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>2021.0.8</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba 微服务 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>2021.0.5.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- Alibaba Nacos 配置 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
<version>2.0.4</version>
|
||||
</dependency>
|
||||
<!-- 系统公共 依赖 版本号定义-->
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>bwie-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
Loading…
Reference in New Issue