瀏覽代碼

解决物联设备分页列表数据权限问题

tags/V1.3.3^2
wanjing 11 月之前
父節點
當前提交
1237cc1b2d
共有 2 個文件被更改,包括 9 次插入25 次删除
  1. +0
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/iotequipment/QueryIotEquipmentPageListRequest.java
  2. +9
    -20
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/iotequipment/query/QueryEditIotEquipmentPageListService.java

+ 0
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/iotequipment/QueryIotEquipmentPageListRequest.java 查看文件

@@ -20,11 +20,6 @@ public class QueryIotEquipmentPageListRequest extends BaseQuery {
*/
private String tenantId;

/**
* 部门Id
*/
private String deptId;

/**
* 公路名称
*/

+ 9
- 20
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/iotequipment/query/QueryEditIotEquipmentPageListService.java 查看文件

@@ -15,13 +15,11 @@ import com.tuoheng.admin.request.iotequipment.QueryIotEquipmentPageListRequest;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.IotEquipmentVo;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@@ -57,7 +55,7 @@ public class QueryEditIotEquipmentPageListService {
}

// 获取部门Id的查询范围
List<String> deptIdList = this.getDeptIdList(user, user.getDeptId());
List<String> deptIdList = this.getDeptIdList(user);
request.setDeptIdList(deptIdList);
request.setTenantId(user.getTenantId());

@@ -94,21 +92,18 @@ public class QueryEditIotEquipmentPageListService {
/**
* 获取部门Id的查询范围
*
* @param deptId
* @return
*/
private List<String> getDeptIdList(User user, String deptId) {
private List<String> getDeptIdList(User user) {
List<String> deptIdList = new ArrayList<>();
if (!StringUtils.isEmpty(deptId)) {
deptIdList.add(deptId);
return deptIdList;
}
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
return null;
} else {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId());
return deptIdList;
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) {
deptIdList = deptMapper.selectAllChildListById(user.getDeptId());
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) {
deptIdList.add(user.getDeptId());
}
return deptIdList;
}

private List<IotEquipmentVo> buildIotEquipmentVoList(List<IotEquipment> iotEquipmentList) {
@@ -116,17 +111,14 @@ public class QueryEditIotEquipmentPageListService {
return null;
}
List<IotEquipmentVo> iotEquipmentVoList = IotEquipmentConverMapper.INSTANCE.fromIotEquipmentToIotEquipmentVoList(iotEquipmentList);

Map<String, Dept> deptMap = this.getDeptMap(iotEquipmentList);
Map<String, RoadInformation> roadInformationMap = this.getRoadInformationMap(iotEquipmentList);
Map<String, Section> sectionMap = this.getSectionMap(iotEquipmentList);
Map<String, User> userMap = this.getUserMap(iotEquipmentList);

Dept dept;
RoadInformation roadInformation;
Section section;
User user;

for (IotEquipmentVo iotEquipmentVo : iotEquipmentVoList) {
if (ObjectUtil.isNotEmpty(deptMap)) {
dept = deptMap.get(iotEquipmentVo.getDeptId());
@@ -156,12 +148,12 @@ public class QueryEditIotEquipmentPageListService {
}
}
}

return iotEquipmentVoList;
}

/**
* 获取用户列表,放到map,减少循环次数
*
* @param iotEquipmentList
* @return
*/
@@ -172,11 +164,11 @@ public class QueryEditIotEquipmentPageListService {
.eq(User::getMark, MarkEnum.VALID.getCode()));
Map<String, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, Function.identity()));
return userMap;

}

/**
* 获取路段列表,放到map,减少循环次数
*
* @param iotEquipmentList
* @return
*/
@@ -187,8 +179,6 @@ public class QueryEditIotEquipmentPageListService {
.eq(Section::getMark, MarkEnum.VALID.getCode()));
Map<String, Section> sectionMap = sectionList.stream().collect(Collectors.toMap(Section::getId, Function.identity()));
return sectionMap;


}

/**
@@ -212,7 +202,6 @@ public class QueryEditIotEquipmentPageListService {
}

/**
*
* 获取公路列表,放到map,减少循环次数
*
* @param iotEquipmentList

Loading…
取消
儲存