feat:多数据源完工
parent
060b2fa2f8
commit
06fbdd9fdb
|
@ -48,6 +48,12 @@ public class EntinfoController extends BaseController
|
|||
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())
|
||||
.phonenumber(business.getBusinessPhone())
|
||||
.loginIp("111.229.102.61")
|
||||
.roleId(Long.valueOf(2))
|
||||
.userType(String.valueOf(business.getId()))
|
||||
.build();
|
||||
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;
|
||||
|
||||
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.system.domain.SysFile;
|
||||
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.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件服务
|
||||
*
|
||||
|
@ -29,7 +32,10 @@ public interface RemoteFileService {
|
|||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public Result<SysFile> upload (@RequestPart(value = "file") MultipartFile file);
|
||||
|
||||
|
||||
@GetMapping(value = "/{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;
|
||||
|
||||
import com.zhiLian.common.core.domain.Entinfo;
|
||||
import com.zhiLian.common.core.domain.Result;
|
||||
import com.zhiLian.common.system.remote.RemoteFileService;
|
||||
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.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件服务降级处理
|
||||
*
|
||||
|
@ -31,6 +34,11 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
|
|||
public Result getInfo(Long id) {
|
||||
return Result.error("获取失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entinfo> listAll() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,4 +66,6 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
|||
* @return 结果
|
||||
*/
|
||||
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);
|
||||
// 新增用户与角色管理
|
||||
if (null == user.getRoleId()|| user.getRoleId().equals("")){
|
||||
user.setRoleId(Long.valueOf(2));
|
||||
insertUserRole(user);
|
||||
return rows;
|
||||
if (2 == user.getRoleId()){
|
||||
SysUserRole sysUserRole = new SysUserRole();
|
||||
sysUserRole.setRoleId(Long.valueOf(2));
|
||||
sysUserRole.setUserId(user.getUserId());
|
||||
userRoleMapper.insertUserRole(sysUserRole);
|
||||
}
|
||||
insertUserRole(user);
|
||||
return rows;
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
(#{item.userId},#{item.roleId})
|
||||
</foreach>
|
||||
</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
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.zhiLian.common.log.annotation.Log;
|
|||
import com.zhiLian.common.log.enums.BusinessType;
|
||||
import com.zhiLian.vehicle.domain.Vehicle;
|
||||
import com.zhiLian.vehicle.service.IVehicleService;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSON;
|
|||
import com.rabbitmq.client.Channel;
|
||||
import com.zhiLian.common.core.utils.SpringUtils;
|
||||
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.role.DynamicDataSource;
|
||||
import com.zhiLian.vehicle.datasource.domain.DataSourceInfo;
|
||||
|
@ -43,6 +44,9 @@ public class ManyDataSource {
|
|||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
|
||||
// @Autowired
|
||||
// private RemoteFileService remoteFileService;
|
||||
|
||||
|
||||
//调用注解 添加队列名称
|
||||
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
|
||||
|
@ -107,6 +111,8 @@ public class ManyDataSource {
|
|||
.port(3306)
|
||||
.build());
|
||||
}};
|
||||
// List<com.zhiLian.common.core.domain.Entinfo> entinfos = remoteFileService.listAll();
|
||||
// databaseNameList.a(entinfos)
|
||||
List<String> entinfo = redisTemplate.opsForList().range("entinfo", 0, -1);
|
||||
|
||||
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.remote.RemoteFileService;
|
||||
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.mapper.VehicleMapper;
|
||||
import com.zhiLian.vehicle.service.IVehicleService;
|
||||
|
@ -66,6 +67,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle>
|
|||
if (user.getUserType().equals("00")) {
|
||||
return vehicleMapper.selectVehicleList(vehicle);
|
||||
}
|
||||
|
||||
// vehicle.setBusinessId(Long.valueOf(user.getUserType()));
|
||||
List<Vehicle> vehicles = vehicleMapper.selectVehicleList(vehicle);
|
||||
// vehicles.forEach(vehicle1 -> {
|
||||
|
|
Loading…
Reference in New Issue