feat:多数据源完工
parent
060b2fa2f8
commit
06fbdd9fdb
|
@ -48,6 +48,12 @@ public class EntinfoController extends BaseController
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("ListAll")
|
||||||
|
public List<Entinfo> listAll(){
|
||||||
|
List<Entinfo> list = entinfoService.list();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出多数据源列表
|
* 导出多数据源列表
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.zhiLian.business.feign;
|
||||||
|
|
||||||
|
|
||||||
|
import com.zhiLian.business.domain.Entinfo;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BingRui.Hou
|
||||||
|
*
|
||||||
|
* @Description 描述
|
||||||
|
* @ClassName EntInfoFeign
|
||||||
|
* @Date 2024/06/07 17:25
|
||||||
|
*/
|
||||||
|
@FeignClient(value = "zhiLian-business-service")
|
||||||
|
public interface EntInfoFeign {
|
||||||
|
@GetMapping("ListAll")
|
||||||
|
public List<Entinfo> listAll();
|
||||||
|
}
|
|
@ -108,6 +108,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
||||||
.email(business.getBusinessEmail())
|
.email(business.getBusinessEmail())
|
||||||
.phonenumber(business.getBusinessPhone())
|
.phonenumber(business.getBusinessPhone())
|
||||||
.loginIp("111.229.102.61")
|
.loginIp("111.229.102.61")
|
||||||
|
.roleId(Long.valueOf(2))
|
||||||
.userType(String.valueOf(business.getId()))
|
.userType(String.valueOf(business.getId()))
|
||||||
.build();
|
.build();
|
||||||
Result add = remoteUserService.add(sysUser);
|
Result add = remoteUserService.add(sysUser);
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.zhiLian.common.core.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.zhiLian.common.core.annotation.Excel;
|
||||||
|
import com.zhiLian.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多数据源对象 entinfo
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-06-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("entinfo")
|
||||||
|
public class Entinfo extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 数据源key */
|
||||||
|
@Excel(name = "数据源key")
|
||||||
|
private String entCode;
|
||||||
|
|
||||||
|
/** 数据源ip */
|
||||||
|
@Excel(name = "数据源ip")
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
/** 数据源端口 */
|
||||||
|
@Excel(name = "数据源端口")
|
||||||
|
private Integer port;
|
||||||
|
|
||||||
|
/** 数据源ID */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.zhiLian.common.system.remote;
|
package com.zhiLian.common.system.remote;
|
||||||
|
|
||||||
import com.zhiLian.common.core.constant.ServiceNameConstants;
|
import com.zhiLian.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.zhiLian.common.core.domain.Entinfo;
|
||||||
import com.zhiLian.common.core.domain.Result;
|
import com.zhiLian.common.core.domain.Result;
|
||||||
import com.zhiLian.common.system.domain.SysFile;
|
import com.zhiLian.common.system.domain.SysFile;
|
||||||
import com.zhiLian.common.system.remote.factory.RemoteFileFallbackFactory;
|
import com.zhiLian.common.system.remote.factory.RemoteFileFallbackFactory;
|
||||||
|
@ -12,6 +13,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件服务
|
* 文件服务
|
||||||
*
|
*
|
||||||
|
@ -29,7 +32,10 @@ public interface RemoteFileService {
|
||||||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public Result<SysFile> upload (@RequestPart(value = "file") MultipartFile file);
|
public Result<SysFile> upload (@RequestPart(value = "file") MultipartFile file);
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public Result getInfo(@PathVariable("id") Long id);
|
public Result getInfo(@PathVariable("id") Long id);
|
||||||
|
@GetMapping("ListAll")
|
||||||
|
public List<Entinfo> listAll();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.zhiLian.common.system.remote.factory;
|
package com.zhiLian.common.system.remote.factory;
|
||||||
|
|
||||||
|
import com.zhiLian.common.core.domain.Entinfo;
|
||||||
import com.zhiLian.common.core.domain.Result;
|
import com.zhiLian.common.core.domain.Result;
|
||||||
import com.zhiLian.common.system.remote.RemoteFileService;
|
import com.zhiLian.common.system.remote.RemoteFileService;
|
||||||
import com.zhiLian.common.system.domain.SysFile;
|
import com.zhiLian.common.system.domain.SysFile;
|
||||||
|
@ -9,6 +10,8 @@ import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件服务降级处理
|
* 文件服务降级处理
|
||||||
*
|
*
|
||||||
|
@ -31,6 +34,11 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
|
||||||
public Result getInfo(Long id) {
|
public Result getInfo(Long id) {
|
||||||
return Result.error("获取失败:" + throwable.getMessage());
|
return Result.error("获取失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Entinfo> listAll() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,4 +66,6 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteUserRoleInfos (@Param("roleId") Long roleId, @Param("userIds") Long[] userIds);
|
public int deleteUserRoleInfos (@Param("roleId") Long roleId, @Param("userIds") Long[] userIds);
|
||||||
|
|
||||||
|
void insertUserRole(SysUserRole sysUserRole);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,10 +241,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
// 新增用户岗位关联
|
// 新增用户岗位关联
|
||||||
insertUserPost(user);
|
insertUserPost(user);
|
||||||
// 新增用户与角色管理
|
// 新增用户与角色管理
|
||||||
if (null == user.getRoleId()|| user.getRoleId().equals("")){
|
if (2 == user.getRoleId()){
|
||||||
user.setRoleId(Long.valueOf(2));
|
SysUserRole sysUserRole = new SysUserRole();
|
||||||
insertUserRole(user);
|
sysUserRole.setRoleId(Long.valueOf(2));
|
||||||
return rows;
|
sysUserRole.setUserId(user.getUserId());
|
||||||
|
userRoleMapper.insertUserRole(sysUserRole);
|
||||||
}
|
}
|
||||||
insertUserRole(user);
|
insertUserRole(user);
|
||||||
return rows;
|
return rows;
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
(#{item.userId},#{item.roleId})
|
(#{item.userId},#{item.roleId})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="insertUserRole">
|
||||||
|
insert into sys_user_role(user_id, role_id)
|
||||||
|
values (#{userId}, #{roleId})
|
||||||
|
</insert>
|
||||||
|
|
||||||
<delete id="deleteUserRoleInfo" parameterType="com.zhiLian.system.domain.SysUserRole">
|
<delete id="deleteUserRoleInfo" parameterType="com.zhiLian.system.domain.SysUserRole">
|
||||||
delete
|
delete
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.zhiLian.common.log.annotation.Log;
|
||||||
import com.zhiLian.common.log.enums.BusinessType;
|
import com.zhiLian.common.log.enums.BusinessType;
|
||||||
import com.zhiLian.vehicle.domain.Vehicle;
|
import com.zhiLian.vehicle.domain.Vehicle;
|
||||||
import com.zhiLian.vehicle.service.IVehicleService;
|
import com.zhiLian.vehicle.service.IVehicleService;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSON;
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
import com.zhiLian.common.core.utils.SpringUtils;
|
import com.zhiLian.common.core.utils.SpringUtils;
|
||||||
import com.zhiLian.common.redis.service.RedisService;
|
import com.zhiLian.common.redis.service.RedisService;
|
||||||
|
import com.zhiLian.common.system.remote.RemoteFileService;
|
||||||
import com.zhiLian.vehicle.datasource.config.factory.DruidDataSourceFactory;
|
import com.zhiLian.vehicle.datasource.config.factory.DruidDataSourceFactory;
|
||||||
import com.zhiLian.vehicle.datasource.config.role.DynamicDataSource;
|
import com.zhiLian.vehicle.datasource.config.role.DynamicDataSource;
|
||||||
import com.zhiLian.vehicle.datasource.domain.DataSourceInfo;
|
import com.zhiLian.vehicle.datasource.domain.DataSourceInfo;
|
||||||
|
@ -43,6 +44,9 @@ public class ManyDataSource {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisTemplate<String,String> redisTemplate;
|
private RedisTemplate<String,String> redisTemplate;
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// private RemoteFileService remoteFileService;
|
||||||
|
|
||||||
|
|
||||||
//调用注解 添加队列名称
|
//调用注解 添加队列名称
|
||||||
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
|
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
|
||||||
|
@ -107,6 +111,8 @@ public class ManyDataSource {
|
||||||
.port(3306)
|
.port(3306)
|
||||||
.build());
|
.build());
|
||||||
}};
|
}};
|
||||||
|
// List<com.zhiLian.common.core.domain.Entinfo> entinfos = remoteFileService.listAll();
|
||||||
|
// databaseNameList.a(entinfos)
|
||||||
List<String> entinfo = redisTemplate.opsForList().range("entinfo", 0, -1);
|
List<String> entinfo = redisTemplate.opsForList().range("entinfo", 0, -1);
|
||||||
|
|
||||||
entinfo.forEach(string -> {
|
entinfo.forEach(string -> {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.zhiLian.common.system.domain.LoginUser;
|
||||||
import com.zhiLian.common.system.domain.SysUser;
|
import com.zhiLian.common.system.domain.SysUser;
|
||||||
import com.zhiLian.common.system.remote.RemoteFileService;
|
import com.zhiLian.common.system.remote.RemoteFileService;
|
||||||
import com.zhiLian.common.system.remote.RemoteUserService;
|
import com.zhiLian.common.system.remote.RemoteUserService;
|
||||||
|
import com.zhiLian.vehicle.datasource.config.role.DynamicDataSource;
|
||||||
import com.zhiLian.vehicle.domain.Vehicle;
|
import com.zhiLian.vehicle.domain.Vehicle;
|
||||||
import com.zhiLian.vehicle.mapper.VehicleMapper;
|
import com.zhiLian.vehicle.mapper.VehicleMapper;
|
||||||
import com.zhiLian.vehicle.service.IVehicleService;
|
import com.zhiLian.vehicle.service.IVehicleService;
|
||||||
|
@ -66,6 +67,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle>
|
||||||
if (user.getUserType().equals("00")) {
|
if (user.getUserType().equals("00")) {
|
||||||
return vehicleMapper.selectVehicleList(vehicle);
|
return vehicleMapper.selectVehicleList(vehicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// vehicle.setBusinessId(Long.valueOf(user.getUserType()));
|
// vehicle.setBusinessId(Long.valueOf(user.getUserType()));
|
||||||
List<Vehicle> vehicles = vehicleMapper.selectVehicleList(vehicle);
|
List<Vehicle> vehicles = vehicleMapper.selectVehicleList(vehicle);
|
||||||
// vehicles.forEach(vehicle1 -> {
|
// vehicles.forEach(vehicle1 -> {
|
||||||
|
|
Loading…
Reference in New Issue