[select] 房间管理代码优化
This commit is contained in:
parent
c18f94cf40
commit
b2a3663fd0
@ -1,11 +1,9 @@
|
||||
package com.qiuguo.iot.user.api.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.qiuguo.iot.data.entity.user.UserRoomEntity;
|
||||
import com.qiuguo.iot.data.request.user.UserRoomRequest;
|
||||
import com.qiuguo.iot.data.service.user.UserRoomService;
|
||||
import com.qiuguo.iot.user.api.service.TuyaDeviceConnector;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -25,45 +23,26 @@ public class RoomAdminController {
|
||||
@Resource
|
||||
private UserRoomService roomService;
|
||||
|
||||
@Resource
|
||||
private TuyaDeviceConnector deviceConnector;
|
||||
|
||||
//新增
|
||||
@PostMapping("/save/room")
|
||||
public Mono<Void> roomSave(@RequestBody JSONObject jsonObject) {
|
||||
if (ObjectUtil.isNull(jsonObject)){
|
||||
return null;
|
||||
}
|
||||
UserRoomEntity room = jsonObject.toJavaObject(UserRoomEntity.class);
|
||||
if (ObjectUtil.isNull(room)){
|
||||
//todo:解析json为空
|
||||
}
|
||||
public Mono<Void> roomSave(@RequestBody UserRoomEntity room) {
|
||||
room.setCreateTime(new Date());
|
||||
room.setIsDelete(1);
|
||||
room.setModifyTime(new Date());
|
||||
roomService.insertUserRoom(room);
|
||||
return Mono.empty();
|
||||
return roomService.insertUserRoom(room).thenEmpty(Mono.empty());
|
||||
}
|
||||
|
||||
//更新
|
||||
@PostMapping("/edit/room")
|
||||
public Mono<JSONObject> editRoom(@RequestBody JSONObject jsonObject) {
|
||||
if (ObjectUtil.isNull(jsonObject)){
|
||||
return null;
|
||||
}
|
||||
UserRoomEntity room = jsonObject.toJavaObject(UserRoomEntity.class);
|
||||
if (ObjectUtil.isNull(room)){
|
||||
//todo:解析json为空
|
||||
}
|
||||
roomService.updateUserRoomById(room);
|
||||
return Mono.empty();
|
||||
public Mono<Integer> editRoom(@RequestBody UserRoomEntity room) {
|
||||
return roomService.updateUserRoomById(room).map( integer -> integer);
|
||||
}
|
||||
|
||||
//删除
|
||||
@GetMapping("/del/room")
|
||||
public Mono<Integer> delFamily(@RequestParam Long id) {
|
||||
if (ObjectUtil.isNull(id)){
|
||||
//todo:为空
|
||||
throw new RuntimeException("传入id为空");
|
||||
}
|
||||
return roomService.deleteUserRoomById(id);
|
||||
}
|
||||
@ -72,12 +51,5 @@ public class RoomAdminController {
|
||||
@PostMapping("/get/room")
|
||||
public Mono<PagerResult<UserRoomEntity>> getFamily(@RequestBody UserRoomRequest resp) {
|
||||
return roomService.selectUserRoomsByRequest(resp);
|
||||
/**
|
||||
* 判空
|
||||
* 查询对应设备id
|
||||
* 调用TuyaDeviceConnector.getByid接口
|
||||
* 返回
|
||||
*/
|
||||
//return Mono.just(aa);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user