多租户调整

This commit is contained in:
kerwincui
2022-06-05 00:18:29 +08:00
parent 3fea5132ce
commit 6e0becee7c
6 changed files with 27 additions and 9 deletions

View File

@@ -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);

View File

@@ -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);
}
/**