mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 17:05:55 +08:00
多租户接口调整
This commit is contained in:
@@ -60,16 +60,9 @@ public class CategoryController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('iot:category:list')")
|
||||
@GetMapping("/shortlist")
|
||||
@ApiOperation("分类简短列表")
|
||||
public AjaxResult shortlist(Category category)
|
||||
public AjaxResult shortlist()
|
||||
{
|
||||
List<IdAndName> list = new ArrayList<>();
|
||||
if(category.getTenantName()==""||category.getTenantName()==null)
|
||||
{
|
||||
list = categoryService.selectCategoryShortList();
|
||||
}else {
|
||||
list = categoryService.selectCategoryShortListAccurate(category);
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
return AjaxResult.success(categoryService.selectCategoryShortList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,16 +65,9 @@ public class DeviceController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:list')")
|
||||
@GetMapping("/all")
|
||||
@ApiOperation("查询所有设备简短列表")
|
||||
public TableDataInfo allShortList(Device device)
|
||||
public TableDataInfo allShortList()
|
||||
{
|
||||
List<DeviceAllShortOutput> list = new ArrayList<>();
|
||||
if(device.getUserName()==null || device.getUserName().equals(""))
|
||||
{
|
||||
list = deviceService.selectAllDeviceShortList();
|
||||
}else {
|
||||
list = deviceService.selectAllDeviceShortListAccurate(device.getUserName());
|
||||
}
|
||||
return getDataTable(list);
|
||||
return getDataTable(deviceService.selectAllDeviceShortList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface CategoryMapper
|
||||
*
|
||||
* @return 产品分类集合
|
||||
*/
|
||||
public List<IdAndName> selectCategoryShortList();
|
||||
public List<IdAndName> selectCategoryShortList(Category category);
|
||||
|
||||
/**
|
||||
* 新增产品分类
|
||||
@@ -78,5 +78,4 @@ public interface CategoryMapper
|
||||
*/
|
||||
public int productCountInCategorys(Long[] categoryIds);
|
||||
|
||||
List<IdAndName> selectCategoryShortListAccurate(Category category);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public interface DeviceMapper
|
||||
*
|
||||
* @return 设备集合
|
||||
*/
|
||||
public List<DeviceAllShortOutput> selectAllDeviceShortList();
|
||||
public List<DeviceAllShortOutput> selectAllDeviceShortList(Device device);
|
||||
|
||||
/**
|
||||
* 新增设备
|
||||
@@ -168,16 +168,4 @@ public interface DeviceMapper
|
||||
*/
|
||||
public int resetDeviceStatus(String deviceNum);
|
||||
|
||||
/**
|
||||
* 查询所有简短设备列表
|
||||
* @return 结果
|
||||
*/
|
||||
List<DeviceAllShortOutput> selectAllDeviceShortListAccurate(String userName);
|
||||
|
||||
/**
|
||||
* 精准查询
|
||||
* @return 结果
|
||||
*/
|
||||
List<Device> selectDeviceListAccurate(Device device);
|
||||
|
||||
}
|
||||
|
||||
@@ -69,5 +69,4 @@ public interface ICategoryService
|
||||
*/
|
||||
public int deleteCategoryByCategoryId(Long categoryId);
|
||||
|
||||
List<IdAndName> selectCategoryShortListAccurate(Category category);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除产品分类
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user