fast()多数据源调整
parent
43d3d167dc
commit
2341e41020
|
@ -0,0 +1,16 @@
|
||||||
|
package com.muyu.auth.form;
|
||||||
|
|
||||||
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class Sys {
|
||||||
|
@Autowired
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
|
public void sys(LoginUser userInfo) {
|
||||||
|
System.out.println(userInfo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.auth.service;
|
package com.muyu.auth.service;
|
||||||
|
|
||||||
|
import com.muyu.auth.form.Sys;
|
||||||
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;
|
||||||
|
@ -18,6 +19,8 @@ import com.muyu.common.system.domain.LoginUser;
|
||||||
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.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录校验方法
|
* 登录校验方法
|
||||||
*
|
*
|
||||||
|
@ -37,6 +40,9 @@ public class SysLoginService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Sys sys;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*/
|
*/
|
||||||
|
@ -88,6 +94,7 @@ public class SysLoginService {
|
||||||
}
|
}
|
||||||
passwordService.validate(user, password);
|
passwordService.validate(user, password);
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||||
|
sys.sys(userInfo);
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,4 +20,12 @@ public class ServiceNameConstants {
|
||||||
* 文件服务的serviceid
|
* 文件服务的serviceid
|
||||||
*/
|
*/
|
||||||
public static final String FILE_SERVICE = "muyu-file";
|
public static final String FILE_SERVICE = "muyu-file";
|
||||||
|
/**
|
||||||
|
* 企业运营
|
||||||
|
*/
|
||||||
|
public static final String GOODS_SERVICE = "muyu-goods";
|
||||||
|
/**
|
||||||
|
* 多数据源
|
||||||
|
*/
|
||||||
|
public static final String RANGE_SERVICE = "muyu-range";
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>muyu-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>muyu-common-goods</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>muyu-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.common.goods.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Sources implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 企业id
|
||||||
|
*/
|
||||||
|
private Long enterpriseId;
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 连接库
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
/**
|
||||||
|
* ip
|
||||||
|
*/
|
||||||
|
private String ip;
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.muyu.common.goods.remote;
|
||||||
|
|
||||||
|
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.goods.domain.Sources;
|
||||||
|
import com.muyu.common.goods.remote.factory.RemoteSourcesFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@FeignClient(
|
||||||
|
contextId = "sourcesService",
|
||||||
|
value = ServiceNameConstants.GOODS_SERVICE,
|
||||||
|
fallbackFactory = RemoteSourcesFallbackFactory.class
|
||||||
|
)
|
||||||
|
public interface RemoteSourcesService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业服务信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("enterprise/listSources")
|
||||||
|
public Result<List<Sources>> listSources();
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.common.goods.remote.factory;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.goods.domain.Sources;
|
||||||
|
import com.muyu.common.goods.remote.RemoteSourcesService;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class RemoteSourcesFallbackFactory implements FallbackFactory<RemoteSourcesService> {
|
||||||
|
@Override
|
||||||
|
public RemoteSourcesService create(Throwable cause) {
|
||||||
|
return new RemoteSourcesService() {
|
||||||
|
@Override
|
||||||
|
public Result<List<Sources>> listSources() {
|
||||||
|
return Result.error(cause.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
com.muyu.common.goods.remote.factory.RemoteSourcesFallbackFactory
|
|
@ -133,4 +133,14 @@ public class LoginUser implements Serializable {
|
||||||
public void setSysUser (SysUser sysUser) {
|
public void setSysUser (SysUser sysUser) {
|
||||||
this.sysUser = sysUser;
|
this.sysUser = sysUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getFirm() {
|
||||||
|
return firm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirm(Long firm) {
|
||||||
|
this.firm = firm;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,7 @@ public class SysUser extends BaseEntity {
|
||||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||||
private Date loginDate;
|
private Date loginDate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门对象
|
* 部门对象
|
||||||
*/
|
*/
|
||||||
|
@ -140,11 +141,8 @@ public class SysUser extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 绑定企业
|
* 绑定企业
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Long firm;
|
private Long firm;
|
||||||
/**
|
|
||||||
* 登录标识
|
|
||||||
*/
|
|
||||||
private Integer identification;
|
|
||||||
|
|
||||||
public SysUser (Long userId) {
|
public SysUser (Long userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
|
@ -310,6 +308,14 @@ public class SysUser extends BaseEntity {
|
||||||
this.roleId = roleId;
|
this.roleId = roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getFirm() {
|
||||||
|
return firm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirm(Long firm) {
|
||||||
|
this.firm = firm;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
@ -332,6 +338,7 @@ public class SysUser extends BaseEntity {
|
||||||
.append("updateTime", getUpdateTime())
|
.append("updateTime", getUpdateTime())
|
||||||
.append("remark", getRemark())
|
.append("remark", getRemark())
|
||||||
.append("dept", getDept())
|
.append("dept", getDept())
|
||||||
|
.append("firm",getFirm())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,18 @@ 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.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户服务
|
* 用户服务
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
@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 {
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户信息
|
* 通过用户名查询用户信息
|
||||||
|
@ -37,4 +43,7 @@ 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/userList")
|
||||||
|
public Result<List<SysUser>> getUserList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户服务降级处理
|
* 用户服务降级处理
|
||||||
*
|
*
|
||||||
|
@ -31,6 +33,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
||||||
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>> getUserList() {
|
||||||
|
return Result.error("获取用户失败:{}"+throwable.getMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<module>muyu-common-datascope</module>
|
<module>muyu-common-datascope</module>
|
||||||
<module>muyu-common-datasource</module>
|
<module>muyu-common-datasource</module>
|
||||||
<module>muyu-common-system</module>
|
<module>muyu-common-system</module>
|
||||||
|
<module>muyu-common-goods</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>muyu-common</artifactId>
|
<artifactId>muyu-common</artifactId>
|
||||||
|
|
|
@ -90,6 +90,10 @@
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-system</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -6,9 +6,11 @@ import com.muyu.common.core.domain.Result;
|
||||||
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 com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
import com.muyu.goods.mapper.BusinessMapper;
|
import com.muyu.goods.mapper.BusinessMapper;
|
||||||
import com.muyu.goods.service.IBusinessService;
|
import com.muyu.goods.service.IBusinessService;
|
||||||
import com.muyu.system.remote.RemoteSystemManageService;
|
import com.muyu.system.remote.RemoteSystemManageService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
import muyu.goods.enterprise.client.config.EnterpriseConfig;
|
import muyu.goods.enterprise.client.config.EnterpriseConfig;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -24,6 +26,7 @@ import java.util.stream.Stream;
|
||||||
* @date 2024-05-26
|
* @date 2024-05-26
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Log4j2
|
||||||
public class BusinessServiceImpl implements IBusinessService
|
public class BusinessServiceImpl implements IBusinessService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -31,6 +34,9 @@ public class BusinessServiceImpl implements IBusinessService
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteSystemManageService remoteSystemManageService;
|
private RemoteSystemManageService remoteSystemManageService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全部入驻企业
|
* 获取全部入驻企业
|
||||||
* @return
|
* @return
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-modules-system</artifactId>
|
<artifactId>muyu-common-goods</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -30,6 +30,12 @@
|
||||||
<artifactId>muyu-goods-enterprise-common</artifactId>
|
<artifactId>muyu-goods-enterprise-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-modules-system</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,21 +1,36 @@
|
||||||
package muyu.goods.enterprise.client.config.runner;
|
package muyu.goods.enterprise.client.config.runner;
|
||||||
|
|
||||||
import com.muyu.common.security.config.ApplicationConfig;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.goods.domain.Sources;
|
||||||
|
import com.muyu.common.goods.remote.RemoteSourcesService;
|
||||||
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
|
import com.muyu.system.remote.RemoteSystemManageService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.BeansException;
|
//import muyu.goods.enterprise.remote.EnterpriseDataService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
|
||||||
|
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@Component
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ComponentScan
|
||||||
public class EnterpriseConfigRunner implements ApplicationRunner {
|
public class EnterpriseConfigRunner implements ApplicationRunner {
|
||||||
|
@Autowired
|
||||||
|
private RemoteSourcesService remoteSourcesService;
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
Result<List<Sources>> listResult = remoteSourcesService.listSources();
|
||||||
|
System.out.println(listResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,5 +24,11 @@
|
||||||
<artifactId>muyu-goods-enterprise-common</artifactId>
|
<artifactId>muyu-goods-enterprise-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package muyu.goods.enterprise.remote;
|
||||||
|
|
||||||
|
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.goods.domain.Sources;
|
||||||
|
import muyu.goods.enterprise.remote.factory.EnterpriseDataServiceFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@FeignClient(
|
||||||
|
contextId = "enterpriseSources",
|
||||||
|
value = ServiceNameConstants.GOODS_SERVICE,
|
||||||
|
fallbackFactory = EnterpriseDataServiceFactory.class
|
||||||
|
)
|
||||||
|
public interface EnterpriseDataService {
|
||||||
|
/**
|
||||||
|
* 获取多数据源信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/enterprise/listSources")
|
||||||
|
public Result<List<Sources>> listSources();
|
||||||
|
}
|
|
@ -1,4 +0,0 @@
|
||||||
package muyu.goods.enterprise.remote;
|
|
||||||
|
|
||||||
public interface RemoteEnterpriseManageService {
|
|
||||||
}
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package muyu.goods.enterprise.remote.factory;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.goods.domain.Sources;
|
||||||
|
import muyu.goods.enterprise.remote.EnterpriseDataService;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EnterpriseDataServiceFactory implements FallbackFactory<EnterpriseDataService> {
|
||||||
|
@Override
|
||||||
|
public EnterpriseDataService create(Throwable cause) {
|
||||||
|
return new EnterpriseDataService() {
|
||||||
|
@Override
|
||||||
|
public Result<List<Sources>> listSources() {
|
||||||
|
return Result.error(cause.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
muyu.goods.enterprise.remote.factory.EnterpriseDataServiceFactory
|
|
@ -5,6 +5,7 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
|
|
@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.goods.domain.Enterprise;
|
import com.muyu.goods.domain.Enterprise;
|
||||||
|
import com.muyu.goods.domain.Sources;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
@ -153,4 +154,13 @@ public class EnterpriseController extends BaseController
|
||||||
return success(enterpriseService.bu(id));
|
return success(enterpriseService.bu(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业服务信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/listSources")
|
||||||
|
public Result<List<Sources>> listSources() {
|
||||||
|
return success(enterpriseService.listSources());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.muyu.goods.mapper;
|
package com.muyu.goods.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.muyu.goods.domain.Enterprise;
|
import com.muyu.goods.domain.Enterprise;
|
||||||
import com.muyu.goods.domain.Sources;
|
import com.muyu.goods.domain.Sources;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
@ -71,4 +73,6 @@ public interface EnterpriseMapper
|
||||||
|
|
||||||
|
|
||||||
void indexSources(Sources sources);
|
void indexSources(Sources sources);
|
||||||
|
|
||||||
|
List<Sources> listSources(QueryWrapper<Object> objectQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.goods.domain.Enterprise;
|
import com.muyu.goods.domain.Enterprise;
|
||||||
|
import com.muyu.goods.domain.Sources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业Service接口
|
* 企业Service接口
|
||||||
|
@ -79,4 +80,6 @@ public interface IEnterpriseService
|
||||||
String getLevel(Long id, Integer serviceLevel);
|
String getLevel(Long id, Integer serviceLevel);
|
||||||
|
|
||||||
String bu(Long id);
|
String bu(Long id);
|
||||||
|
|
||||||
|
List<Sources> listSources();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.muyu.common.core.utils.DateUtils;
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
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;
|
||||||
|
@ -76,7 +77,6 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
||||||
if (i>0){
|
if (i>0){
|
||||||
Enterprise enterprise1 = enterpriseMapper.queryDateEnterprise();
|
Enterprise enterprise1 = enterpriseMapper.queryDateEnterprise();
|
||||||
enterpriseConfig.index(enterprise1);
|
enterpriseConfig.index(enterprise1);
|
||||||
|
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -206,4 +206,9 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
||||||
return "成功";
|
return "成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Sources> listSources() {
|
||||||
|
return enterpriseMapper.listSources(new QueryWrapper<>());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<include refid="selectEnterpriseVo"/>
|
<include refid="selectEnterpriseVo"/>
|
||||||
ORDER BY id DESC LIMIT 1;
|
ORDER BY id DESC LIMIT 1;
|
||||||
</select>
|
</select>
|
||||||
|
<select id="listSources" resultType="com.muyu.goods.domain.Sources">
|
||||||
|
select * from sources
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<insert id="insertEnterprise" parameterType="com.muyu.goods.domain.Enterprise" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertEnterprise" parameterType="com.muyu.goods.domain.Enterprise" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
|
|
@ -22,6 +22,12 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-goods</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
@ -82,6 +88,12 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-common-swagger</artifactId>
|
<artifactId>muyu-common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-goods-enterprise-remote</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
package com.muyu.cloud.Client.run;
|
|
||||||
|
|
||||||
public class ManyConfigRunner {
|
|
||||||
}
|
|
|
@ -1,12 +1,11 @@
|
||||||
package com.muyu.cloud.Client;
|
package com.muyu.cloud.client;
|
||||||
|
|
||||||
import com.muyu.cloud.Client.run.ManyConfigRunner;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
@Import(value = ManyConfigRunner.class)
|
@Import(value = CloudConfigRunner.class)
|
||||||
public class ManyConfig {
|
public class CloudConfig {
|
||||||
}
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.cloud.client;
|
||||||
|
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
public class CloudConfigRunner implements ApplicationRunner {
|
||||||
|
// @Autowired
|
||||||
|
// private RemoteEnterpriseService;
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,8 +2,11 @@ package com.muyu.cloud.datasource.config;
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
import com.muyu.cloud.datasource.config.contents.DataSourceInfo;
|
import com.muyu.cloud.datasource.config.contents.DataSourceInfo;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.goods.domain.Sources;
|
||||||
|
import com.muyu.common.goods.remote.RemoteSourcesService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
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.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
|
@ -22,22 +25,26 @@ import java.util.Map;
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@Configuration
|
@Configuration
|
||||||
public class DruidConfig {
|
public class DruidConfig {
|
||||||
|
@Autowired
|
||||||
// @Autowired
|
private RemoteSourcesService remoteSourcesService;
|
||||||
// private DynamicDataSource dynamicDataSource;
|
|
||||||
/**
|
/**
|
||||||
* 获取多数据源信息列表
|
* 获取多数据源信息列表
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<DataSourceInfo> getDataSourceInfoList(){
|
private List<DataSourceInfo> getDataSourceInfoList(){
|
||||||
System.out.println("获取当前登录信息");
|
List<Sources> listResult = remoteSourcesService.listSources().getData();
|
||||||
System.out.println(SecurityUtils.getLoginUser());
|
System.out.println(listResult);
|
||||||
List<String> databaseNameList = new ArrayList<>(){{
|
List<String> databaseNameList = new ArrayList<>();
|
||||||
add("3310");
|
listResult.forEach(res -> {
|
||||||
add("3311");
|
databaseNameList.add(res.getIp());
|
||||||
}};
|
});
|
||||||
|
// List<String> databaseNameList = new ArrayList<>(){{
|
||||||
|
// add("3310");
|
||||||
|
// add("3311");
|
||||||
|
// }};
|
||||||
|
System.out.println(databaseNameList);
|
||||||
List<DataSourceInfo> list = databaseNameList.stream().map(DataSourceInfo::dataIpBuild).toList();
|
List<DataSourceInfo> list = databaseNameList.stream().map(DataSourceInfo::dataIpBuild).toList();
|
||||||
System.out.println(list);
|
// System.out.println(list);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +83,7 @@ public class DruidConfig {
|
||||||
getDataSourceInfoList().forEach(dataSourceInfo -> {
|
getDataSourceInfoList().forEach(dataSourceInfo -> {
|
||||||
dataSourceMap.put(dataSourceInfo.getIp(), createDataSourceConnection(dataSourceInfo));
|
dataSourceMap.put(dataSourceInfo.getIp(), createDataSourceConnection(dataSourceInfo));
|
||||||
});
|
});
|
||||||
System.out.println(dataSourceMap);
|
// System.out.println(dataSourceMap);
|
||||||
//设置动态数据源
|
//设置动态数据源
|
||||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||||
// dynamicDataSource.setDefaultTargetDataSource(dynamicDataSource);
|
// dynamicDataSource.setDefaultTargetDataSource(dynamicDataSource);
|
||||||
|
@ -84,5 +91,6 @@ public class DruidConfig {
|
||||||
//将数据源信息备份在defineTargetDataSources中
|
//将数据源信息备份在defineTargetDataSources中
|
||||||
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
||||||
return dynamicDataSource;
|
return dynamicDataSource;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.muyu.cloud.remote;
|
||||||
|
|
||||||
|
import com.muyu.cloud.domain.Status;
|
||||||
|
import com.muyu.cloud.remote.factory.DataSourceConfigRunner;
|
||||||
|
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@FeignClient(
|
||||||
|
contextId = "sourceId",
|
||||||
|
value = ServiceNameConstants.RANGE_SERVICE,
|
||||||
|
fallbackFactory = DataSourceConfigRunner.class,
|
||||||
|
path = "/cloud"
|
||||||
|
)
|
||||||
|
public interface DataSourceConfig {
|
||||||
|
@PostMapping("list")
|
||||||
|
public Result<List<Status>> list();
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.muyu.cloud.remote.factory;
|
||||||
|
|
||||||
|
import com.muyu.cloud.domain.Status;
|
||||||
|
import com.muyu.cloud.remote.DataSourceConfig;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DataSourceConfigRunner implements FallbackFactory<DataSourceConfig> {
|
||||||
|
@Override
|
||||||
|
public DataSourceConfig create(Throwable cause) {
|
||||||
|
return new DataSourceConfig() {
|
||||||
|
@Override
|
||||||
|
public Result<List<Status>> list() {
|
||||||
|
return Result.error(cause.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +1,3 @@
|
||||||
com.muyu.cloud.datasource.interceptor.WebMvcConfig
|
com.muyu.cloud.datasource.interceptor.WebMvcConfig
|
||||||
|
com.muyu.cloud.client.CloudConfig
|
||||||
|
com.muyu.cloud.remote.factory.DataSourceConfigRunner
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
<!-- 日志存放路径 -->
|
<!-- 日志存放路径 -->
|
||||||
<property name="log.path" value="logs/muyu-moudels-many-datasource"/>
|
<property name="log.path" value="logs/muyu-visual-monitor"/>
|
||||||
<!-- 日志输出格式 -->
|
<!-- 日志输出格式 -->
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import com.muyu.system.domain.resp.AuthRoleResp;
|
||||||
import com.muyu.system.domain.resp.UserDetailInfoResp;
|
import com.muyu.system.domain.resp.UserDetailInfoResp;
|
||||||
import com.muyu.system.domain.resp.UserInfoResp;
|
import com.muyu.system.domain.resp.UserInfoResp;
|
||||||
import com.muyu.system.service.*;
|
import com.muyu.system.service.*;
|
||||||
|
import org.apache.catalina.User;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
@ -139,6 +140,10 @@ public class SysUserController extends BaseController {
|
||||||
return Result.success(userService.registerUser(sysUser));
|
return Result.success(userService.registerUser(sysUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/userList")
|
||||||
|
public Result<List<SysUser>> userList(){
|
||||||
|
return Result.success(userService.lists());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue