Compare commits
No commits in common. "master" and "dev.car.gateway" have entirely different histories.
master
...
dev.car.ga
|
@ -16,6 +16,12 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.muyu</groupId>-->
|
||||||
|
<!-- <artifactId>cloud-common-saas</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
@ -34,6 +40,7 @@
|
||||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- SpringBoot Web -->
|
<!-- SpringBoot Web -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -58,6 +65,50 @@
|
||||||
<artifactId>cloud-common-api-doc</artifactId>
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
</dependency>
|
</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>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package com.muyu.auth;
|
package com.muyu.auth;
|
||||||
|
|
||||||
|
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||||
|
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||||
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
@ -10,10 +13,18 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
@SpringBootApplication(
|
||||||
|
exclude = {
|
||||||
|
DataSourceAutoConfiguration.class,
|
||||||
|
DruidDataSourceAutoConfigure.class,
|
||||||
|
DynamicDataSourceAutoConfiguration.class
|
||||||
|
}
|
||||||
|
)
|
||||||
public class CloudAuthApplication {
|
public class CloudAuthApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(CloudAuthApplication.class, args);
|
SpringApplication.run(CloudAuthApplication.class, args);
|
||||||
|
System.out.println("CloudAuth 模块启动成功!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,11 @@ import com.muyu.common.security.auth.AuthUtil;
|
||||||
import com.muyu.common.security.service.TokenService;
|
import com.muyu.common.security.service.TokenService;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
@ -25,16 +29,20 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
public class TokenController {
|
public class TokenController {
|
||||||
@Autowired
|
|
||||||
|
@Resource
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
||||||
private SysLoginService sysLoginService;
|
private SysLoginService sysLoginService;
|
||||||
|
|
||||||
@PostMapping("login")
|
@PostMapping("login")
|
||||||
public Result<?> login (@RequestBody LoginBody form) {
|
public Result<?> login (@RequestBody LoginBody form) {
|
||||||
// 用户登录
|
// 用户登录
|
||||||
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
|
||||||
|
LoginUser userInfo = sysLoginService.login(form);
|
||||||
|
|
||||||
// 获取登录token
|
// 获取登录token
|
||||||
return Result.success(tokenService.createToken(userInfo));
|
return Result.success(tokenService.createToken(userInfo));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
package com.muyu.auth.form;
|
package com.muyu.auth.form;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登录对象
|
* 用户登录对象
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
public class LoginBody {
|
public class LoginBody {
|
||||||
|
|
||||||
|
private String firmCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名
|
* 用户名
|
||||||
*/
|
*/
|
||||||
|
@ -16,6 +26,8 @@ public class LoginBody {
|
||||||
*/
|
*/
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getUsername () {
|
public String getUsername () {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
@ -24,11 +36,5 @@ public class LoginBody {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword () {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword (String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.auth.service;
|
package com.muyu.auth.service;
|
||||||
|
|
||||||
|
import com.muyu.auth.form.LoginBody;
|
||||||
import com.muyu.common.core.constant.CacheConstants;
|
import com.muyu.common.core.constant.CacheConstants;
|
||||||
import com.muyu.common.core.constant.Constants;
|
import com.muyu.common.core.constant.Constants;
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
|
@ -12,12 +13,15 @@ import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.utils.ip.IpUtils;
|
import com.muyu.common.core.utils.ip.IpUtils;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.remote.RemoteUserService;
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.remote.RemoteSaasService;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录校验方法
|
* 登录校验方法
|
||||||
*
|
*
|
||||||
|
@ -25,24 +29,30 @@ import org.springframework.stereotype.Component;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SysLoginService {
|
public class SysLoginService {
|
||||||
@Autowired
|
@Resource
|
||||||
private RemoteUserService remoteUserService;
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private SysPasswordService passwordService;
|
private SysPasswordService passwordService;
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private SysRecordLogService recordLogService;
|
private SysRecordLogService recordLogService;
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RemoteSaasService remoteSaasService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*/
|
*/
|
||||||
public LoginUser login (String username, String password) {
|
public LoginUser login (LoginBody form) {
|
||||||
|
String firmCode = form.getFirmCode();
|
||||||
|
String username = form.getUsername();
|
||||||
|
String password = form.getPassword();
|
||||||
// 用户名或密码为空 错误
|
// 用户名或密码为空 错误
|
||||||
if (StringUtils.isAnyBlank(username, password)) {
|
if (StringUtils.isAnyBlank(firmCode, username, password)) {
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
||||||
throw new ServiceException("用户/密码必须填写");
|
throw new ServiceException("用户/密码必须填写");
|
||||||
}
|
}
|
||||||
|
@ -65,8 +75,7 @@ public class SysLoginService {
|
||||||
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
||||||
}
|
}
|
||||||
// 查询用户信息
|
// 查询用户信息
|
||||||
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
Result<LoginUser> userResult = remoteUserService.getUserInfo(firmCode, username, SecurityConstants.INNER);
|
||||||
|
|
||||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
|
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
throw new ServiceException("登录用户:" + username + " 不存在");
|
||||||
|
@ -76,8 +85,8 @@ public class SysLoginService {
|
||||||
throw new ServiceException(userResult.getMsg());
|
throw new ServiceException(userResult.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginUser userInfo = userResult.getData();
|
LoginUser loginUser = userResult.getData();
|
||||||
SysUser user = userResult.getData().getSysUser();
|
SysUser user = loginUser.getSysUser();
|
||||||
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||||
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
||||||
|
@ -88,7 +97,8 @@ public class SysLoginService {
|
||||||
}
|
}
|
||||||
passwordService.validate(user, password);
|
passwordService.validate(user, password);
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||||
return userInfo;
|
|
||||||
|
return loginUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logout (String loginName) {
|
public void logout (String loginName) {
|
||||||
|
|
|
@ -6,7 +6,11 @@ import com.muyu.common.core.exception.ServiceException;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -18,14 +22,22 @@ import java.util.concurrent.TimeUnit;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SysPasswordService {
|
public class SysPasswordService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
|
private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
|
||||||
|
|
||||||
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
|
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
||||||
private SysRecordLogService recordLogService;
|
private SysRecordLogService recordLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,11 @@ import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.utils.ip.IpUtils;
|
import com.muyu.common.core.utils.ip.IpUtils;
|
||||||
import com.muyu.common.system.remote.RemoteLogService;
|
import com.muyu.common.system.remote.RemoteLogService;
|
||||||
import com.muyu.common.system.domain.SysLogininfor;
|
import com.muyu.common.system.domain.SysLogininfor;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +20,11 @@ import org.springframework.stereotype.Component;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SysRecordLogService {
|
public class SysRecordLogService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
||||||
private RemoteLogService remoteLogService;
|
private RemoteLogService remoteLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,10 +4,14 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: nacos.muyu.icu:8848
|
addr: 106.54.193.225:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: muyu-cloud
|
|
||||||
|
namespace: one-saas
|
||||||
|
|
||||||
|
namespace: one
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
|
@ -40,8 +44,15 @@ spring:
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
|
|
||||||
|
# 系统环境Config共享配置
|
||||||
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# 系统共享配置
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
|
||||||
# 系统共享配置
|
# 系统共享配置
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
# 系统环境Config共享配置
|
# 系统环境Config共享配置
|
||||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.yulichang</groupId>
|
||||||
|
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||||
|
<version>1.4.11</version>
|
||||||
|
</dependency>
|
||||||
<!-- SpringCloud Openfeign -->
|
<!-- SpringCloud Openfeign -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
@ -164,6 +169,13 @@
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.2.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -45,4 +45,11 @@ public class SecurityConstants {
|
||||||
* 角色权限
|
* 角色权限
|
||||||
*/
|
*/
|
||||||
public static final String ROLE_PERMISSION = "role_permission";
|
public static final String ROLE_PERMISSION = "role_permission";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SAAS请求头的key
|
||||||
|
*/
|
||||||
|
public static final String SAAS_KEY = "ent-code";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,14 @@ public class ServiceNameConstants {
|
||||||
* 文件服务的serviceid
|
* 文件服务的serviceid
|
||||||
*/
|
*/
|
||||||
public static final String FILE_SERVICE = "cloud-file";
|
public static final String FILE_SERVICE = "cloud-file";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 智能车联服务
|
||||||
|
*/
|
||||||
|
public static final String SMART_SERVICE = "cloud-smart-car";
|
||||||
|
|
||||||
|
public static final String ENT_SERVICE = "cloud-ent";
|
||||||
|
|
||||||
|
public static final String SAAS_SERVICE = "cloud-system-saas";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,4 +80,14 @@ public class SecurityContextHolder {
|
||||||
public static void remove () {
|
public static void remove () {
|
||||||
THREAD_LOCAL.remove();
|
THREAD_LOCAL.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getSaasKey() {
|
||||||
|
return get(SecurityConstants.SAAS_KEY);
|
||||||
|
}
|
||||||
|
public static void setSaasKey(String saasKey) {
|
||||||
|
set(SecurityConstants.SAAS_KEY,saasKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ package com.muyu.common.core.exception;
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
public final class ServiceException extends RuntimeException {
|
public class ServiceException extends RuntimeException {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@ public final class ServiceException extends RuntimeException {
|
||||||
/**
|
/**
|
||||||
* 错误明细,内部调试错误
|
* 错误明细,内部调试错误
|
||||||
* <p>
|
* <p>
|
||||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
* 和 {CommonResult#getDetailMessage()} 一致的设计
|
||||||
*/
|
*/
|
||||||
private String detailMessage;
|
private String detailMessage;
|
||||||
|
|
||||||
|
|
|
@ -162,4 +162,17 @@ public class JwtUtils {
|
||||||
public static String getValue (Claims claims, String key) {
|
public static String getValue (Claims claims, String key) {
|
||||||
return Convert.toStr(claims.get(key), "");
|
return Convert.toStr(claims.get(key), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据身份信息获取SAASKey
|
||||||
|
*
|
||||||
|
* @param claims 身份信息
|
||||||
|
*
|
||||||
|
* @return saas_key
|
||||||
|
*/
|
||||||
|
public static String getSaasKey(Claims claims) {
|
||||||
|
return getValue(claims, SecurityConstants.SAAS_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,8 @@ public class IpUtils {
|
||||||
ip = request.getRemoteAddr();
|
ip = request.getRemoteAddr();
|
||||||
}
|
}
|
||||||
|
|
||||||
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : getMultistageReverseProxyIp(ip);
|
|
||||||
|
return "0:0:0:0:0:0:0:1".equals(ip) ? "106.54.193.225" : getMultistageReverseProxyIp(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +71,10 @@ public class IpUtils {
|
||||||
*/
|
*/
|
||||||
public static boolean internalIp (String ip) {
|
public static boolean internalIp (String ip) {
|
||||||
byte[] addr = textToNumericFormatV4(ip);
|
byte[] addr = textToNumericFormatV4(ip);
|
||||||
return internalIp(addr) || "127.0.0.1".equals(ip);
|
|
||||||
|
return internalIp(addr) || "106.54.193.225".equals(ip);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,7 +201,8 @@ public class IpUtils {
|
||||||
return InetAddress.getLocalHost().getHostAddress();
|
return InetAddress.getLocalHost().getHostAddress();
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
}
|
}
|
||||||
return "127.0.0.1";
|
|
||||||
|
return "106.54.193.225";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,7 +18,11 @@ import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.annotation.Before;
|
import org.aspectj.lang.annotation.Before;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import org.springframework.core.NamedThreadLocal;
|
import org.springframework.core.NamedThreadLocal;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -48,7 +52,11 @@ public class LogAspect {
|
||||||
*/
|
*/
|
||||||
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
|
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
||||||
private AsyncLogService asyncLogService;
|
private AsyncLogService asyncLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +90,7 @@ public class LogAspect {
|
||||||
|
|
||||||
protected void handleLog (final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
|
protected void handleLog (final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
|
||||||
try {
|
try {
|
||||||
// *========数据库日志=========*//
|
// *=数据库日志==*//
|
||||||
SysOperLog operLog = new SysOperLog();
|
SysOperLog operLog = new SysOperLog();
|
||||||
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
||||||
// 请求的地址
|
// 请求的地址
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.common.log.service;
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
import com.muyu.common.system.remote.RemoteLogService;
|
import com.muyu.common.system.remote.RemoteLogService;
|
||||||
import com.muyu.common.system.domain.SysOperLog;
|
import com.muyu.common.system.domain.SysOperLog;
|
||||||
|
import javax.annotation.Resource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
|
@ -32,4 +32,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.muyu.common.rabbit.callback;
|
||||||
|
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lenovo
|
||||||
|
* @Description 消息发送到broker确认回调
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class ConfirmCallback implements RabbitTemplate.ConfirmCallback {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化
|
||||||
|
*/
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
this.rabbitTemplate.setConfirmCallback(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回调确认方法(消息发送之后 消息无论发送成功还是失败都会执行这个回调方法)
|
||||||
|
* @param correlationData 回调的相关数据
|
||||||
|
* @param ack 确认结果(true表示消息已经被broker接收,false表示消息未被broker接收)
|
||||||
|
* @param cause 失败原因(当ack为false时,表示拒绝接收消息的原因;当ack为true时,该值为空)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
|
||||||
|
if (ack) {
|
||||||
|
log.info("消息发送到broker成功!");
|
||||||
|
} else {
|
||||||
|
log.info("消息发送到broker失败,失败原因:{}", cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.common.rabbit.callback;
|
||||||
|
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.core.ReturnedMessage;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lenovo
|
||||||
|
* @Description 消息发送失败时回调
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class ReturnsCallback implements RabbitTemplate.ReturnsCallback {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化
|
||||||
|
*/
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
rabbitTemplate.setReturnsCallback(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息发送到队列失败时执行
|
||||||
|
* @param returnedMessage 返回的消息和元数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void returnedMessage(ReturnedMessage returnedMessage) {
|
||||||
|
log.info("消息:{}被交换机:{}回退!回退原因:{}", returnedMessage.getMessage().toString(),
|
||||||
|
returnedMessage.getExchange(), returnedMessage.getReplyText());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package com.muyu.common.rabbit.config;
|
||||||
|
|
||||||
|
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||||
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lenovo
|
||||||
|
* @Description RabbitMQ连接和管理功能配置
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RabbitAdminConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RabbitMQ服务器的主机地址
|
||||||
|
*/
|
||||||
|
@Value("${spring.rabbitmq.host}")
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RabbitMQ的用户名
|
||||||
|
*/
|
||||||
|
@Value("${spring.rabbitmq.username}")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RabbitMQ的密码
|
||||||
|
*/
|
||||||
|
@Value("${spring.rabbitmq.password}")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RabbitMQ的虚拟主机
|
||||||
|
*/
|
||||||
|
@Value("${spring.rabbitmq.virtualhost}")
|
||||||
|
private String virtualhost;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建并初始化RabbitAdmin实例
|
||||||
|
*
|
||||||
|
* @return RabbitAdmin 实例
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public RabbitAdmin rabbitAdmin() {
|
||||||
|
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory());
|
||||||
|
rabbitAdmin.setAutoStartup(true);
|
||||||
|
return rabbitAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建RabbitMQ连接工厂
|
||||||
|
*
|
||||||
|
* @return ConnectionFactory 实例
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ConnectionFactory connectionFactory() {
|
||||||
|
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
|
||||||
|
connectionFactory.setAddresses(host);
|
||||||
|
connectionFactory.setUsername(username);
|
||||||
|
connectionFactory.setPassword(password);
|
||||||
|
connectionFactory.setVirtualHost(virtualhost);
|
||||||
|
|
||||||
|
// 配置发送确认回调时,次配置必须配置,否则即使在RabbitTemplate配置了ConfirmCallback也不会生效
|
||||||
|
connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
|
||||||
|
connectionFactory.setPublisherReturns(true);
|
||||||
|
return connectionFactory;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.muyu.common.rabbit.config;
|
||||||
|
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer;
|
||||||
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||||
|
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
|
||||||
|
import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lenovo
|
||||||
|
* @Description rabbitMQ的监听器配置
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RabbitListenerConfig implements RabbitListenerConfigurer {
|
||||||
|
|
||||||
|
static {
|
||||||
|
// 设置为信任所有类型的反序列化,确保消息能够正确反序列化
|
||||||
|
System.setProperty("spring.amqp.deserialization.trust.all", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RabbitMQ连接工厂,用于创建连接
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
public ConnectionFactory connectionFactory;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建处理器方法工厂的bean
|
||||||
|
*
|
||||||
|
* @return DefaultMessageHandlerMethodFactory 实例,用于处理消息的转换和方法调用
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public DefaultMessageHandlerMethodFactory handlerMethodFactory() {
|
||||||
|
DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
|
||||||
|
// 这里的转换器设置实现了 通过 @Payload 注解 自动反序列化message body
|
||||||
|
factory.setMessageConverter(new MappingJackson2MessageConverter());
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置RabbitMQ监听器的消息处理方法工厂。
|
||||||
|
*
|
||||||
|
* @param rabbitListenerEndpointRegistrar 实例,用于注册监听器的配置
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void configureRabbitListeners(RabbitListenerEndpointRegistrar rabbitListenerEndpointRegistrar) {
|
||||||
|
// 注册自定义的消息处理方法工厂
|
||||||
|
rabbitListenerEndpointRegistrar.setMessageHandlerMethodFactory(handlerMethodFactory());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
package com.muyu.common.rabbit.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lenovo
|
||||||
|
* @Description rabbitMQ消息转换器配置
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RabbitMQMessageConverterConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息转换配置
|
||||||
|
*
|
||||||
|
* @return 消息转换器
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public MessageConverter jsonMessageConverter() {
|
||||||
|
return new Jackson2JsonMessageConverter();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +1,7 @@
|
||||||
|
|
||||||
|
com.muyu.common.rabbit.config.RabbitListenerConfig
|
||||||
|
com.muyu.common.rabbit.config.RabbitAdminConfig
|
||||||
|
com.muyu.common.rabbit.config.RabbitMQMessageConverterConfig
|
||||||
|
|
||||||
com.muyu.common.rabbit.RabbitListenerConfigurer
|
com.muyu.common.rabbit.RabbitListenerConfigurer
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.common.redis.service;
|
package com.muyu.common.redis.service;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.BoundSetOperations;
|
import org.springframework.data.redis.core.BoundSetOperations;
|
||||||
import org.springframework.data.redis.core.HashOperations;
|
import org.springframework.data.redis.core.HashOperations;
|
||||||
|
@ -7,6 +8,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.core.ValueOperations;
|
import org.springframework.data.redis.core.ValueOperations;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -18,7 +20,11 @@ import java.util.concurrent.TimeUnit;
|
||||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||||
@Component
|
@Component
|
||||||
public class RedisService {
|
public class RedisService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
||||||
public RedisTemplate redisTemplate;
|
public RedisTemplate redisTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?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.muyu</groupId>
|
||||||
|
<artifactId>cloud-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>cloud-common-saas</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.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 鉴权依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.muyu.cloud.common.many.datasource;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||||
|
import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
||||||
|
import com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory;
|
||||||
|
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
|
||||||
|
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
|
||||||
|
import com.muyu.cloud.common.saas.exception.SaaSException;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.SpringUtils;
|
||||||
|
import com.muyu.common.system.domain.SysEnt;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/6/3
|
||||||
|
* @Description: 多数据源
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@AutoConfiguration(before = {MybatisPlusAutoConfiguration.class, MybatisAutoConfiguration.class})
|
||||||
|
@Component
|
||||||
|
public class ManyDataSource implements ApplicationRunner{
|
||||||
|
|
||||||
|
|
||||||
|
private List<EntInfo> dataSourceInfoList(){
|
||||||
|
RemoteUserService remoteUserService = SpringUtils.getBean(RemoteUserService.class);
|
||||||
|
Result<List<SysEnt>> listResult = remoteUserService.list(new SysEnt());
|
||||||
|
if (listResult==null){
|
||||||
|
throw new SaaSException("saas远调数据源错误");
|
||||||
|
}
|
||||||
|
List<SysEnt> data = listResult.getData();
|
||||||
|
System.out.println(data);
|
||||||
|
if (listResult.getCode() == Result.SUCCESS && data !=null){
|
||||||
|
List<EntInfo> list = new ArrayList<>();
|
||||||
|
for (SysEnt row : data) {
|
||||||
|
list.add(
|
||||||
|
EntInfo.builder()
|
||||||
|
.entCode(row.getEntCode())
|
||||||
|
.dbName(row.getDbName())
|
||||||
|
.ip(row.getIp())
|
||||||
|
.port(row.getPort())
|
||||||
|
.userName(row.getUserName())
|
||||||
|
.password(row.getPassword())
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}else {
|
||||||
|
log.error("远调数据源错误,远调数据为:{}", JSON.toJSONString(listResult));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
||||||
|
// 企业列表 企业CODE,端口,IP
|
||||||
|
Map<Object, Object> dataSourceMap = new HashMap<>();
|
||||||
|
Objects.requireNonNull(dataSourceInfoList())
|
||||||
|
.stream()
|
||||||
|
.map(DataSourceInfo::hostAndPortBuild)
|
||||||
|
.forEach(dataSourceInfo -> {
|
||||||
|
dataSourceMap.put(dataSourceInfo.getKey(), druidDataSourceFactory.create(dataSourceInfo));
|
||||||
|
});
|
||||||
|
//设置动态数据源
|
||||||
|
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||||
|
// dynamicDataSource.setDefaultTargetDataSource(masterDataSource());
|
||||||
|
dynamicDataSource.setTargetDataSources(dataSourceMap);
|
||||||
|
//将数据源信息备份在defineTargetDataSources中
|
||||||
|
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
||||||
|
log.info("动态数据源加载完成,持有key:{}",dynamicDataSource.getKeys());
|
||||||
|
return dynamicDataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) {
|
||||||
|
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
|
||||||
|
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
||||||
|
for (EntInfo entInfo : dataSourceInfoList()) {
|
||||||
|
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entInfo);
|
||||||
|
DruidDataSource druidDataSource = druidDataSourceFactory.create(dataSourceInfo);
|
||||||
|
dynamicDataSource.put(dataSourceInfo.getKey(), druidDataSource);
|
||||||
|
log.info("存储数据连接池为:key:{}",dataSourceInfo.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Bean
|
||||||
|
// public SqlSessionFactory sqlSessionFactory(DynamicDataSource dataSource) throws Exception {
|
||||||
|
// SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
||||||
|
// sessionFactory.setDataSource(dataSource);
|
||||||
|
// return sessionFactory.getObject();
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.cloud.common.many.datasource.constents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 数据源常量
|
||||||
|
* @Date 2023-8-1 上午 11:02
|
||||||
|
*/
|
||||||
|
public class DatasourceContent {
|
||||||
|
|
||||||
|
public final static String DATASOURCE_URL = "jdbc:mysql://{}:{}/{}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
||||||
|
|
||||||
|
public final static String USER_NAME = "root";
|
||||||
|
|
||||||
|
public final static String PASSWORD = "bawei2112A";
|
||||||
|
|
||||||
|
public final static String IP = "106.54.193.225";
|
||||||
|
|
||||||
|
public final static Integer PORT = 3306;
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.muyu.cloud.common.many.datasource.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
|
||||||
|
import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 数据源实体类
|
||||||
|
* @Date 2023-8-1 上午 11:15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DataSourceInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 键
|
||||||
|
*/
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
|
||||||
|
// public static DataSourceInfo hostAndPortBuild(String key, String host, Integer port) {
|
||||||
|
// return DataSourceInfo.builder()
|
||||||
|
// .key(key)
|
||||||
|
// .url(StringUtils.format(DatasourceContent.DATASOURCE_URL, host, port, key))
|
||||||
|
// .password(DatasourceContent.PASSWORD)
|
||||||
|
// .userName(DatasourceContent.USER_NAME)
|
||||||
|
// .build();
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static DataSourceInfo hostAndPortBuild(EntInfo entInfo) {
|
||||||
|
return DataSourceInfo.builder()
|
||||||
|
.key(entInfo.getEntCode())
|
||||||
|
.url(StringUtils.format(DatasourceContent.DATASOURCE_URL, entInfo.getIp(), entInfo.getPort(), entInfo.getDbName()))
|
||||||
|
.userName(entInfo.getUserName())
|
||||||
|
.password(entInfo.getPassword())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.muyu.cloud.common.many.datasource.factory;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/6/3
|
||||||
|
* @Description: Druid工厂
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
public class DruidDataSourceFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 根据传递的数据源信息测试数据库连接
|
||||||
|
* @Author Dongzl
|
||||||
|
*/
|
||||||
|
public DruidDataSource create(DataSourceInfo dataSourceInfo) {
|
||||||
|
DruidDataSource druidDataSource = new DruidDataSource();
|
||||||
|
druidDataSource.setUrl(dataSourceInfo.getUrl());
|
||||||
|
druidDataSource.setConnectTimeout(10000);
|
||||||
|
druidDataSource.setUsername(dataSourceInfo.getUserName());
|
||||||
|
druidDataSource.setPassword(dataSourceInfo.getPassword());
|
||||||
|
druidDataSource.setBreakAfterAcquireFailure(true);
|
||||||
|
druidDataSource.setConnectionErrorRetryAttempts(0);
|
||||||
|
try {
|
||||||
|
druidDataSource.getConnection(2000);
|
||||||
|
log.info("{} -> 数据源连接成功", dataSourceInfo.getKey());
|
||||||
|
return druidDataSource;
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
log.error("数据源 {} 连接失败,用户名:{},密码 {}, 原因:{}",dataSourceInfo.getUrl(),dataSourceInfo.getUserName(),dataSourceInfo.getPassword(), throwables);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.muyu.cloud.common.many.datasource.holder;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据源切换处理
|
||||||
|
*
|
||||||
|
* @author Dongzl
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class DynamicDataSourceHolder {
|
||||||
|
/**
|
||||||
|
* 保存动态数据源名称
|
||||||
|
*/
|
||||||
|
private static final ThreadLocal<String> DYNAMIC_DATASOURCE_KEY = new ThreadLocal<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置/切换数据源,决定当前线程使用哪个数据源
|
||||||
|
*/
|
||||||
|
public static void setDynamicDataSourceKey(String key){
|
||||||
|
log.info("数据源切换为:{}",key);
|
||||||
|
DYNAMIC_DATASOURCE_KEY.set(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取动态数据源名称,默认使用mater数据源
|
||||||
|
*/
|
||||||
|
public static String getDynamicDataSourceKey(){
|
||||||
|
String key = DYNAMIC_DATASOURCE_KEY.get();
|
||||||
|
Assert.notNull(key, "请携带数据标识");
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除当前数据源
|
||||||
|
*/
|
||||||
|
public static void removeDynamicDataSourceKey(){
|
||||||
|
log.info("移除数据源:{}",DYNAMIC_DATASOURCE_KEY.get());
|
||||||
|
DYNAMIC_DATASOURCE_KEY.remove();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.muyu.cloud.common.many.datasource.role;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态数据源
|
||||||
|
* 调用AddDefineDataSource组件的addDefineDynamicDataSource()方法,获取原来targetdatasources的map,并将新的数据源信息添加到map中,并替换targetdatasources中的map
|
||||||
|
* 切换数据源时可以使用@DataSource(value = "数据源名称"),或者DynamicDataSourceContextHolder.setContextKey("数据源名称")
|
||||||
|
* @author Dongzl
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@Slf4j
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DynamicDataSource extends AbstractRoutingDataSource {
|
||||||
|
/**
|
||||||
|
* 备份所有数据源信息 备份的是个 指针 !!!
|
||||||
|
*/
|
||||||
|
private Map<Object, Object> defineTargetDataSources;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判定键是否出站了
|
||||||
|
* @param key 键
|
||||||
|
* @return 存在结果 true存在 false不存在
|
||||||
|
*/
|
||||||
|
public boolean hashKey(String key){
|
||||||
|
return defineTargetDataSources.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加数据库
|
||||||
|
* @param key 键
|
||||||
|
* @param value 数据源
|
||||||
|
*/
|
||||||
|
public void put(String key, DruidDataSource value) {
|
||||||
|
if (value!=null) {
|
||||||
|
defineTargetDataSources.put(key, value);
|
||||||
|
this.afterPropertiesSet();
|
||||||
|
}else{
|
||||||
|
log.warn("Key为 {} 的数据源为空!",key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 决定当前线程使用哪个数据源
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Object determineCurrentLookupKey() {
|
||||||
|
return DynamicDataSourceHolder.getDynamicDataSourceKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Object> getKeys() {
|
||||||
|
return defineTargetDataSources.keySet().stream().toList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.muyu.cloud.common.saas.contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/6/3
|
||||||
|
* @Description: SAAS常量
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class SaaSConstant {
|
||||||
|
|
||||||
|
public final static String SAAS_KEY = "ent-code";
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.muyu.cloud.common.saas.domain.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/6/3
|
||||||
|
* @Description: 企业信息
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EntInfo {
|
||||||
|
|
||||||
|
private String entCode;
|
||||||
|
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
private Integer port;
|
||||||
|
|
||||||
|
private String dbName;
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.muyu.cloud.common.saas.exception;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/6/3
|
||||||
|
* @Description: SaaS异常类
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class SaaSException extends ServiceException {
|
||||||
|
|
||||||
|
public SaaSException (String message, Integer code) {
|
||||||
|
super(message, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SaaSException (String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 空构造方法,避免反序列化问题
|
||||||
|
*/
|
||||||
|
public SaaSException () {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.muyu.cloud.common.saas.interceptor;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.muyu.cloud.common.saas.contents.SaaSConstant;
|
||||||
|
import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
|
||||||
|
import com.muyu.cloud.common.saas.exception.SaaSException;
|
||||||
|
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
|
||||||
|
import com.muyu.common.core.context.SecurityContextHolder;
|
||||||
|
import com.muyu.common.core.utils.ServletUtils;
|
||||||
|
import com.muyu.common.core.utils.SpringUtils;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/6/3
|
||||||
|
* @Description: SAAS拦截器
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class SaaSInterceptor implements AsyncHandlerInterceptor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 之前
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean preHandle (HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
if (!(handler instanceof HandlerMethod)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String saasKey = ServletUtils.getHeader(request, SaaSConstant.SAAS_KEY);
|
||||||
|
log.info("访问路径:{},携带SaaSKey:{}",request.getRequestURI(),saasKey);
|
||||||
|
if (saasKey == null) {
|
||||||
|
throw new SaaSException("SaaS非法访问");
|
||||||
|
}else {
|
||||||
|
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
||||||
|
if (!dynamicDataSource.hashKey(saasKey)){
|
||||||
|
throw new SaaSException("SaaS非法访问");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DynamicDataSourceHolder.setDynamicDataSourceKey(saasKey);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 之后
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void afterConcurrentHandlingStarted (HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.muyu.cloud.common.saas.interceptor;
|
||||||
|
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拦截器配置
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
*/
|
||||||
|
public class WebMvcSaaSConfig implements WebMvcConfigurer {
|
||||||
|
/**
|
||||||
|
* 不需要拦截的地址
|
||||||
|
*/
|
||||||
|
public static final String[] EXCLUDE_URLS = {"/user/info", "/login", "/logout", "/refresh"};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors (InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(getHeaderInterceptor())
|
||||||
|
.addPathPatterns("/**")
|
||||||
|
.excludePathPatterns(EXCLUDE_URLS)
|
||||||
|
.order(-10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义请求头拦截器
|
||||||
|
*/
|
||||||
|
public SaaSInterceptor getHeaderInterceptor () {
|
||||||
|
return new SaaSInterceptor();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
com.muyu.cloud.common.saas.interceptor.WebMvcSaaSConfig
|
||||||
|
com.muyu.cloud.common.many.datasource.ManyDataSource
|
||||||
|
com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory
|
|
@ -28,6 +28,10 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
SecurityContextHolder.setUserId(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USER_ID));
|
SecurityContextHolder.setUserId(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USER_ID));
|
||||||
|
|
||||||
|
SecurityContextHolder.setSaasKey(ServletUtils.getHeader(request, SecurityConstants.SAAS_KEY));
|
||||||
|
|
||||||
|
|
||||||
SecurityContextHolder.setUserName(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USERNAME));
|
SecurityContextHolder.setUserName(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USERNAME));
|
||||||
SecurityContextHolder.setUserKey(ServletUtils.getHeader(request, SecurityConstants.USER_KEY));
|
SecurityContextHolder.setUserKey(ServletUtils.getHeader(request, SecurityConstants.USER_KEY));
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
@ -34,7 +34,7 @@ public class TokenService {
|
||||||
private final static long expireTime = CacheConstants.EXPIRATION;
|
private final static long expireTime = CacheConstants.EXPIRATION;
|
||||||
|
|
||||||
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
|
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
|
||||||
@Autowired
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,10 +55,11 @@ public class TokenService {
|
||||||
claimsMap.put(SecurityConstants.USER_KEY, token);
|
claimsMap.put(SecurityConstants.USER_KEY, token);
|
||||||
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
||||||
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
||||||
|
claimsMap.put(SecurityConstants.SAAS_KEY,loginUser.getSysUser().getFirmCode());
|
||||||
// 接口返回信息
|
// 接口返回信息
|
||||||
Map<String, Object> rspMap = new HashMap<String, Object>();
|
Map<String, Object> rspMap = new HashMap<String, Object>();
|
||||||
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
||||||
|
rspMap.put("ent_code", loginUser.getSysUser().getFirmCode());
|
||||||
rspMap.put("expires_in", expireTime);
|
rspMap.put("expires_in", expireTime);
|
||||||
return rspMap;
|
return rspMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,13 @@ public class SecurityUtils {
|
||||||
return SecurityContextHolder.getUserName();
|
return SecurityContextHolder.getUserName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getSaasKey () {
|
||||||
|
return SecurityContextHolder.getSaasKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户key
|
* 获取用户key
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -63,4 +63,9 @@ public class LoginUser implements Serializable {
|
||||||
*/
|
*/
|
||||||
private SysUser sysUser;
|
private SysUser sysUser;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,11 @@ public class SysDept extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
|
|
||||||
|
private String firmCode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 祖级列表
|
* 祖级列表
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/6/3
|
||||||
|
* @Description: 企业信息
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("sys_ent")
|
||||||
|
public class SysEnt {
|
||||||
|
@TableId( type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String entCode;
|
||||||
|
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
private Integer port;
|
||||||
|
|
||||||
|
private String dbName;
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author WangXin
|
||||||
|
* @Data 2024/9/18
|
||||||
|
* @Description 企业用户
|
||||||
|
* @Version 1.0.0
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SysFirmUser extends SysUser {
|
||||||
|
/**
|
||||||
|
* 用户数据库
|
||||||
|
*/
|
||||||
|
private String databaseName;
|
||||||
|
}
|
|
@ -36,6 +36,11 @@ public class SysRole extends BaseEntity {
|
||||||
@Excel(name = "角色名称")
|
@Excel(name = "角色名称")
|
||||||
private String roleName;
|
private String roleName;
|
||||||
|
|
||||||
|
|
||||||
|
private String firmCode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色权限
|
* 角色权限
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package com.muyu.common.system.domain;
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||||
import com.muyu.common.core.annotation.Excel.Type;
|
import com.muyu.common.core.annotation.Excel.Type;
|
||||||
|
@ -28,6 +31,7 @@ import java.util.List;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("sys_user")
|
||||||
public class SysUser extends BaseEntity {
|
public class SysUser extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -35,8 +39,11 @@ public class SysUser extends BaseEntity {
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
private Integer isAdmin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID
|
* 部门ID
|
||||||
*/
|
*/
|
||||||
|
@ -49,6 +56,9 @@ public class SysUser extends BaseEntity {
|
||||||
@Excel(name = "登录名称")
|
@Excel(name = "登录名称")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
|
||||||
|
private String firmCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户昵称
|
* 用户昵称
|
||||||
*/
|
*/
|
||||||
|
@ -135,6 +145,8 @@ public class SysUser extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public SysUser (Long userId) {
|
public SysUser (Long userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
@ -143,8 +155,9 @@ public class SysUser extends BaseEntity {
|
||||||
return userId != null && 1L == userId;
|
return userId != null && 1L == userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isAdmin () {
|
public boolean isAdmin () {
|
||||||
return isAdmin(this.userId);
|
return isAdmin(this.userId) || (this.isAdmin != null && this.isAdmin == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Xss(message = "用户昵称不能包含脚本字符")
|
@Xss(message = "用户昵称不能包含脚本字符")
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户和岗位关联 sys_user_post
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SysUserPost {
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 岗位ID
|
||||||
|
*/
|
||||||
|
private Long postId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户和角色关联 sys_user_role
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SysUserRole {
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色ID
|
||||||
|
*/
|
||||||
|
private Long roleId;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.common.system.remote;
|
||||||
|
|
||||||
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
|
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.remote.factory.RemoteSaasFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件服务
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteSaasService", value = ServiceNameConstants.SAAS_SERVICE, fallbackFactory = RemoteSaasFallbackFactory.class)
|
||||||
|
public interface RemoteSaasService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户名查询用户信息
|
||||||
|
*
|
||||||
|
* @param firmCode
|
||||||
|
* @param userName 用户名
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/user/info")
|
||||||
|
public Result<SysUser> getUserInfo (@RequestParam("firmCode") String firmCode, @RequestParam("userName") String userName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
}
|
|
@ -3,12 +3,23 @@ package com.muyu.common.system.remote;
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
|
||||||
|
import com.muyu.common.system.domain.*;
|
||||||
|
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户服务
|
* 用户服务
|
||||||
*
|
*
|
||||||
|
@ -16,6 +27,8 @@ import org.springframework.web.bind.annotation.*;
|
||||||
*/
|
*/
|
||||||
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
|
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
|
||||||
public interface RemoteUserService {
|
public interface RemoteUserService {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户信息
|
* 通过用户名查询用户信息
|
||||||
*
|
*
|
||||||
|
@ -27,6 +40,7 @@ public interface RemoteUserService {
|
||||||
@GetMapping("/user/info/{username}")
|
@GetMapping("/user/info/{username}")
|
||||||
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册用户信息
|
* 注册用户信息
|
||||||
*
|
*
|
||||||
|
@ -37,4 +51,76 @@ public interface RemoteUserService {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/user/register")
|
@PostMapping("/user/register")
|
||||||
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/user/companyList")
|
||||||
|
public Result<List<SysUser>> companyList ();
|
||||||
|
|
||||||
|
@PostMapping("/ent/list")
|
||||||
|
public Result<List<SysEnt>> list (@RequestBody SysEnt sysEnt);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户名查询用户信息
|
||||||
|
*
|
||||||
|
* @param firmCode
|
||||||
|
* @param userName 用户名
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/user/info")
|
||||||
|
public Result<LoginUser> getUserInfo (@RequestParam("firmCode") String firmCode, @RequestParam("userName") String userName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取角色数据权限
|
||||||
|
*
|
||||||
|
* @param user 用户
|
||||||
|
*
|
||||||
|
* @return 角色权限信息
|
||||||
|
*/
|
||||||
|
@PostMapping("/permission/getRole")
|
||||||
|
public Set<String> getRolePermission (@RequestBody SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单数据权限
|
||||||
|
*
|
||||||
|
* @param user 用户
|
||||||
|
*
|
||||||
|
* @return 菜单权限信息
|
||||||
|
*/
|
||||||
|
@PostMapping("/permission/getMenu")
|
||||||
|
public Set<String> getMenuPermission (@RequestBody SysUser user);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据部门编号获取详细信息
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/dept/{deptId}")
|
||||||
|
public Result<SysDept> selectDeptById (@PathVariable("deptId") Long deptId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户角色信息
|
||||||
|
*
|
||||||
|
* @param user 用户对象
|
||||||
|
*/
|
||||||
|
@PostMapping("/user/insertUserRole")
|
||||||
|
public void insertUserRole (@RequestBody SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户岗位信息
|
||||||
|
*
|
||||||
|
* @param user 用户对象
|
||||||
|
*/
|
||||||
|
@PostMapping("/user/insertUserPost")
|
||||||
|
public void insertUserPost (@RequestBody SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册用户
|
||||||
|
*/
|
||||||
|
@PostMapping("/user")
|
||||||
|
public Result addUser (@RequestBody SysUser user);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.common.system.remote.factory;
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: RemoteEntFallbackFactory
|
||||||
|
* @Description:
|
||||||
|
* @CreatedDate: 2024/9/20 下午3:11
|
||||||
|
* @FilePath: com.muyu.common.system.remote
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.remote.RemoteSaasService;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: RemoteEntFallbackFactory
|
||||||
|
* @Description:
|
||||||
|
* @CreatedDate: 2024/9/20 下午3:11
|
||||||
|
* @FilePath: com.muyu.common.system.remote
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteSaasFallbackFactory implements FallbackFactory<RemoteSaasService> {
|
||||||
|
@Override
|
||||||
|
public RemoteSaasService create(Throwable cause) {
|
||||||
|
return new RemoteSaasService() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<SysUser> getUserInfo(String firmCode, String username, String source) {
|
||||||
|
return Result.error("获取用户失败:" + cause.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,26 @@
|
||||||
package com.muyu.common.system.remote.factory;
|
package com.muyu.common.system.remote.factory;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.common.system.domain.*;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
|
|
||||||
import com.muyu.common.system.remote.RemoteUserService;
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户服务降级处理
|
* 用户服务降级处理
|
||||||
*
|
*
|
||||||
|
@ -22,15 +34,67 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
||||||
public RemoteUserService create (Throwable throwable) {
|
public RemoteUserService create (Throwable throwable) {
|
||||||
log.error("用户服务调用失败:{}", throwable.getMessage());
|
log.error("用户服务调用失败:{}", throwable.getMessage());
|
||||||
return new RemoteUserService() {
|
return new RemoteUserService() {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<LoginUser> getUserInfo (String username, String source) {
|
public Result<LoginUser> getUserInfo (String username, String source) {
|
||||||
return Result.error("获取用户失败:" + throwable.getMessage());
|
return Result.error("获取用户失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
|
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
|
||||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<SysUser>> companyList() {
|
||||||
|
return Result.error("获取企业列表失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<SysEnt>> list(SysEnt sysEnt) {
|
||||||
|
return Result.error("获取企业列表失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<LoginUser> getUserInfo(String firmCode, String userName, String source) {
|
||||||
|
return Result.error("获取用户信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getRolePermission(SysUser user) {
|
||||||
|
return Set.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getMenuPermission(SysUser user) {
|
||||||
|
return Set.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<SysDept> selectDeptById(Long deptId) {
|
||||||
|
return Result.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertUserRole(SysUser user) {
|
||||||
|
log.warn("新增用户角色失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertUserPost(SysUser user) {
|
||||||
|
log.warn("新增用户权限失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result addUser(SysUser user) {
|
||||||
|
return Result.error(throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
com.muyu.common.system.remote.factory.RemoteUserFallbackFactory
|
com.muyu.common.system.remote.factory.RemoteUserFallbackFactory
|
||||||
com.muyu.common.system.remote.factory.RemoteLogFallbackFactory
|
com.muyu.common.system.remote.factory.RemoteLogFallbackFactory
|
||||||
com.muyu.common.system.remote.factory.RemoteFileFallbackFactory
|
com.muyu.common.system.remote.factory.RemoteFileFallbackFactory
|
||||||
|
|
||||||
|
com.muyu.common.system.remote.factory.RemoteSaasFallbackFactory
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<module>cloud-common-system</module>
|
<module>cloud-common-system</module>
|
||||||
<module>cloud-common-xxl</module>
|
<module>cloud-common-xxl</module>
|
||||||
<module>cloud-common-rabbit</module>
|
<module>cloud-common-rabbit</module>
|
||||||
|
<module>cloud-common-saas</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>cloud-common</artifactId>
|
<artifactId>cloud-common</artifactId>
|
||||||
|
|
|
@ -82,6 +82,7 @@
|
||||||
<version>4.5.0</version>
|
<version>4.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -13,5 +13,9 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
public class CloudGatewayApplication {
|
public class CloudGatewayApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(CloudGatewayApplication.class, args);
|
SpringApplication.run(CloudGatewayApplication.class, args);
|
||||||
|
|
||||||
|
System.out.println("CloudGateway 模块启动成功!");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package com.muyu.gateway.config;
|
package com.muyu.gateway.config;
|
||||||
|
|
||||||
import com.muyu.gateway.handler.ValidateCodeHandler;
|
import com.muyu.gateway.handler.ValidateCodeHandler;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -16,7 +20,11 @@ import org.springframework.web.reactive.function.server.RouterFunctions;
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class RouterFunctionConfiguration {
|
public class RouterFunctionConfiguration {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
||||||
private ValidateCodeHandler validateCodeHandler;
|
private ValidateCodeHandler validateCodeHandler;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 参考 ModifyRequestBodyGatewayFilterFactory 中的方法 ==========
|
// === 参考 ModifyRequestBodyGatewayFilterFactory 中的方法 ===
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求装饰器,支持重新计算 headers、body 缓存
|
* 请求装饰器,支持重新计算 headers、body 缓存
|
||||||
|
@ -210,7 +210,7 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 参考 ModifyResponseBodyGatewayFilterFactory 中的方法 ==========
|
// === 参考 ModifyResponseBodyGatewayFilterFactory 中的方法 ===
|
||||||
|
|
||||||
private byte[] readContent(List<? extends DataBuffer> dataBuffers) {
|
private byte[] readContent(List<? extends DataBuffer> dataBuffers) {
|
||||||
// 合并多个流集合,解决返回体分段传输
|
// 合并多个流集合,解决返回体分段传输
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.muyu.gateway.config.properties.IgnoreWhiteProperties;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
|
@ -31,10 +31,10 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
||||||
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
|
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
|
||||||
|
|
||||||
// 排除过滤的 uri 地址,nacos自行添加
|
// 排除过滤的 uri 地址,nacos自行添加
|
||||||
@Autowired
|
@Resource
|
||||||
private IgnoreWhiteProperties ignoreWhite;
|
private IgnoreWhiteProperties ignoreWhite;
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
||||||
}
|
}
|
||||||
String userid = JwtUtils.getUserId(claims);
|
String userid = JwtUtils.getUserId(claims);
|
||||||
String username = JwtUtils.getUserName(claims);
|
String username = JwtUtils.getUserName(claims);
|
||||||
|
String saasKey = JwtUtils.getSaasKey(claims);
|
||||||
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
|
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
|
||||||
return unauthorizedResponse(exchange, "令牌验证失败");
|
return unauthorizedResponse(exchange, "令牌验证失败");
|
||||||
}
|
}
|
||||||
|
@ -71,6 +72,7 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
||||||
addHeader(mutate, SecurityConstants.USER_KEY, userkey);
|
addHeader(mutate, SecurityConstants.USER_KEY, userkey);
|
||||||
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
|
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
|
||||||
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
|
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
|
||||||
|
addHeader(mutate,SecurityConstants.SAAS_KEY,saasKey);
|
||||||
// 内部请求来源参数清除
|
// 内部请求来源参数清除
|
||||||
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
|
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
|
||||||
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.muyu.common.core.utils.ServletUtils;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.gateway.config.properties.CaptchaProperties;
|
import com.muyu.gateway.config.properties.CaptchaProperties;
|
||||||
import com.muyu.gateway.service.ValidateCodeService;
|
import com.muyu.gateway.service.ValidateCodeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
|
@ -29,9 +29,9 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object> {
|
||||||
private final static String[] VALIDATE_URL = new String[]{"/auth/login", "/auth/register"};
|
private final static String[] VALIDATE_URL = new String[]{"/auth/login", "/auth/register"};
|
||||||
private static final String CODE = "code";
|
private static final String CODE = "code";
|
||||||
private static final String UUID = "uuid";
|
private static final String UUID = "uuid";
|
||||||
@Autowired
|
@Resource
|
||||||
private ValidateCodeService validateCodeService;
|
private ValidateCodeService validateCodeService;
|
||||||
@Autowired
|
@Resource
|
||||||
private CaptchaProperties captchaProperties;
|
private CaptchaProperties captchaProperties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,7 +4,11 @@ import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.utils.html.EscapeUtil;
|
import com.muyu.common.core.utils.html.EscapeUtil;
|
||||||
import com.muyu.gateway.config.properties.XssProperties;
|
import com.muyu.gateway.config.properties.XssProperties;
|
||||||
import io.netty.buffer.ByteBufAllocator;
|
import io.netty.buffer.ByteBufAllocator;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||||
|
@ -31,7 +35,11 @@ import java.nio.charset.StandardCharsets;
|
||||||
@ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true")
|
@ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true")
|
||||||
public class XssFilter implements GlobalFilter, Ordered {
|
public class XssFilter implements GlobalFilter, Ordered {
|
||||||
// 跨站脚本的 xss 配置,nacos自行添加
|
// 跨站脚本的 xss 配置,nacos自行添加
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
||||||
private XssProperties xss;
|
private XssProperties xss;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,7 +3,11 @@ package com.muyu.gateway.handler;
|
||||||
import com.muyu.common.core.exception.CaptchaException;
|
import com.muyu.common.core.exception.CaptchaException;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.gateway.service.ValidateCodeService;
|
import com.muyu.gateway.service.ValidateCodeService;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.reactive.function.BodyInserters;
|
import org.springframework.web.reactive.function.BodyInserters;
|
||||||
|
@ -21,7 +25,11 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
|
public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
||||||
private ValidateCodeService validateCodeService;
|
private ValidateCodeService validateCodeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
|
||||||
CaptchaCodeResp.CaptchaCodeRespBuilder respBuilder = CaptchaCodeResp.builder()
|
CaptchaCodeResp.CaptchaCodeRespBuilder respBuilder = CaptchaCodeResp.builder()
|
||||||
.captchaEnabled(captchaEnabled);
|
.captchaEnabled(captchaEnabled);
|
||||||
if (!captchaEnabled) {
|
if (!captchaEnabled) {
|
||||||
return Result.success(respBuilder);
|
return Result.success(respBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
|
|
|
@ -4,8 +4,11 @@ import cn.hutool.core.net.NetUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import org.springframework.cloud.gateway.route.Route;
|
import org.springframework.cloud.gateway.route.Route;
|
||||||
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
||||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||||
|
@ -18,8 +21,11 @@ import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web 工具类
|
* Web 工具类
|
||||||
|
|
||||||
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class WebFrameworkUtils {
|
public class WebFrameworkUtils {
|
||||||
|
@ -72,8 +78,11 @@ public class WebFrameworkUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得客户端 IP
|
* 获得客户端 IP
|
||||||
|
|
||||||
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
||||||
* @param exchange 请求
|
* @param exchange 请求
|
||||||
* @param otherHeaderNames 其它 header 名字的数组
|
* @param otherHeaderNames 其它 header 名字的数组
|
||||||
* @return 客户端 IP
|
* @return 客户端 IP
|
||||||
|
@ -92,6 +101,9 @@ public class WebFrameworkUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 方式二,通过 remoteAddress 获取
|
// 方式二,通过 remoteAddress 获取
|
||||||
if (exchange.getRequest().getRemoteAddress() == null) {
|
if (exchange.getRequest().getRemoteAddress() == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -102,7 +114,10 @@ public class WebFrameworkUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得请求匹配的 Route 路由
|
* 获得请求匹配的 Route 路由
|
||||||
|
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
* @param exchange 请求
|
* @param exchange 请求
|
||||||
* @return 路由
|
* @return 路由
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,10 +4,14 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: nacos.muyu.icu:8848
|
addr: 106.54.193.225:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: muyu-cloud
|
|
||||||
|
namespace: one-saas
|
||||||
|
|
||||||
|
namespace: one
|
||||||
|
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
@ -22,35 +26,60 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
|
|
||||||
|
# # nacos用户名
|
||||||
|
# username: ${nacos.user-name}
|
||||||
|
# # nacos密码
|
||||||
|
# password: ${nacos.password}
|
||||||
|
|
||||||
# nacos用户名
|
# nacos用户名
|
||||||
username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# nacos密码
|
# nacos密码
|
||||||
password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
|
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
config:
|
config:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
|
|
||||||
|
# # nacos用户名
|
||||||
|
# username: ${nacos.user-name}
|
||||||
|
# # nacos密码
|
||||||
|
# password: ${nacos.password}
|
||||||
|
|
||||||
# nacos用户名
|
# nacos用户名
|
||||||
username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# nacos密码
|
# nacos密码
|
||||||
password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
|
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
|
|
||||||
|
# 系统环境Config共享配置
|
||||||
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# 系统共享配置
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
|
||||||
# 系统共享配置
|
# 系统共享配置
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
# 系统环境Config共享配置
|
# 系统环境Config共享配置
|
||||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
|
||||||
sentinel:
|
sentinel:
|
||||||
# 取消控制台懒加载
|
# 取消控制台懒加载
|
||||||
eager: true
|
eager: true
|
||||||
transport:
|
transport:
|
||||||
# 控制台地址
|
# 控制台地址
|
||||||
|
|
||||||
|
dashboard: 106.54.193.225:8718
|
||||||
|
|
||||||
dashboard: 127.0.0.1:8718
|
dashboard: 127.0.0.1:8718
|
||||||
|
|
||||||
# nacos配置持久化
|
# nacos配置持久化
|
||||||
datasource:
|
datasource:
|
||||||
ds1:
|
ds1:
|
||||||
|
|
|
@ -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.muyu</groupId>
|
||||||
|
<artifactId>cloud-breakdown</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>cloud-breakdown-client</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.muyu</groupId>
|
||||||
|
<artifactId>cloud-breakdown-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -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.muyu</groupId>
|
||||||
|
<artifactId>cloud-breakdown</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>cloud-breakdown-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>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,93 @@
|
||||||
|
//package com.muyu.breakdown.DTO;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//import com.muyu.breakdown.domain.Messages;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
|
//import java.sql.*;
|
||||||
|
//import java.util.*;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * @ Tool:IntelliJ IDEA
|
||||||
|
// * @ Author:CHX
|
||||||
|
// * @ Date:2024-09-18-15:00
|
||||||
|
// * @ Version:1.0
|
||||||
|
// * @ Description:数据库连接层
|
||||||
|
// * @author Lenovo
|
||||||
|
// */
|
||||||
|
//@Component
|
||||||
|
//public class MessageDTO {
|
||||||
|
// private static final String DB_URL = "jdbc:mysql://106.54.193.225:3306/one";
|
||||||
|
// private static final String USER = "root";
|
||||||
|
// private static final String PASSWORD = "bawei2112A";
|
||||||
|
//
|
||||||
|
// // 2. 建立数据库连接
|
||||||
|
// Connection connection;
|
||||||
|
// // 构造函数,初始化数据库连接
|
||||||
|
// // 保存消息到数据库
|
||||||
|
// public void saveMessage(Messages message) {
|
||||||
|
// String sql = "INSERT INTO sys_messages (sender_id, receiver_id, content) VALUES (?, ?, ?)";
|
||||||
|
// try {
|
||||||
|
// Class.forName("com.mysql.cj.jdbc.Driver");
|
||||||
|
// } catch (ClassNotFoundException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// try {
|
||||||
|
// connection = DriverManager.getConnection(DB_URL, USER, PASSWORD);
|
||||||
|
// } catch (SQLException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||||
|
// preparedStatement.setInt(1, message.getSenderId());
|
||||||
|
// preparedStatement.setInt(2, message.getReceiverId());
|
||||||
|
// preparedStatement.setString(3, message.getContent());
|
||||||
|
// // 执行添加操作
|
||||||
|
// preparedStatement.executeUpdate();
|
||||||
|
// } catch (SQLException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// try {
|
||||||
|
// connection.close();
|
||||||
|
// } catch (SQLException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 获取所有消息
|
||||||
|
// public List<Messages> getAllMessages(int receiverId){
|
||||||
|
// String sql = "SELECT * FROM sys_messages WHERE receiver_id = ?";
|
||||||
|
// try {
|
||||||
|
// Class.forName("com.mysql.cj.jdbc.Driver");
|
||||||
|
// } catch (ClassNotFoundException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// List<Messages> messages = new ArrayList<>();
|
||||||
|
// try {
|
||||||
|
// connection = DriverManager.getConnection(DB_URL, USER, PASSWORD);
|
||||||
|
// } catch (SQLException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||||
|
// preparedStatement.setInt(1, receiverId);
|
||||||
|
// // 执行查询操作
|
||||||
|
// ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
// while (rs.next()) {
|
||||||
|
// Messages message = new Messages(rs.getInt("sender_id"), receiverId, rs.getString("content"));
|
||||||
|
//
|
||||||
|
// // 添加到消息列表
|
||||||
|
// messages.add(message);
|
||||||
|
// }
|
||||||
|
// } catch (SQLException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// try {
|
||||||
|
// connection.close();
|
||||||
|
// } catch (SQLException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// // 返回消息列表
|
||||||
|
// return messages;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.muyu.breakdown.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lenovo
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-17-15:10
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:故障实体类
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("sys_car_fault")
|
||||||
|
public class BreakDown extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
@Excel(name = "主键")
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 故障码
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障码")
|
||||||
|
private String faultCode;
|
||||||
|
/**
|
||||||
|
* 故障类型
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障类型")
|
||||||
|
private String faultType;
|
||||||
|
/**
|
||||||
|
* 故障标签
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障标签")
|
||||||
|
private String faultLabel;
|
||||||
|
/**
|
||||||
|
* 故障位
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障位")
|
||||||
|
private String faultBit;
|
||||||
|
/**
|
||||||
|
* 故障值
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障值")
|
||||||
|
private String faultValue;
|
||||||
|
/**
|
||||||
|
* 故障级别
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障级别")
|
||||||
|
private String faultWarn;
|
||||||
|
/**
|
||||||
|
* 报警状态(Y.是,N.否)
|
||||||
|
*/
|
||||||
|
@Excel(name = "报警状态")
|
||||||
|
private String faultStatus;
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.muyu.breakdown.domain;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障日志对象 fault_log
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("fault_log")
|
||||||
|
public class FaultLog extends BaseEntity{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** id */
|
||||||
|
@TableId( type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 故障码 */
|
||||||
|
@Excel(name = "故障码")
|
||||||
|
private String faultCode;
|
||||||
|
|
||||||
|
/** 车辆VIN */
|
||||||
|
@Excel(name = "车辆VIN")
|
||||||
|
private String carVin;
|
||||||
|
|
||||||
|
/** 开始报警时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "开始报警时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
/** 结束报警时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "结束报警时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu.breakdown.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-20-15:31
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
public class MessageMap {
|
||||||
|
private String key;
|
||||||
|
private String value;
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.breakdown.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-18-14:51
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:站内信实体类
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("sys_messages")
|
||||||
|
public class Messages {
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
@Excel(name = "消息ID")
|
||||||
|
private Long id;
|
||||||
|
@Excel(name = "发送者ID")
|
||||||
|
private String senderId;
|
||||||
|
@Excel(name = "接收者ID")
|
||||||
|
private String receiverId;
|
||||||
|
@Excel(name = "消息内容")
|
||||||
|
private String content;
|
||||||
|
@Excel(name = "发送时间")
|
||||||
|
private Date createTime;
|
||||||
|
@Excel(name = "消息状态")
|
||||||
|
private String status;
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.muyu.breakdown.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-20-15:35
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:报文
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
@TableName("sys_car_message")
|
||||||
|
public class SysCarMessage {
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 车辆型号编码
|
||||||
|
*/
|
||||||
|
private String modelCode;
|
||||||
|
/**
|
||||||
|
* 车辆报文类型编码
|
||||||
|
*/
|
||||||
|
private String messageTypeCode;
|
||||||
|
/**
|
||||||
|
* 开始位下标
|
||||||
|
*/
|
||||||
|
private String messageStartIndex;
|
||||||
|
/**
|
||||||
|
* 结束位下标
|
||||||
|
*/
|
||||||
|
private String messageEndIndex;
|
||||||
|
}
|
|
@ -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.muyu</groupId>
|
||||||
|
<artifactId>cloud-breakdown</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>cloud-breakdown-remote</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.muyu</groupId>
|
||||||
|
<artifactId>cloud-breakdown-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
<?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.muyu</groupId>
|
||||||
|
<artifactId>cloud-breakdown</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>cloud-breakdown-server</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>
|
||||||
|
<!-- 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>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 接口模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- XllJob定时任务 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-xxl</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-rabbit</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-breakdown-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu;
|
||||||
|
|
||||||
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-17-15:00
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:故障启动类
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class BreakDownApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(BreakDownApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.breakdown.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-17-15:41
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:mybatisplus配置类
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
//@Configuration
|
||||||
|
//public class MybatisPlusConfig {
|
||||||
|
// /**
|
||||||
|
// * 添加分页插件
|
||||||
|
// */
|
||||||
|
// @Bean
|
||||||
|
// public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
|
// MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
// // 如果配置多个插件, 切记分页最后添加
|
||||||
|
// interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
|
// // 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
|
||||||
|
// return interceptor;
|
||||||
|
// }
|
||||||
|
// @Bean
|
||||||
|
// public MybatisConfiguration mybatisConfiguration(){
|
||||||
|
// MybatisConfiguration configuration = new MybatisConfiguration();
|
||||||
|
// return configuration;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.muyu.breakdown.config;
|
||||||
|
|
||||||
|
import org.springframework.amqp.core.Binding;
|
||||||
|
import org.springframework.amqp.core.BindingBuilder;
|
||||||
|
import org.springframework.amqp.core.FanoutExchange;
|
||||||
|
import org.springframework.amqp.core.Queue;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
/**
|
||||||
|
* 绑定交换机与队列
|
||||||
|
* */
|
||||||
|
@Configuration
|
||||||
|
public class RabbitMQConfig {
|
||||||
|
|
||||||
|
// 1.生命注册fanout模式的交换机
|
||||||
|
@Bean
|
||||||
|
public FanoutExchange fanoutExchange(){
|
||||||
|
//1.fanout模式的路由名称 2.是否持久化 3. 是否自动删除
|
||||||
|
return new FanoutExchange("fanout",true,false);
|
||||||
|
}
|
||||||
|
// 2.生命队列 sms.fanout.queue email.fanout.queue,duanxin.fanout.queue
|
||||||
|
@Bean
|
||||||
|
public Queue duanxinQueue(){
|
||||||
|
return new Queue("duanxin",true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Queue emailQueue(){
|
||||||
|
return new Queue("email",false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Queue smsQueue(){
|
||||||
|
return new Queue("sms",false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.完成绑定关系(队列和交换机完成绑定关系
|
||||||
|
@Bean
|
||||||
|
public Binding duanxinExchange(){
|
||||||
|
return BindingBuilder.bind(duanxinQueue()).to(fanoutExchange());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Binding emailExchange(){
|
||||||
|
return BindingBuilder.bind(emailQueue()).to(fanoutExchange());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Binding smsExchange(){
|
||||||
|
return BindingBuilder.bind(smsQueue()).to(fanoutExchange());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4.生命注册fanout模式的交换机
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.muyu.breakdown.config;
|
||||||
|
|
||||||
|
import org.springframework.amqp.core.*;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定交换机与队列
|
||||||
|
* */
|
||||||
|
@Configuration
|
||||||
|
public class RabbitMQDirectConfig {
|
||||||
|
/**
|
||||||
|
* 与fanout发布订阅模式不同的是 Direct 需要在Binding规定对应的 路由名称
|
||||||
|
* */
|
||||||
|
// 1.生命注册fanout模式的交换机
|
||||||
|
@Bean
|
||||||
|
public DirectExchange directExchange(){
|
||||||
|
//1.fanout模式的路由名称 2.是否持久化 3. 是否自动删除
|
||||||
|
return new DirectExchange("direct",true,false);
|
||||||
|
}
|
||||||
|
// 2.生命队列 sms.fanout.queue email.fanout.queue,duanxin.fanout.queue
|
||||||
|
@Bean
|
||||||
|
public Queue directduanxinQueue(){
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
map.put("x-delayed-letter-exchange","direct");
|
||||||
|
map.put("x-delayed-routing-key","directduanxin");
|
||||||
|
map.put("x-message-ttl",10000);
|
||||||
|
return QueueBuilder.durable("directduanxin").withArguments(map).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Queue directemailQueue(){
|
||||||
|
return new Queue("directemail",false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Queue directsmsQueue(){
|
||||||
|
return new Queue("directsms",false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.完成绑定关系(队列和交换机完成绑定关系
|
||||||
|
@Bean
|
||||||
|
public Binding directduanxinExchange(){
|
||||||
|
return BindingBuilder.bind(directduanxinQueue()).to(directExchange()).with("directduanxin");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Binding directemailExchange(){
|
||||||
|
return BindingBuilder.bind(directemailQueue()).to(directExchange()).with("directemail");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Binding directsmsExchange(){
|
||||||
|
return BindingBuilder.bind(directsmsQueue()).to(directExchange()).with("directsms");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4.生命注册fanout模式的交换机
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.muyu.breakdown.config;
|
||||||
|
|
||||||
|
import org.springframework.amqp.core.Binding;
|
||||||
|
import org.springframework.amqp.core.BindingBuilder;
|
||||||
|
import org.springframework.amqp.core.Queue;
|
||||||
|
import org.springframework.amqp.core.TopicExchange;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定交换机与队列
|
||||||
|
* */
|
||||||
|
@Configuration
|
||||||
|
public class RabbitMQTopicConfig {
|
||||||
|
/**
|
||||||
|
* 与fanout发布订阅模式不同的是 Direct 需要在Binding规定对应的 路由名称
|
||||||
|
* */
|
||||||
|
// 1.生命注册fanout模式的交换机
|
||||||
|
@Bean
|
||||||
|
public TopicExchange topicExchange(){
|
||||||
|
//1.fanout模式的路由名称 2.是否持久化 3. 是否自动删除
|
||||||
|
return new TopicExchange("topic",true,false);
|
||||||
|
}
|
||||||
|
// 2.生命队列 sms.fanout.queue email.fanout.queue,duanxin.fanout.queue
|
||||||
|
@Bean
|
||||||
|
public Queue topicduanxinQueue(){
|
||||||
|
return new Queue("topicduanxin.test.one",true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Queue topicemailQueue(){
|
||||||
|
return new Queue("topicemail.test.two",false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Queue topicsmsQueue(){
|
||||||
|
return new Queue("topicsms.test.three",false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.完成绑定关系(队列和交换机完成绑定关系
|
||||||
|
@Bean
|
||||||
|
public Binding topicduanxinExchange(){
|
||||||
|
return BindingBuilder.bind(topicduanxinQueue()).to(topicExchange()).with("topic.#");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Binding topicemailExchange(){
|
||||||
|
return BindingBuilder.bind(topicemailQueue()).to(topicExchange()).with("topic.*");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Binding topicsmsExchange(){
|
||||||
|
return BindingBuilder.bind(topicsmsQueue()).to(topicExchange()).with("topic.test.#");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4.生命注册fanout模式的交换机
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
package com.muyu.breakdown.controller;
|
||||||
|
|
||||||
|
import com.muyu.breakdown.domain.BreakDown;
|
||||||
|
import com.muyu.breakdown.domain.MessageMap;
|
||||||
|
import com.muyu.breakdown.service.BreakDownService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-17-15:13
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:故障管理实体类
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/breakdown")
|
||||||
|
public class BreakDownController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BreakDownService breakDownService;
|
||||||
|
/**
|
||||||
|
* 查询车辆故障列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<BreakDown>> list(BreakDown breakDown)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<BreakDown> list = breakDownService.selectBreakDownList(breakDown);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出车辆故障列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:export")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, BreakDown breakDown)
|
||||||
|
{
|
||||||
|
List<BreakDown> list = breakDownService.selectBreakDownList(breakDown);
|
||||||
|
ExcelUtil<BreakDown> util = new ExcelUtil<BreakDown>(BreakDown.class);
|
||||||
|
util.exportExcel(response, list, "车辆故障数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆故障详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result<List<BreakDown>> getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(breakDownService.selectBreakDownById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增车辆故障
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:add")
|
||||||
|
@PostMapping
|
||||||
|
public Result<Integer> add(
|
||||||
|
@Validated @RequestBody BreakDown breakDown)
|
||||||
|
{
|
||||||
|
if (breakDownService.checkIdUnique(breakDown)) {
|
||||||
|
return error("新增 车辆故障 '" + breakDown + "'失败,车辆故障已存在");
|
||||||
|
}
|
||||||
|
breakDown.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(breakDownService.save(breakDown));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改车辆故障
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:edit")
|
||||||
|
@PutMapping
|
||||||
|
public Result<Integer> edit(
|
||||||
|
@Validated @RequestBody BreakDown breakDown)
|
||||||
|
{
|
||||||
|
if (!breakDownService.checkIdUnique(breakDown)) {
|
||||||
|
return error("修改 车辆故障 '" + breakDown + "'失败,车辆故障不存在");
|
||||||
|
}
|
||||||
|
breakDown.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(breakDownService.updateById(breakDown));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除车辆故障
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("breakdown:breakdown:remove")
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||||
|
{
|
||||||
|
breakDownService.removeBatchByIds(Arrays.asList(ids));
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result getMessages(MessageMap messageMap) {
|
||||||
|
Map<String,String> messages =breakDownService.getMessages(messageMap);
|
||||||
|
return Result.success(messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,113 @@
|
||||||
|
package com.muyu.breakdown.controller;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.breakdown.domain.FaultLog;
|
||||||
|
import com.muyu.breakdown.service.IFaultLogService;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障日志Controller
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/log")
|
||||||
|
public class FaultLogController extends BaseController
|
||||||
|
{
|
||||||
|
@Resource
|
||||||
|
private IFaultLogService faultLogService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询故障日志列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("platform:log:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<FaultLog>> list(FaultLog faultLog)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<FaultLog> list = faultLogService.selectFaultLogList(faultLog);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出故障日志列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("platform:log:export")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, FaultLog faultLog)
|
||||||
|
{
|
||||||
|
List<FaultLog> list = faultLogService.selectFaultLogList(faultLog);
|
||||||
|
ExcelUtil<FaultLog> util = new ExcelUtil<FaultLog>(FaultLog.class);
|
||||||
|
util.exportExcel(response, list, "故障日志数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取故障日志详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("platform:log:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result<List<FaultLog>> getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(faultLogService.selectFaultLogById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增故障日志
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("platform:log:add")
|
||||||
|
@PostMapping
|
||||||
|
public Result<Integer> add(
|
||||||
|
@Validated @RequestBody FaultLog faultLog)
|
||||||
|
{
|
||||||
|
if (faultLogService.checkIdUnique(faultLog)) {
|
||||||
|
return error("新增 故障日志 '" + faultLog + "'失败,故障日志已存在");
|
||||||
|
}
|
||||||
|
faultLog.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(faultLogService.save(faultLog));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改故障日志
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("platform:log:edit")
|
||||||
|
@PutMapping
|
||||||
|
public Result<Integer> edit(
|
||||||
|
@Validated @RequestBody FaultLog faultLog)
|
||||||
|
{
|
||||||
|
if (!faultLogService.checkIdUnique(faultLog)) {
|
||||||
|
return error("修改 故障日志 '" + faultLog + "'失败,故障日志不存在");
|
||||||
|
}
|
||||||
|
faultLog.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
return toAjax(faultLogService.updateById(faultLog));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除故障日志
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("platform:log:remove")
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||||
|
{
|
||||||
|
faultLogService.removeBatchByIds(Arrays.asList(ids));
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.muyu.breakdown.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.muyu.breakdown.domain.Messages;
|
||||||
|
import com.muyu.breakdown.service.BreakDownService;
|
||||||
|
import com.muyu.breakdown.service.StationMessageService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-18-12:01
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:站内信控制层
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/stationMessage")
|
||||||
|
public class StationMessageController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private StationMessageService stationMessageService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据当前用户id获取站内信列表
|
||||||
|
* @param receiverId 当前用户id
|
||||||
|
* @return 站内信列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/getMessageList")
|
||||||
|
public Result<List<Messages>> list(@RequestParam("receiverId") String receiverId){
|
||||||
|
List<Messages> list = stationMessageService.list(new LambdaQueryWrapper<>() {{
|
||||||
|
eq(Messages::getReceiverId, receiverId);
|
||||||
|
}});
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.muyu.breakdown.controller;
|
||||||
|
|
||||||
|
import com.muyu.breakdown.service.SysCarMessageService;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-20-15:41
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:报文模版控制层
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class SysCarMessageController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private SysCarMessageService sysCarMessageService;
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.breakdown.mapper;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.muyu.breakdown.domain.BreakDown;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-17-15:14
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:故障管理持久层
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface BreakDownMapper extends MPJBaseMapper<BreakDown> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.muyu.breakdown.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.breakdown.domain.FaultLog;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障日志Mapper接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FaultLogMapper extends BaseMapper<FaultLog>{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.breakdown.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.muyu.breakdown.domain.Messages;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-18-14:57
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:站内信持久层
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface StationMessageMapper extends MPJBaseMapper<Messages> {
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.muyu.breakdown.mapper;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.muyu.breakdown.domain.SysCarMessage;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-20-15:54
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysCarMessageMapper extends MPJBaseMapper<SysCarMessage> {
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.muyu.breakdown.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.breakdown.domain.BreakDown;
|
||||||
|
import com.muyu.breakdown.domain.MessageMap;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-17-15:31
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:故障管理业务层
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
public interface BreakDownService extends IService<BreakDown> {
|
||||||
|
/**
|
||||||
|
* 精确查询车辆故障
|
||||||
|
*
|
||||||
|
* @param id 车辆故障主键
|
||||||
|
* @return 车辆故障
|
||||||
|
*/
|
||||||
|
public BreakDown selectBreakDownById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆故障列表
|
||||||
|
*
|
||||||
|
* @param breakDown 车辆故障
|
||||||
|
* @return 车辆故障集合
|
||||||
|
*/
|
||||||
|
public List<BreakDown> selectBreakDownList(BreakDown breakDown);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断 车辆故障 id是否唯一
|
||||||
|
* @param breakDown 车辆故障
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
Boolean checkIdUnique(BreakDown breakDown);
|
||||||
|
|
||||||
|
Map<String, String> getMessages(MessageMap messageMap);
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.breakdown.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.breakdown.domain.FaultLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障日志Service接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
public interface IFaultLogService extends IService<FaultLog> {
|
||||||
|
/**
|
||||||
|
* 精确查询故障日志
|
||||||
|
*
|
||||||
|
* @param id 故障日志主键
|
||||||
|
* @return 故障日志
|
||||||
|
*/
|
||||||
|
public FaultLog selectFaultLogById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询故障日志列表
|
||||||
|
*
|
||||||
|
* @param faultLog 故障日志
|
||||||
|
* @return 故障日志集合
|
||||||
|
*/
|
||||||
|
public List<FaultLog> selectFaultLogList(FaultLog faultLog);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断 故障日志 id是否唯一
|
||||||
|
* @param faultLog 故障日志
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
Boolean checkIdUnique(FaultLog faultLog);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.breakdown.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.breakdown.domain.Messages;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-18-14:56
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
public interface StationMessageService extends IService<Messages> {
|
||||||
|
|
||||||
|
List<Messages> getMessageList(String receiverId);
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.muyu.breakdown.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.breakdown.domain.SysCarMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-20-15:42
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
public interface SysCarMessageService extends IService<SysCarMessage> {
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package com.muyu.breakdown.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.muyu.breakdown.domain.BreakDown;
|
||||||
|
import com.muyu.breakdown.domain.MessageMap;
|
||||||
|
import com.muyu.breakdown.domain.SysCarMessage;
|
||||||
|
import com.muyu.breakdown.mapper.BreakDownMapper;
|
||||||
|
import com.muyu.breakdown.service.BreakDownService;
|
||||||
|
import com.muyu.breakdown.service.SysCarMessageService;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-17-15:31
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:故障管理业务实现层
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BreakDownServiceImpl extends ServiceImpl<BreakDownMapper, BreakDown> implements BreakDownService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysCarMessageService sysCarMessageService;
|
||||||
|
@Autowired
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
/**
|
||||||
|
* 精确查询车辆故障
|
||||||
|
*
|
||||||
|
* @param id 车辆故障主键
|
||||||
|
* @return 车辆故障
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public BreakDown selectBreakDownById(Long id)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<BreakDown> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
Assert.notNull(id, "id不可为空");
|
||||||
|
queryWrapper.eq(BreakDown::getId, id);
|
||||||
|
return this.getOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆故障列表
|
||||||
|
*
|
||||||
|
* @param breakDown 车辆故障
|
||||||
|
* @return 车辆故障
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BreakDown> selectBreakDownList(BreakDown breakDown)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<BreakDown> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotEmpty(breakDown.getFaultCode())){
|
||||||
|
queryWrapper.eq(BreakDown::getFaultCode, breakDown.getFaultCode());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(breakDown.getFaultType())){
|
||||||
|
queryWrapper.eq(BreakDown::getFaultType, breakDown.getFaultType());
|
||||||
|
}
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一 判断
|
||||||
|
* @param breakDown 车辆故障
|
||||||
|
* @return 车辆故障
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean checkIdUnique(BreakDown breakDown) {
|
||||||
|
LambdaQueryWrapper<BreakDown> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(BreakDown::getId, breakDown.getId());
|
||||||
|
return this.count(queryWrapper) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getMessages(MessageMap messageMap) {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @RabbitListener(queues = "car.message.queue")
|
||||||
|
// private void sendMessage(String message) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.muyu.breakdown.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.breakdown.domain.FaultLog;
|
||||||
|
import com.muyu.breakdown.mapper.FaultLogMapper;
|
||||||
|
import com.muyu.breakdown.service.IFaultLogService;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障日志Service业务层处理
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class FaultLogServiceImpl
|
||||||
|
extends ServiceImpl<FaultLogMapper, FaultLog>
|
||||||
|
implements IFaultLogService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精确查询故障日志
|
||||||
|
*
|
||||||
|
* @param id 故障日志主键
|
||||||
|
* @return 故障日志
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public FaultLog selectFaultLogById(Long id)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<FaultLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
Assert.notNull(id, "id不可为空");
|
||||||
|
queryWrapper.eq(FaultLog::getId, id);
|
||||||
|
return this.getOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询故障日志列表
|
||||||
|
*
|
||||||
|
* @param faultLog 故障日志
|
||||||
|
* @return 故障日志
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<FaultLog> selectFaultLogList(FaultLog faultLog)
|
||||||
|
{
|
||||||
|
LambdaQueryWrapper<FaultLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotEmpty(faultLog.getFaultCode())){
|
||||||
|
queryWrapper.eq(FaultLog::getFaultCode, faultLog.getFaultCode());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(faultLog.getCarVin())){
|
||||||
|
queryWrapper.eq(FaultLog::getCarVin, faultLog.getCarVin());
|
||||||
|
}
|
||||||
|
if (faultLog.getStartTime()!=null){
|
||||||
|
queryWrapper.eq(FaultLog::getStartTime, faultLog.getStartTime());
|
||||||
|
}
|
||||||
|
if (faultLog.getEndTime()!=null){
|
||||||
|
queryWrapper.eq(FaultLog::getEndTime, faultLog.getEndTime());
|
||||||
|
}
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一 判断
|
||||||
|
* @param faultLog 故障日志
|
||||||
|
* @return 故障日志
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean checkIdUnique(FaultLog faultLog) {
|
||||||
|
LambdaQueryWrapper<FaultLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(FaultLog::getId, faultLog.getId());
|
||||||
|
return this.count(queryWrapper) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.muyu.breakdown.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.breakdown.domain.Messages;
|
||||||
|
import com.muyu.breakdown.mapper.StationMessageMapper;
|
||||||
|
import com.muyu.breakdown.service.StationMessageService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-18-14:56
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:站内信业务实现层
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class StationMessageServiceImpl
|
||||||
|
extends ServiceImpl<StationMessageMapper, Messages>
|
||||||
|
implements StationMessageService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StationMessageMapper stationMessageMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Messages> getMessageList(String receiverId) {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.breakdown.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.breakdown.domain.SysCarMessage;
|
||||||
|
import com.muyu.breakdown.mapper.SysCarMessageMapper;
|
||||||
|
import com.muyu.breakdown.service.SysCarMessageService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-20-15:42
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysCarMessageServiceImpl extends ServiceImpl<SysCarMessageMapper, SysCarMessage> implements SysCarMessageService {
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,60 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9702
|
||||||
|
|
||||||
|
# nacos线上地址
|
||||||
|
nacos:
|
||||||
|
addr: 106.54.193.225:8848
|
||||||
|
user-name: nacos
|
||||||
|
password: nacos
|
||||||
|
namespace: one
|
||||||
|
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
amqp:
|
||||||
|
deserialization:
|
||||||
|
trust:
|
||||||
|
all: true
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: cloud-breakdown
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos.addr}
|
||||||
|
# nacos用户名
|
||||||
|
username: ${nacos.user-name}
|
||||||
|
# nacos密码
|
||||||
|
password: ${nacos.password}
|
||||||
|
# 命名空间
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
config:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos.addr}
|
||||||
|
# nacos用户名
|
||||||
|
username: ${nacos.user-name}
|
||||||
|
# nacos密码
|
||||||
|
password: ${nacos.password}
|
||||||
|
# 命名空间
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
# 系统共享配置
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# 系统环境Config共享配置
|
||||||
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# xxl-job 配置文件
|
||||||
|
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# rabbit 配置文件
|
||||||
|
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.muyu.breakdown.mapper: DEBUG
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue