mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-19 17:35:54 +08:00
后端多租户调整
This commit is contained in:
@@ -69,8 +69,5 @@ public interface ICategoryService
|
||||
*/
|
||||
public int deleteCategoryByCategoryId(Long categoryId);
|
||||
|
||||
// 精准查询
|
||||
List<Category> selectCategoryListAccurate(Category category);
|
||||
|
||||
List<IdAndName> selectCategoryShortListAccurate(Category category);
|
||||
}
|
||||
|
||||
@@ -172,10 +172,4 @@ public interface IDeviceService
|
||||
*/
|
||||
List<Device> selectDeviceListAccurate(Device device);
|
||||
|
||||
/**
|
||||
* 精准查询所有条件设备的简短信息
|
||||
* @param device
|
||||
* @return
|
||||
*/
|
||||
List<DeviceShortOutput> selectDeviceShortListAccurate(Device device);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,4 @@ public interface IGroupService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGroupByGroupId(Long groupId);
|
||||
|
||||
// 精准查询
|
||||
List<Group> selectGroupListAccurate(Group group);
|
||||
}
|
||||
|
||||
@@ -78,6 +78,4 @@ public interface IProductService
|
||||
*/
|
||||
public int deleteProductByProductId(Long productId);
|
||||
|
||||
// 精准查询
|
||||
List<Product> selectProductListAccurate(Product product);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,4 @@ public interface IThingsModelTemplateService
|
||||
*/
|
||||
public int deleteThingsModelTemplateByTemplateId(Long templateId);
|
||||
|
||||
// 精准查询
|
||||
List<ThingsModelTemplate> selectThingsModelTemplateListAccurate(ThingsModelTemplate thingsModelTemplate);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ public class CategoryServiceImpl implements ICategoryService
|
||||
@Override
|
||||
public List<Category> selectCategoryList(Category category)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
List<SysRole> roles=user.getRoles();
|
||||
// 租户
|
||||
if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
|
||||
category.setTenantId(user.getUserId());
|
||||
}
|
||||
return categoryMapper.selectCategoryList(category);
|
||||
}
|
||||
|
||||
@@ -132,9 +138,4 @@ public class CategoryServiceImpl implements ICategoryService
|
||||
{
|
||||
return categoryMapper.deleteCategoryByCategoryId(categoryId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Category> selectCategoryListAccurate(Category category) {
|
||||
return categoryMapper.selectCategoryListAccurate(category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.iot.service.impl;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
@@ -218,6 +219,17 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
*/
|
||||
@Override
|
||||
public List<Device> selectDeviceList(Device device) {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
List<SysRole> roles=user.getRoles();
|
||||
for(int i=0;i<roles.size();i++){
|
||||
if(roles.get(i).getRoleKey().equals("tenant")){
|
||||
// 租户查看产品下所有设备
|
||||
device.setTenantId(user.getUserId());
|
||||
}else if (roles.get(i).getRoleKey().equals("general")){
|
||||
// 用户查看自己设备
|
||||
device.setUserId(user.getUserId());
|
||||
}
|
||||
}
|
||||
return deviceMapper.selectDeviceList(device);
|
||||
}
|
||||
|
||||
@@ -241,6 +253,20 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
@Override
|
||||
public List<DeviceShortOutput> selectDeviceShortList(Device device) {
|
||||
// TODO 关联设备用户表
|
||||
|
||||
SysUser user = getLoginUser().getUser();
|
||||
List<SysRole> roles=user.getRoles();
|
||||
for(int i=0;i<roles.size();i++){
|
||||
if(roles.get(i).getRoleKey().equals("tenant")){
|
||||
// 租户查看产品下所有设备
|
||||
device.setTenantId(user.getUserId());
|
||||
break;
|
||||
}else if (roles.get(i).getRoleKey().equals("general")){
|
||||
// 用户查看自己设备
|
||||
device.setUserId(user.getUserId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<DeviceShortOutput> deviceList = deviceMapper.selectDeviceShortList(device);
|
||||
for (int i = 0; i < deviceList.size(); i++) {
|
||||
JSONObject thingsModelObject = JSONObject.parseObject(thingsModelService.getCacheThingsModelByProductId(deviceList.get(i).getProductId()));
|
||||
@@ -254,11 +280,6 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
return deviceList;
|
||||
}
|
||||
|
||||
// 精准查询所有条件的设备
|
||||
@Override
|
||||
public List<DeviceShortOutput> selectDeviceShortListAccurate(Device device) {
|
||||
return deviceMapper.selectDeviceShortListAccurate(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* Json物模型集合转换为对象中的分类集合
|
||||
|
||||
@@ -46,6 +46,12 @@ public class FirmwareServiceImpl implements IFirmwareService
|
||||
@Override
|
||||
public List<Firmware> selectFirmwareList(Firmware firmware)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
List<SysRole> roles=user.getRoles();
|
||||
// 租户
|
||||
if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
|
||||
firmware.setTenantId(user.getUserId());
|
||||
}
|
||||
return firmwareMapper.selectFirmwareList(firmware);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.iot.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.iot.domain.Group;
|
||||
@@ -63,6 +64,15 @@ public class GroupServiceImpl implements IGroupService
|
||||
@Override
|
||||
public List<Group> selectGroupList(Group group)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
List<SysRole> roles=user.getRoles();
|
||||
for(int i=0;i<roles.size();i++){
|
||||
if (roles.get(i).getRoleKey().equals("general")){
|
||||
// 用户查看自己设备
|
||||
group.setUserId(user.getUserId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
return groupMapper.selectGroupList(group);
|
||||
}
|
||||
|
||||
@@ -140,9 +150,4 @@ public class GroupServiceImpl implements IGroupService
|
||||
return groupMapper.deleteGroupByGroupId(groupId);
|
||||
}
|
||||
|
||||
// 精准查询所有
|
||||
@Override
|
||||
public List<Group> selectGroupListAccurate(Group group) {
|
||||
return groupMapper.selectGroupListAccurate(group);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,12 @@ public class ProductServiceImpl implements IProductService
|
||||
@Override
|
||||
public List<Product> selectProductList(Product product)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
List<SysRole> roles=user.getRoles();
|
||||
// 租户
|
||||
if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
|
||||
product.setTenantId(user.getUserId());
|
||||
}
|
||||
return productMapper.selectProductList(product);
|
||||
}
|
||||
|
||||
@@ -194,9 +200,4 @@ public class ProductServiceImpl implements IProductService
|
||||
redisCache.deleteObject(tslPreKey+productId);
|
||||
return productMapper.deleteProductByProductId(productId);
|
||||
}
|
||||
// 精准查询
|
||||
@Override
|
||||
public List<Product> selectProductListAccurate(Product product) {
|
||||
return productMapper.selectProductListAccurate(product);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,12 @@ public class ThingsModelTemplateServiceImpl implements IThingsModelTemplateServi
|
||||
@Override
|
||||
public List<ThingsModelTemplate> selectThingsModelTemplateList(ThingsModelTemplate thingsModelTemplate)
|
||||
{
|
||||
SysUser user = getLoginUser().getUser();
|
||||
List<SysRole> roles=user.getRoles();
|
||||
// 租户
|
||||
if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
|
||||
thingsModelTemplate.setTenantId(user.getUserId());
|
||||
}
|
||||
return thingsModelTemplateMapper.selectThingsModelTemplateList(thingsModelTemplate);
|
||||
}
|
||||
|
||||
@@ -108,9 +114,4 @@ public class ThingsModelTemplateServiceImpl implements IThingsModelTemplateServi
|
||||
{
|
||||
return thingsModelTemplateMapper.deleteThingsModelTemplateByTemplateId(templateId);
|
||||
}
|
||||
// 精准查询
|
||||
@Override
|
||||
public List<ThingsModelTemplate> selectThingsModelTemplateListAccurate(ThingsModelTemplate thingsModelTemplate) {
|
||||
return thingsModelTemplateMapper.selectThingsModelTemplateListAccurate(thingsModelTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user