From e86b062eaab9369aca3fdf2a8d328e7d7c179ed2 Mon Sep 17 00:00:00 2001 From: wenjy Date: Wed, 25 May 2022 21:10:22 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=BC=A0=E6=84=9F=E5=99=A8?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=E3=80=82?= =?UTF-8?q?=E4=BC=A0=E6=84=9F=E5=99=A8=E4=BF=A1=E6=81=AF=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=88=97=E8=A1=A8,=E5=88=86=E9=A1=B5=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E6=98=BE=E7=A4=BA=E6=89=80=E6=9C=89=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/BaseSensorInfoController.java | 17 +----------- .../templates/base/sensorInfo/sensorInfo.html | 5 +--- .../impl/BaseSensorInfoServiceImpl.java | 26 ++++++++++++++++--- 3 files changed, 24 insertions(+), 24 deletions(-) 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;