mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
1.设备分享添加字段查询过滤,2.app/home/editUserConfig接口放开认证
This commit is contained in:
parent
1172a7b7bf
commit
0b3a494fd2
@ -42,7 +42,7 @@ public class EqEquipmentController extends BaseController {
|
||||
@SaCheckPermission("device:equipment:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<EqEquipmentVo> list(EqEquipmentBo bo, PageQuery pageQuery) {
|
||||
return eqEquipmentService.queryPageList(bo, pageQuery);
|
||||
return eqEquipmentService.queryPageList(bo, pageQuery,false,null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.web.controller.app;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -27,8 +28,10 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* app通用业务
|
||||
@ -64,6 +67,7 @@ public class EqHomeController extends BaseController {
|
||||
*/
|
||||
@Log(title = "用户配置", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@SaIgnore
|
||||
@PutMapping("/editUserConfig")
|
||||
public R<Void> editUserConfig(@Validated(EditGroup.class) @RequestBody EqUserConfigBo bo) {
|
||||
return toAjax(eqUserConfigService.updateByBo(bo));
|
||||
@ -327,13 +331,18 @@ public class EqHomeController extends BaseController {
|
||||
public TableDataInfo<EqEquipmentVo> list(EqAppHomeBo bo, PageQuery pageQuery){
|
||||
//当前用户为家庭主体 切换用户后需要传输用户id
|
||||
Long currentUserId = LoginHelper.getUserId();
|
||||
if (bo.getUserId() == null) bo.setUserId(currentUserId);
|
||||
checkUserId(bo.getUserId(), currentUserId);
|
||||
boolean shared=true;
|
||||
List<Long> equipmentIdIds=null;
|
||||
if (bo.getUserId() == null) {
|
||||
bo.setUserId(currentUserId);
|
||||
shared=false;
|
||||
}
|
||||
equipmentIdIds =checkUserId(bo.getUserId(), currentUserId);
|
||||
// 下面返回的状态 会在设备状态变化时更新设备状态 状态更新由iot触发
|
||||
EqEquipmentBo eqEquipmentBo = new EqEquipmentBo();
|
||||
eqEquipmentBo.setUserId(bo.getUserId());
|
||||
eqEquipmentBo.setAreaId(bo.getAreaId());
|
||||
return eqEquipmentService.queryPageList(eqEquipmentBo, pageQuery); //在设备表中增加了分布id
|
||||
return eqEquipmentService.queryPageList(eqEquipmentBo, pageQuery,shared,equipmentIdIds); //在设备表中增加了分布id
|
||||
}
|
||||
|
||||
/**
|
||||
@ -342,7 +351,7 @@ public class EqHomeController extends BaseController {
|
||||
* @param userId
|
||||
* @param currentUserId
|
||||
*/
|
||||
private void checkUserId(Long userId, Long currentUserId) {
|
||||
private List<Long> checkUserId(Long userId, Long currentUserId) {
|
||||
if (!currentUserId.equals(userId)){
|
||||
EqShareBo eqShareBo = new EqShareBo();
|
||||
eqShareBo.setShareUserId(userId);
|
||||
@ -350,8 +359,12 @@ public class EqHomeController extends BaseController {
|
||||
List<EqShareVo> eqShareVos = shareService.queryList(eqShareBo);
|
||||
if (CollectionUtils.isEmpty(eqShareVos)){
|
||||
throw new RuntimeException("您没有权限查看该设备");
|
||||
}else {
|
||||
String ids= eqShareVos.get(0).getSharedEquipmentIds();
|
||||
return Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ public class EqShowEquipmentController extends BaseController {
|
||||
@SaCheckPermission("device:showEquipment:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<EqEquipmentVo> list(EqEquipmentBo bo, PageQuery pageQuery) {
|
||||
return eqEquipmentService.queryPageList(bo, pageQuery);
|
||||
return eqEquipmentService.queryPageList(bo, pageQuery,false,null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -46,6 +46,10 @@ public class EqShare extends BaseEntity {
|
||||
* 被分享者名称
|
||||
*/
|
||||
private String sharedUserName;
|
||||
/**
|
||||
* 被分享的设备IDs
|
||||
*/
|
||||
private String sharedEquipmentIds;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -49,6 +49,11 @@ public class EqShareBo extends BaseEntity {
|
||||
*/
|
||||
@NotBlank(message = "被分享者名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String sharedUserName;
|
||||
/**
|
||||
* 被分享的设备IDs
|
||||
*/
|
||||
@NotBlank(message = "被分享的设备不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String sharedEquipmentIds;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -57,6 +57,10 @@ public class EqShareVo implements Serializable {
|
||||
*/
|
||||
@ExcelProperty(value = "被分享者名称")
|
||||
private String sharedUserName;
|
||||
/**
|
||||
* 被分享的设备IDs
|
||||
*/
|
||||
private String sharedEquipmentIds;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ public interface IEqEquipmentService {
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备信息分页列表
|
||||
*/
|
||||
TableDataInfo<EqEquipmentVo> queryPageList(EqEquipmentBo bo, PageQuery pageQuery);
|
||||
TableDataInfo<EqEquipmentVo> queryPageList(EqEquipmentBo bo, PageQuery pageQuery,boolean shared,List<Long> equipmentIdIds);
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备信息列表
|
||||
|
||||
@ -69,8 +69,8 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
* @return 设备信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<EqEquipmentVo> queryPageList(EqEquipmentBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<EqEquipment> lqw = buildQueryWrapper(bo);
|
||||
public TableDataInfo<EqEquipmentVo> queryPageList(EqEquipmentBo bo, PageQuery pageQuery,boolean shared,List<Long> equipmentIdIds) {
|
||||
LambdaQueryWrapper<EqEquipment> lqw = buildQueryWrapper(bo,shared,equipmentIdIds);
|
||||
Page<EqEquipmentVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
List<EqEquipmentVo> records = result.getRecords();
|
||||
if (CollUtil.isEmpty(records)) return TableDataInfo.build(result);
|
||||
@ -118,13 +118,17 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
*/
|
||||
@Override
|
||||
public List<EqEquipmentVo> queryList(EqEquipmentBo bo) {
|
||||
LambdaQueryWrapper<EqEquipment> lqw = buildQueryWrapper(bo);
|
||||
LambdaQueryWrapper<EqEquipment> lqw = buildQueryWrapper(bo,false,null);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<EqEquipment> buildQueryWrapper(EqEquipmentBo bo) {
|
||||
private LambdaQueryWrapper<EqEquipment> buildQueryWrapper(EqEquipmentBo bo,boolean shared,List<Long> equipmentIdIds) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<EqEquipment> lqw = Wrappers.lambdaQuery();
|
||||
//查询分享的过滤设备ID
|
||||
if(shared&& !CollectionUtils.isEmpty(equipmentIdIds)){
|
||||
lqw.in(EqEquipment::getEquipmentId, equipmentIdIds);
|
||||
}
|
||||
lqw.eq(bo.getAreaId() != null, EqEquipment::getAreaId, bo.getAreaId());
|
||||
lqw.eq(bo.getUserId() != null, EqEquipment::getUserId, bo.getUserId());
|
||||
lqw.eq(bo.getType() != null, EqEquipment::getType, bo.getType());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user