feat(新增): 🚀 更新包和修改多数据源问题
This commit is contained in:
parent
0d218cd7ba
commit
157d40a48e
|
@ -17,6 +17,15 @@
|
|||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>dao</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
|
@ -30,12 +39,7 @@
|
|||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
<!-- fastjson2 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
</dependency>
|
||||
<!--mysql-->
|
||||
<!-- mysql连接驱动 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
|
|
|
@ -17,15 +17,6 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>dao</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- 解决 javax.xml.bind 错误 -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
|
|
|
@ -30,9 +30,11 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
|
|||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
log.info("WebMvcConfiguration===>开始注册自定义拦截器...");
|
||||
// log.info("WebMvcConfiguration===>开始注册自定义拦截器...");
|
||||
|
||||
String[] excludeList = {"/api/checkCode", "/api/sendEmailCode", "/api/register", "/api/login",};
|
||||
// TODO Spring Security 和这个拦截器任选一个
|
||||
String[] excludeList = {"/", "/test/**", "/*.html", "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico",
|
||||
"/swagger-resources/**", "/swagger-ui.html/**", "/admin/login", "/v3/**", "/api/**"};
|
||||
registry.addInterceptor(userTokenInterceptor).excludePathPatterns(excludeList);
|
||||
|
||||
// TODO 如果想使用普通JWT可以使用这个,不使用 SpringSecurity6
|
||||
|
|
|
@ -33,6 +33,11 @@
|
|||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- fastjson2 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
</dependency>
|
||||
<!-- 实体类注解 -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
|
|
|
@ -88,8 +88,8 @@ public class WebSecurityConfig {
|
|||
// 排出鉴定路径
|
||||
@Bean
|
||||
public WebSecurityCustomizer webSecurityCustomizer() {
|
||||
String[] annotations = {"/", "/test/**", "/*.html", "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", "/swagger-resources/**", "/swagger-ui.html/**",
|
||||
"/api/**"
|
||||
String[] annotations = {"/", "/test/**", "/admin/login", "/*.html", "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico",
|
||||
"/swagger-resources/**", "/swagger-ui.html/**", "/v3/**", "/api/**"
|
||||
};
|
||||
return web -> web.ignoring().requestMatchers(annotations);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.bunny.service.service.impl;
|
||||
|
||||
import cn.bunny.common.service.exception.BunnyException;
|
||||
import cn.bunny.common.service.utils.EmptyUtil;
|
||||
import cn.bunny.common.service.utils.JwtHelper;
|
||||
import cn.bunny.dto.user.LoginDto;
|
||||
|
@ -23,6 +24,7 @@ import cn.hutool.captcha.CaptchaUtil;
|
|||
import cn.hutool.captcha.CircleCaptcha;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springdoc.core.service.OperationService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
@ -51,6 +53,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||
private EmailUsersMapper emailUsersMapper;
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@Autowired
|
||||
private OperationService operationBuilder;
|
||||
|
||||
/**
|
||||
* 前台用户登录接口
|
||||
|
@ -68,6 +72,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||
String password = DigestUtils.md5DigestAsHex(loginDto.getPassword().getBytes());
|
||||
// 查询数据库,用户对应的角色、权限
|
||||
User user = baseMapper.login(username, password);
|
||||
|
||||
if (user == null) {
|
||||
throw new BunnyException(ExceptionConstant.USER_NOT_FOUND_Exception);
|
||||
}
|
||||
|
||||
Long userId = user.getId();
|
||||
|
||||
// 查询用户所有的角色信息
|
||||
|
|
|
@ -7,9 +7,9 @@ bunny:
|
|||
password: "02120212"
|
||||
|
||||
redis:
|
||||
host: 1192.168.3.100
|
||||
host: 192.168.3.100
|
||||
port: 6379
|
||||
database: 3
|
||||
database: 0
|
||||
password: "123456"
|
||||
|
||||
minio:
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
bunny:
|
||||
datasource:
|
||||
host: 192.168.1.4
|
||||
host: 192.168.3.100
|
||||
port: 3306
|
||||
sqlData: bunny_docs
|
||||
username: root
|
||||
password: "02120212"
|
||||
|
||||
redis:
|
||||
host: 192.168.1.4
|
||||
host: 192.168.3.100
|
||||
port: 6379
|
||||
database: 3
|
||||
database: 0
|
||||
password: "123456"
|
||||
|
||||
minio:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
server:
|
||||
port: 8800
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
|
@ -8,28 +8,24 @@ spring:
|
|||
name: bunny-service
|
||||
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
||||
username: ${bunny.datasource.username}
|
||||
password: ${bunny.datasource.password}
|
||||
# dynamic:
|
||||
# primary: master #设置默认的数据源或者数据源组,默认值即为master
|
||||
# strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
|
||||
# grace-destroy: false #是否优雅关闭数据源,默认为false,设置为true时,关闭数据源时如果数据源中还存在活跃连接,至多等待10s后强制关闭
|
||||
# datasource:
|
||||
# master:
|
||||
# driver-class-name: com.zaxxer.hikari.HikariDataSource
|
||||
# url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
||||
# username: ${bunny.datasource.username}
|
||||
# password: ${bunny.datasource.password}
|
||||
# i18n:
|
||||
# url: jdbc:mysql://${bunny.datasource2.host}:${bunny.datasource2.port}/${bunny.datasource2.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
||||
# username: ${bunny.datasource2.username}
|
||||
# password: ${bunny.datasource2.password}
|
||||
# driver-class-name: com.zaxxer.hikari.HikariDataSource
|
||||
# aop:
|
||||
# enabled: true
|
||||
# type: com.zaxxer.hikari.HikariDataSource
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
||||
# username: ${bunny.datasource.username}
|
||||
# password: ${bunny.datasource.password}
|
||||
dynamic:
|
||||
primary: master #设置默认的数据源或者数据源组,默认值即为master
|
||||
strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
|
||||
grace-destroy: false #是否优雅关闭数据源,默认为false,设置为true时,关闭数据源时如果数据源中还存在活跃连接,至多等待10s后强制关闭
|
||||
datasource:
|
||||
master:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
||||
username: ${bunny.datasource.username}
|
||||
password: ${bunny.datasource.password}
|
||||
aop:
|
||||
enabled: true
|
||||
|
||||
data:
|
||||
redis:
|
||||
|
|
Loading…
Reference in New Issue