mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 01:48:47 +08:00
接口优化
This commit is contained in:
parent
39dc86655c
commit
5ab83b6051
@ -19,6 +19,7 @@ import org.dromara.web.domain.vo.*;
|
|||||||
import org.dromara.web.service.*;
|
import org.dromara.web.service.*;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -67,12 +68,25 @@ public class EqDeviceController extends BaseController {
|
|||||||
public R<Boolean> bindDevice(EqAppHomeBo bo){
|
public R<Boolean> bindDevice(EqAppHomeBo bo){
|
||||||
String equipmentCode = bo.getEquipmentCode();
|
String equipmentCode = bo.getEquipmentCode();
|
||||||
if (equipmentCode == null) throw new ServiceException("设备编码不能为空");
|
if (equipmentCode == null) throw new ServiceException("设备编码不能为空");
|
||||||
if (bo.getUserId() == null) throw new ServiceException("用户ID不能为空");
|
if (bo.getUserId() == null) throw new ServiceException("用户ID不能为空");//分享用户要使用家庭主体的用户id
|
||||||
if (bo.getAreaId() == null) throw new ServiceException("分布ID不能为空");
|
|
||||||
|
|
||||||
return R.ok(eqEquipmentService.bindDevice(bo));
|
return R.ok(eqEquipmentService.bindDevice(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 删除设备
|
||||||
|
* 传参设备id
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
public R<Boolean> delete(EqAppHomeBo bo){
|
||||||
|
if (bo.getEquipmentId() == null) throw new ServiceException("设备ID不能为空");
|
||||||
|
Long userId = LoginHelper.getUserId();
|
||||||
|
if (!userId.equals(bo.getUserId())){
|
||||||
|
return R.fail("删除失败,设备不属于当前用户");
|
||||||
|
}
|
||||||
|
return R.ok(eqEquipmentService.deleteWithValidByIds(Collections.singletonList(bo.getEquipmentId()),Boolean.FALSE));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 控制设备 门 灯光 控制
|
* 控制设备 门 灯光 控制
|
||||||
* 传参设备编码
|
* 传参设备编码
|
||||||
|
|||||||
@ -95,16 +95,22 @@ public class EqHomeController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/share")
|
@PostMapping("/share")
|
||||||
public R<Void> share(@Validated(AddGroup.class) @RequestBody EqShareBo bo) {
|
public R<Void> share(@Validated(AddGroup.class) @RequestBody EqShareBo bo) {
|
||||||
|
if (bo.getSharedUserName() == null){
|
||||||
|
return R.fail("被分享者用户名不能为空");
|
||||||
|
}
|
||||||
|
SysUserVo sysUserVo = userService.selectUserByUserName(bo.getSharedUserName());
|
||||||
if (bo.getShareUserId() == null){
|
if (bo.getShareUserId() == null){
|
||||||
bo.setShareUserId(LoginHelper.getUserId());
|
bo.setShareUserId(LoginHelper.getUserId());
|
||||||
bo.setShareUserName(LoginHelper.getUsername());
|
bo.setShareUserName(LoginHelper.getUsername());
|
||||||
}
|
}
|
||||||
|
bo.setSharedUserId(sysUserVo.getUserId());
|
||||||
|
bo.setSharedUserName(sysUserVo.getUserName());
|
||||||
return toAjax(eqShareService.insertByBo(bo));
|
return toAjax(eqShareService.insertByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除被分享的成员
|
* 删除被分享的成员
|
||||||
* @param sharedId
|
* @param sharedId 被分享者用户id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/{sharedId}")
|
@DeleteMapping("/{sharedId}")
|
||||||
@ -122,15 +128,16 @@ public class EqHomeController extends BaseController {
|
|||||||
return R.ok(eqAreaService.queryList(bo));
|
return R.ok(eqAreaService.queryList(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** todo
|
/**
|
||||||
* 首页查看设备列表
|
* 首页查看设备列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<EqEquipmentVo> list(EqAppHomeBo bo, PageQuery pageQuery){
|
public TableDataInfo<EqEquipmentVo> list(EqAppHomeBo bo, PageQuery pageQuery){
|
||||||
|
//当前用户为家庭主体 切换用户后需要传输用户id
|
||||||
if (bo.getUserId() == null) bo.setUserId(LoginHelper.getUserId());
|
if (bo.getUserId() == null) bo.setUserId(LoginHelper.getUserId());
|
||||||
//TODO 下面返回的状态 会在设备状态变化时更新设备状态
|
//TODO 下面返回的状态 会在设备状态变化时更新设备状态
|
||||||
EqEquipmentBo eqEquipmentBo = new EqEquipmentBo();
|
EqEquipmentBo eqEquipmentBo = new EqEquipmentBo();
|
||||||
eqEquipmentBo.setCreateBy(bo.getUserId());
|
eqEquipmentBo.setUserId(bo.getUserId());
|
||||||
return eqEquipmentService.queryPageList(eqEquipmentBo, pageQuery); //在设备表中增加了分布id
|
return eqEquipmentService.queryPageList(eqEquipmentBo, pageQuery); //在设备表中增加了分布id
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,29 +145,11 @@ public class EqHomeController extends BaseController {
|
|||||||
* 设备详情 (暂时无用)
|
* 设备详情 (暂时无用)
|
||||||
* 传参 设备id
|
* 传参 设备id
|
||||||
*/
|
*/
|
||||||
@GetMapping("/info")
|
/*@GetMapping("/info")
|
||||||
public R<EqEquipmentVo> info(EqAppHomeBo bo){
|
public R<EqEquipmentVo> info(EqAppHomeBo bo){
|
||||||
if (bo.getEquipmentId() == null) throw new ServiceException("设备ID不能为空");
|
if (bo.getEquipmentId() == null) throw new ServiceException("设备ID不能为空");
|
||||||
return R.ok(eqEquipmentService.queryById(bo.getEquipmentId()));
|
return R.ok(eqEquipmentService.queryById(bo.getEquipmentId()));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 删除设备
|
|
||||||
* 传参设备id
|
|
||||||
*/
|
|
||||||
@GetMapping("/delete")
|
|
||||||
public R<Boolean> delete(EqAppHomeBo bo){
|
|
||||||
if (bo.getEquipmentId() == null) throw new ServiceException("设备ID不能为空");
|
|
||||||
Long userId = LoginHelper.getUserId();
|
|
||||||
if (!userId.equals(bo.getUserId())){
|
|
||||||
return R.fail("删除失败,设备不属于当前用户");
|
|
||||||
}
|
|
||||||
return R.ok(eqEquipmentService.deleteWithValidByIds(Collections.singletonList(bo.getEquipmentId()),Boolean.FALSE));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码验证
|
* 密码验证
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import org.dromara.common.mybatis.core.domain.BaseEntity;
|
|||||||
@Data
|
@Data
|
||||||
public class EqAppHomeBo extends BaseEntity{
|
public class EqAppHomeBo extends BaseEntity{
|
||||||
/**
|
/**
|
||||||
* 选取用户ID(家庭主体ID)
|
* 选取用户ID(家庭主体ID) 当前登录用户非家庭主体用户时,该字段必传
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -89,6 +89,7 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
|||||||
Map<String, Object> params = bo.getParams();
|
Map<String, Object> params = bo.getParams();
|
||||||
LambdaQueryWrapper<EqEquipment> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<EqEquipment> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(bo.getAreaId() != null, EqEquipment::getAreaId, bo.getAreaId());
|
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());
|
lqw.eq(bo.getType() != null, EqEquipment::getType, bo.getType());
|
||||||
lqw.like(StringUtils.isNotBlank(bo.getUserName()), EqEquipment::getUserName, bo.getUserName());
|
lqw.like(StringUtils.isNotBlank(bo.getUserName()), EqEquipment::getUserName, bo.getUserName());
|
||||||
lqw.like(StringUtils.isNotBlank(bo.getNickName()), EqEquipment::getNickName, bo.getNickName());
|
lqw.like(StringUtils.isNotBlank(bo.getNickName()), EqEquipment::getNickName, bo.getNickName());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user