多租户接口调整

This commit is contained in:
kerwincui
2022-06-04 00:51:14 +08:00
parent 4999c2abcb
commit 46aa17f320
12 changed files with 56 additions and 113 deletions

View File

@@ -69,5 +69,4 @@ public interface ICategoryService
*/
public int deleteCategoryByCategoryId(Long categoryId);
List<IdAndName> selectCategoryShortListAccurate(Category category);
}

View File

@@ -158,18 +158,5 @@ public interface IDeviceService
*/
public int resetDeviceStatus(String deviceNum);
/**
* 获取所有简短设备列表
* @param userName
* @return
*/
List<DeviceAllShortOutput> selectAllDeviceShortListAccurate(String userName);
/**
* 精准查询
* @param device
* @return
*/
List<Device> selectDeviceListAccurate(Device device);
}

View File

@@ -65,7 +65,14 @@ public class CategoryServiceImpl implements ICategoryService
@Override
public List<IdAndName> selectCategoryShortList()
{
return categoryMapper.selectCategoryShortList();
Category category=new 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.selectCategoryShortList(category);
}
/**
@@ -103,11 +110,6 @@ public class CategoryServiceImpl implements ICategoryService
return categoryMapper.updateCategory(category);
}
@Override
public List<IdAndName> selectCategoryShortListAccurate(Category category) {
return categoryMapper.selectCategoryShortListAccurate(category);
}
/**
* 批量删除产品分类
*

View File

@@ -240,8 +240,19 @@ public class DeviceServiceImpl implements IDeviceService {
*/
@Override
public List<DeviceAllShortOutput> selectAllDeviceShortList() {
// TODO redis缓存
return deviceMapper.selectAllDeviceShortList();
Device device=new 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.selectAllDeviceShortList(device);
}
/**
@@ -252,8 +263,6 @@ 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++){
@@ -568,16 +577,6 @@ public class DeviceServiceImpl implements IDeviceService {
return "";
}
@Override
public List<DeviceAllShortOutput> selectAllDeviceShortListAccurate(String userName) {
return deviceMapper.selectAllDeviceShortListAccurate(userName);
}
// 精准查询 新增别人分享给自己的设备
@Override
public List<Device> selectDeviceListAccurate(Device device) {
return deviceMapper.selectDeviceListAccurate(device);
}
/**
*