diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java index 3d4b559..48fef65 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java @@ -74,22 +74,7 @@ public class BaseSensorInfoController extends BaseController { @ResponseBody public TableDataInfo list(BaseSensorInfo baseSensorInfo) { startPage(); - //List list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); - List list = new ArrayList<>(); - SysUser sysUser = ShiroUtils.getSysUser(); - - List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); - - if(ShiroUtils.getLoginName().equals("admin")){ - List baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); - list.addAll(baseSensorInfoDtos); - }else{ - for (SysRole sysRole : sysRoles) { - baseSensorInfo.setRoleId(sysRole.getRoleId()); - List baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); - list.addAll(baseSensorInfoDtos); - } - } + List list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); return getDataTable(list); } diff --git a/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html index 3ca6184..49d6264 100644 --- a/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html +++ b/ruoyi-admin/src/main/resources/templates/base/sensorInfo/sensorInfo.html @@ -162,6 +162,7 @@ fixedColumns: true, fixedNumber: 6, fixedRightNumber: 1, + sidePagination: "client", columns: [{ checkbox: true }, @@ -310,10 +311,6 @@ pageNumber: 1, //当前第几页 pageList: [5, 10, 15, 20, 25], //记录数可选列表 striped: true, //显示行间隔色 - // search: true, //启用查询 - // showColumns: true, //显示下拉框勾选要显示的列 - // showRefresh: true, //显示刷新按钮 - // showToggle:true, //显示切换视图模式按钮 sortOrder: "asc", //排序方式 sidePagination: "server", //分页方式:client客户端分页,server服务端分页 //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorInfoServiceImpl.java index 08f2af2..35d00d6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorInfoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseSensorInfoServiceImpl.java @@ -5,12 +5,15 @@ import java.util.Date; import java.util.List; import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.BaseMonitorunitInfo; import com.ruoyi.system.domain.dto.BaseSensorInfoDto; +import com.ruoyi.system.service.ISysRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.BaseSensorInfoMapper; @@ -30,6 +33,9 @@ public class BaseSensorInfoServiceImpl implements IBaseSensorInfoService @Autowired private BaseSensorInfoMapper baseSensorInfoMapper; + @Autowired + private ISysRoleService iSysRoleService; + /** * 查询传感器信息 * @@ -52,11 +58,23 @@ public class BaseSensorInfoServiceImpl implements IBaseSensorInfoService public List selectBaseSensorInfoList(BaseSensorInfo baseSensorInfo) { try{ - if(baseSensorInfo.getRoleId() != null && baseSensorInfo.getRoleId() > 1){ - List baseSensorInfoDtos = baseSensorInfoMapper.selectBaseSensorInfoListByRoleId(baseSensorInfo); - return baseSensorInfoDtos; + List list = new ArrayList<>(); + SysUser sysUser = ShiroUtils.getSysUser(); + + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + + if(ShiroUtils.getLoginName().equals("admin")){ + List baseSensorInfoDtos = baseSensorInfoMapper.selectBaseSensorInfoList(baseSensorInfo); + list.addAll(baseSensorInfoDtos); + }else{ + for (SysRole sysRole : sysRoles) { + baseSensorInfo.setRoleId(sysRole.getRoleId()); + List baseSensorInfoDtos = baseSensorInfoMapper.selectBaseSensorInfoListByRoleId(baseSensorInfo); + list.addAll(baseSensorInfoDtos); + } } - return baseSensorInfoMapper.selectBaseSensorInfoList(baseSensorInfo); + + return list; }catch (Exception ex) { System.out.println(ex.getMessage()); return null;