fast()补充唯一
parent
a560229583
commit
d3f9814aba
|
@ -136,6 +136,7 @@
|
|||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -29,6 +29,14 @@
|
|||
<artifactId>muyu-modules-system</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MQ依赖-->
|
||||
<!-- rabbitmq-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -109,6 +109,36 @@ public class EnterpriseController extends BaseController
|
|||
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
|
||||
|
@ -174,4 +204,13 @@ public class EnterpriseController extends BaseController
|
|||
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();
|
||||
|
||||
/**
|
||||
* 判断唯一
|
||||
* @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);
|
||||
|
||||
|
||||
|
@ -78,4 +88,7 @@ public interface EnterpriseMapper
|
|||
List<Sources> listSources(QueryWrapper<Object> objectQueryWrapper);
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* 判断唯一
|
||||
*/
|
||||
Integer oneName(String enterpriseName);
|
||||
|
||||
Integer onePhone(String contactPhone);
|
||||
|
||||
Integer oneEmail(String email);
|
||||
|
||||
/**
|
||||
* 企业认证
|
||||
* @param id
|
||||
|
@ -85,4 +94,7 @@ public interface IEnterpriseService
|
|||
List<Sources> listSources();
|
||||
|
||||
int indexCustom(Custom custom);
|
||||
|
||||
List<Custom> listCustom();
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
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.goods.domain.Custom;
|
||||
import com.muyu.goods.domain.Sources;
|
||||
import com.muyu.goods.mq.Producer;
|
||||
import com.muyu.goods.pojo.HttpClient;
|
||||
import com.muyu.system.remote.RemoteSystemManageService;
|
||||
import muyu.goods.enterprise.client.config.EnterpriseConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.goods.mapper.EnterpriseMapper;
|
||||
import com.muyu.goods.domain.Enterprise;
|
||||
|
@ -35,6 +38,8 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
|||
private RemoteSystemManageService remoteSystemManageService;
|
||||
@Autowired
|
||||
private EnterpriseConfig enterpriseConfig;
|
||||
@Autowired
|
||||
private Producer producer;
|
||||
|
||||
/**
|
||||
* 查询企业
|
||||
|
@ -97,6 +102,21 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
|||
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
|
||||
|
@ -121,6 +141,8 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
|||
Sources sources = Sources.index(enterprise1.getId(),"enterprise" + enterprise1.getId(), String.valueOf((int) (enterprise.getId() + 3306)));
|
||||
System.out.println(sources);
|
||||
enterpriseMapper.indexSources(sources);
|
||||
System.out.println(sources.getIp());
|
||||
producer.datasource(sources.getIp());
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -209,14 +231,19 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
|||
|
||||
@Override
|
||||
public List<Sources> listSources() {
|
||||
// producer.datasource("3306");
|
||||
return enterpriseMapper.listSources(new QueryWrapper<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexCustom(Custom custom) {
|
||||
System.out.println(custom);
|
||||
// int i = enterpriseMapper.indexCustom(custom);
|
||||
return 0;
|
||||
int i = enterpriseMapper.indexCustom(custom);
|
||||
return i;
|
||||
}
|
||||
|
||||
@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 * from sources
|
||||
</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">
|
||||
|
|
|
@ -95,6 +95,13 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- rabbitmq-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -31,7 +31,7 @@ public class DruidConfig {
|
|||
* 获取多数据源信息列表
|
||||
* @return
|
||||
*/
|
||||
private List<DataSourceInfo> getDataSourceInfoList(){
|
||||
public List<DataSourceInfo> getDataSourceInfoList(){
|
||||
List<Sources> listResult = remoteSourcesService.listSources().getData();
|
||||
System.out.println(listResult);
|
||||
List<String> databaseNameList = new ArrayList<>();
|
||||
|
@ -79,11 +79,11 @@ public class DruidConfig {
|
|||
@Primary
|
||||
public DynamicDataSource dynamicDataSource() {
|
||||
//获取列表 获取多数据源信息
|
||||
|
||||
Map<Object, Object> dataSourceMap = new HashMap<>();
|
||||
getDataSourceInfoList().forEach(dataSourceInfo -> {
|
||||
dataSourceMap.put(dataSourceInfo.getIp(), createDataSourceConnection(dataSourceInfo));
|
||||
});
|
||||
System.out.println(getDataSourceInfoList());
|
||||
// System.out.println(dataSourceMap);
|
||||
//设置动态数据源
|
||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||
|
@ -92,6 +92,5 @@ public class DruidConfig {
|
|||
//将数据源信息备份在defineTargetDataSources中
|
||||
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
||||
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