Commit e0ad53b5 by huangjy

fix:小程序设备列表数据权限

parent 9ce8647f
......@@ -11,12 +11,15 @@ import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO;
import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.enums.HeaderConst;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.module.iot.vo.DeviceProperties;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatRoleService;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.utils.data.validate.CollectionUtils;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.request.RequestUtil;
import com.makeit.vo.platform.device.PlatDeviceListVO;
......@@ -31,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
......@@ -48,20 +52,17 @@ public class PlatDeviceWechatController {
@Autowired
private PlatDeviceService platDeviceService;
@Autowired
private PlatRoleService platRoleService;
private PlatOrgService platOrgService;
@ApiOperation("分页列表")
@PostMapping("page")
public ApiResponseEntity<PageVO<PlatDeviceListVO>> page(@RequestBody PageReqDTO<PlatDeviceQueryDTO> pageReqDTO) {
PlatDeviceQueryDTO dto = pageReqDTO.getData();
String roleId = RequestUtil.getHeader(HeaderConst.ROLE_ID);
if (StringUtils.isNotEmpty(roleId)) {
PlatRole platRole = platRoleService.getById(roleId);
String dataScope = platRole.getDataScope();
if (StringUtils.isNotEmpty(dataScope)) {
dto.setOrgIds(Lists.newArrayList(dataScope.split(",")));
}
List<PlatOrg> orgs = platOrgService.belongToScopeList(new PlatOrg());
if (CollectionUtils.isEmpty(orgs)) {
return ApiResponseUtils.success(new PageVO<>());
}
dto.setOrgIds(orgs.stream().map(PlatOrg::getId).collect(Collectors.toList()));
return ApiResponseUtils.success(platDeviceService.page(pageReqDTO));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment