mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 08:25:53 +08:00
多租户调整
This commit is contained in:
@@ -32,7 +32,7 @@ public class ProductAuthorizeController extends BaseController
|
||||
/**
|
||||
* 查询产品授权码列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:authorize:list')")
|
||||
@PreAuthorize("@ss.hasPermi('iot:product:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ProductAuthorize productAuthorize)
|
||||
{
|
||||
|
||||
@@ -35,10 +35,10 @@ public interface ProductMapper
|
||||
/**
|
||||
* 查询产品简短列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param product 产品
|
||||
* @return 产品集合
|
||||
*/
|
||||
public List<IdAndName> selectProductShortList(Long userId);
|
||||
public List<IdAndName> selectProductShortList(Product product);
|
||||
|
||||
/**
|
||||
* 新增产品
|
||||
|
||||
@@ -426,6 +426,13 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
device.setTenantId(sysUser.getUserId());
|
||||
device.setTenantName(sysUser.getUserName());
|
||||
device.setRssi(0);
|
||||
// 随机经纬度
|
||||
if(device.getLongitude()==null || device.getLongitude().equals("")){
|
||||
device.setLongitude(BigDecimal.valueOf(116.23-(Math.random()*15)));
|
||||
}
|
||||
if(device.getLatitude()==null || device.getLatitude().equals("")){
|
||||
device.setLatitude(BigDecimal.valueOf(39.54-(Math.random()*15)));
|
||||
}
|
||||
Product product=productService.selectProductByProductId(device.getProductId());
|
||||
device.setImgUrl(product.getImgUrl());
|
||||
deviceMapper.insertDevice(device);
|
||||
|
||||
@@ -76,8 +76,14 @@ public class ProductServiceImpl implements IProductService
|
||||
@Override
|
||||
public List<IdAndName> selectProductShortList()
|
||||
{
|
||||
Product product =new Product();
|
||||
SysUser user = getLoginUser().getUser();
|
||||
return productMapper.selectProductShortList(user.getUserId());
|
||||
List<SysRole> roles=user.getRoles();
|
||||
// 租户
|
||||
if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
|
||||
product.setTenantId(user.getUserId());
|
||||
}
|
||||
return productMapper.selectProductShortList(product);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -125,10 +125,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="selectAllDeviceShortList" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceAllShortResult">
|
||||
select device_id, device_name, product_name, user_name, serial_number, firmware_version, status,rssi,is_shadow ,
|
||||
is_custom_location, active_time,network_address,longitude,latitude from iot_device
|
||||
select d.device_id, d.device_name, d.product_name, d.user_name, d.serial_number, d.firmware_version, d.status,d.rssi,d.is_shadow ,
|
||||
d.is_custom_location, d.active_time,d.network_address,d.longitude,latitude
|
||||
from iot_device d
|
||||
left join iot_device_user u on u.device_id = d.device_id
|
||||
<where>
|
||||
<if test="userId != null and userId != ''"> and user_id = #{userId}</if>
|
||||
<if test="userId != null "> and u.user_id = #{userId}</if>
|
||||
<if test="tenantId != null "> and d.tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
@@ -51,9 +51,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectProductShortList" parameterType="Long" resultMap="ProductShortResult">
|
||||
<select id="selectProductShortList" parameterType="com.ruoyi.iot.domain.Product" resultMap="ProductShortResult">
|
||||
select product_id,product_name from iot_product
|
||||
where tenant_id=#{userId} or is_sys = 1
|
||||
<where>
|
||||
<if test="tenantId != null and tenantId != 0"> and tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user