fast()补充唯一
parent
a560229583
commit
d3f9814aba
|
@ -136,6 +136,7 @@
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -29,6 +29,14 @@
|
||||||
<artifactId>muyu-modules-system</artifactId>
|
<artifactId>muyu-modules-system</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MQ依赖-->
|
||||||
|
<!-- rabbitmq-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -109,6 +109,36 @@ public class EnterpriseController extends BaseController
|
||||||
return toAjax(enterpriseService.updateEnterprise(enterprise));
|
return toAjax(enterpriseService.updateEnterprise(enterprise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断公司名称是否唯一
|
||||||
|
* @param enterpriseName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("oneName")
|
||||||
|
public Result<Integer> oneName(String enterpriseName) {
|
||||||
|
return success(enterpriseService.oneName(enterpriseName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断联系方式是否唯一
|
||||||
|
* @param contactPhone
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("onePhone")
|
||||||
|
public Result<Integer> onePhone(String contactPhone) {
|
||||||
|
return success(enterpriseService.onePhone(contactPhone));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断邮箱是否唯一
|
||||||
|
* @param email
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("oneEmail")
|
||||||
|
public Result<Integer> oneEmail(String email) {
|
||||||
|
return success(enterpriseService.oneEmail(email));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业认证
|
* 企业认证
|
||||||
* @param id
|
* @param id
|
||||||
|
@ -174,4 +204,13 @@ public class EnterpriseController extends BaseController
|
||||||
return success(enterpriseService.indexCustom(custom));
|
return success(enterpriseService.indexCustom(custom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看所有定制服务
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("listCustom")
|
||||||
|
public Result<List<Custom>> listCustom() {
|
||||||
|
return success(enterpriseService.listCustom());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,16 @@ public interface EnterpriseMapper
|
||||||
|
|
||||||
Enterprise queryDateEnterprise();
|
Enterprise queryDateEnterprise();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断唯一
|
||||||
|
* @param enterpriseName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer oneName(@Param("enterpriseName") String enterpriseName);
|
||||||
|
|
||||||
|
Integer onePhone(@Param("contactPhone") String contactPhone);
|
||||||
|
|
||||||
|
Integer oneEmail(@Param("email") String email);
|
||||||
int getLevel(@Param("id") Long id, @Param("serviceLevel") Integer serviceLevel);
|
int getLevel(@Param("id") Long id, @Param("serviceLevel") Integer serviceLevel);
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,4 +88,7 @@ public interface EnterpriseMapper
|
||||||
List<Sources> listSources(QueryWrapper<Object> objectQueryWrapper);
|
List<Sources> listSources(QueryWrapper<Object> objectQueryWrapper);
|
||||||
|
|
||||||
int indexCustom(Custom custom);
|
int indexCustom(Custom custom);
|
||||||
|
|
||||||
|
List<Custom> listCustom();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.goods.mq;
|
||||||
|
|
||||||
|
import com.alibaba.csp.sentinel.command.annotation.CommandMapping;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class Producer {
|
||||||
|
@Autowired
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
public void datasource(String ip) {
|
||||||
|
rabbitTemplate.convertAndSend("datasource",ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -48,6 +48,15 @@ public interface IEnterpriseService
|
||||||
*/
|
*/
|
||||||
public int updateEnterprise(Enterprise enterprise);
|
public int updateEnterprise(Enterprise enterprise);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断唯一
|
||||||
|
*/
|
||||||
|
Integer oneName(String enterpriseName);
|
||||||
|
|
||||||
|
Integer onePhone(String contactPhone);
|
||||||
|
|
||||||
|
Integer oneEmail(String email);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业认证
|
* 企业认证
|
||||||
* @param id
|
* @param id
|
||||||
|
@ -85,4 +94,7 @@ public interface IEnterpriseService
|
||||||
List<Sources> listSources();
|
List<Sources> listSources();
|
||||||
|
|
||||||
int indexCustom(Custom custom);
|
int indexCustom(Custom custom);
|
||||||
|
|
||||||
|
List<Custom> listCustom();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
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;
|
||||||
|
@ -11,10 +12,12 @@ import com.muyu.common.system.domain.LoginUser;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.goods.domain.Custom;
|
import com.muyu.goods.domain.Custom;
|
||||||
import com.muyu.goods.domain.Sources;
|
import com.muyu.goods.domain.Sources;
|
||||||
|
import com.muyu.goods.mq.Producer;
|
||||||
import com.muyu.goods.pojo.HttpClient;
|
import com.muyu.goods.pojo.HttpClient;
|
||||||
import com.muyu.system.remote.RemoteSystemManageService;
|
import com.muyu.system.remote.RemoteSystemManageService;
|
||||||
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.Component;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.goods.mapper.EnterpriseMapper;
|
import com.muyu.goods.mapper.EnterpriseMapper;
|
||||||
import com.muyu.goods.domain.Enterprise;
|
import com.muyu.goods.domain.Enterprise;
|
||||||
|
@ -35,6 +38,8 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
||||||
private RemoteSystemManageService remoteSystemManageService;
|
private RemoteSystemManageService remoteSystemManageService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private EnterpriseConfig enterpriseConfig;
|
private EnterpriseConfig enterpriseConfig;
|
||||||
|
@Autowired
|
||||||
|
private Producer producer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询企业
|
* 查询企业
|
||||||
|
@ -97,6 +102,21 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
||||||
return enterpriseMapper.updateEnterprise(enterprise);
|
return enterpriseMapper.updateEnterprise(enterprise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer oneName(String enterpriseName) {
|
||||||
|
return enterpriseMapper.oneName(enterpriseName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer onePhone(String contactPhone) {
|
||||||
|
return enterpriseMapper.onePhone(contactPhone);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer oneEmail(String email) {
|
||||||
|
return enterpriseMapper.oneEmail(email);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 企业认证
|
* 企业认证
|
||||||
* @param id
|
* @param id
|
||||||
|
@ -121,6 +141,8 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
||||||
Sources sources = Sources.index(enterprise1.getId(),"enterprise" + enterprise1.getId(), String.valueOf((int) (enterprise.getId() + 3306)));
|
Sources sources = Sources.index(enterprise1.getId(),"enterprise" + enterprise1.getId(), String.valueOf((int) (enterprise.getId() + 3306)));
|
||||||
System.out.println(sources);
|
System.out.println(sources);
|
||||||
enterpriseMapper.indexSources(sources);
|
enterpriseMapper.indexSources(sources);
|
||||||
|
System.out.println(sources.getIp());
|
||||||
|
producer.datasource(sources.getIp());
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -209,14 +231,19 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Sources> listSources() {
|
public List<Sources> listSources() {
|
||||||
|
// producer.datasource("3306");
|
||||||
return enterpriseMapper.listSources(new QueryWrapper<>());
|
return enterpriseMapper.listSources(new QueryWrapper<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int indexCustom(Custom custom) {
|
public int indexCustom(Custom custom) {
|
||||||
System.out.println(custom);
|
int i = enterpriseMapper.indexCustom(custom);
|
||||||
// int i = enterpriseMapper.indexCustom(custom);
|
return i;
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Custom> listCustom() {
|
||||||
|
return enterpriseMapper.listCustom();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<select id="listSources" resultType="com.muyu.goods.domain.Sources">
|
<select id="listSources" resultType="com.muyu.goods.domain.Sources">
|
||||||
select * from sources
|
select * from sources
|
||||||
</select>
|
</select>
|
||||||
|
<select id="listCustom" resultType="com.muyu.goods.domain.Custom">
|
||||||
|
select *
|
||||||
|
from custom
|
||||||
|
</select>
|
||||||
|
<select id="oneName" resultType="java.lang.Integer">
|
||||||
|
select count(enterprise_name) from enterprise where enterprise_name = #{enterpriseName}
|
||||||
|
</select>
|
||||||
|
<select id="onePhone" resultType="java.lang.Integer">
|
||||||
|
select count(contact_phone) from enterprise where contact_phone = #{contactPhone}
|
||||||
|
</select>
|
||||||
|
<select id="oneEmail" resultType="java.lang.Integer">
|
||||||
|
select count(email) from enterprise where email = #{email}
|
||||||
|
</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">
|
||||||
|
|
|
@ -95,6 +95,13 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- rabbitmq-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class DruidConfig {
|
||||||
* 获取多数据源信息列表
|
* 获取多数据源信息列表
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<DataSourceInfo> getDataSourceInfoList(){
|
public List<DataSourceInfo> getDataSourceInfoList(){
|
||||||
List<Sources> listResult = remoteSourcesService.listSources().getData();
|
List<Sources> listResult = remoteSourcesService.listSources().getData();
|
||||||
System.out.println(listResult);
|
System.out.println(listResult);
|
||||||
List<String> databaseNameList = new ArrayList<>();
|
List<String> databaseNameList = new ArrayList<>();
|
||||||
|
@ -79,11 +79,11 @@ public class DruidConfig {
|
||||||
@Primary
|
@Primary
|
||||||
public DynamicDataSource dynamicDataSource() {
|
public DynamicDataSource dynamicDataSource() {
|
||||||
//获取列表 获取多数据源信息
|
//获取列表 获取多数据源信息
|
||||||
|
|
||||||
Map<Object, Object> dataSourceMap = new HashMap<>();
|
Map<Object, Object> dataSourceMap = new HashMap<>();
|
||||||
getDataSourceInfoList().forEach(dataSourceInfo -> {
|
getDataSourceInfoList().forEach(dataSourceInfo -> {
|
||||||
dataSourceMap.put(dataSourceInfo.getIp(), createDataSourceConnection(dataSourceInfo));
|
dataSourceMap.put(dataSourceInfo.getIp(), createDataSourceConnection(dataSourceInfo));
|
||||||
});
|
});
|
||||||
|
System.out.println(getDataSourceInfoList());
|
||||||
// System.out.println(dataSourceMap);
|
// System.out.println(dataSourceMap);
|
||||||
//设置动态数据源
|
//设置动态数据源
|
||||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||||
|
@ -92,6 +92,5 @@ public class DruidConfig {
|
||||||
//将数据源信息备份在defineTargetDataSources中
|
//将数据源信息备份在defineTargetDataSources中
|
||||||
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
||||||
return dynamicDataSource;
|
return dynamicDataSource;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.cloud.mq;
|
||||||
|
|
||||||
|
import com.muyu.cloud.controller.CloudController;
|
||||||
|
import com.muyu.cloud.datasource.config.DruidConfig;
|
||||||
|
import com.muyu.cloud.datasource.config.DynamicDataSource;
|
||||||
|
import com.muyu.cloud.datasource.config.contents.DataSourceInfo;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
public class Consumer {
|
||||||
|
@Autowired
|
||||||
|
private DruidConfig druidConfig;
|
||||||
|
@Autowired
|
||||||
|
private CloudController controller;
|
||||||
|
|
||||||
|
@RabbitListener(queuesToDeclare = {@Queue("datasource")})
|
||||||
|
public void dataSource(String ip){
|
||||||
|
System.out.println(ip);
|
||||||
|
DynamicDataSource dynamicDataSource = druidConfig.dynamicDataSource();
|
||||||
|
log.info("初始化:{}",dynamicDataSource);
|
||||||
|
// druidConfig.getDataSourceInfoList();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue