[select]房间管理-列表查询
This commit is contained in:
parent
04ce300add
commit
bfd44709d9
@ -10,7 +10,11 @@ import java.util.Date;
|
|||||||
import org.hswebframework.ezorm.rdb.mapping.ReactiveQuery;
|
import org.hswebframework.ezorm.rdb.mapping.ReactiveQuery;
|
||||||
import org.hswebframework.ezorm.rdb.mapping.ReactiveUpdate;
|
import org.hswebframework.ezorm.rdb.mapping.ReactiveUpdate;
|
||||||
import org.hswebframework.ezorm.rdb.operator.dml.query.SortOrder;
|
import org.hswebframework.ezorm.rdb.operator.dml.query.SortOrder;
|
||||||
|
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||||
|
import org.hswebframework.web.api.crud.entity.QueryParamEntity;
|
||||||
import org.hswebframework.web.crud.service.GenericReactiveCrudService;
|
import org.hswebframework.web.crud.service.GenericReactiveCrudService;
|
||||||
|
import org.hswebframework.web.crud.service.ReactiveCrudService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
@ -28,6 +32,8 @@ import reactor.core.publisher.Mono;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class UserRoomService extends GenericReactiveCrudService<UserRoomEntity, Long> {
|
public class UserRoomService extends GenericReactiveCrudService<UserRoomEntity, Long> {
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// private ReactiveCrudService<UserRoomEntity, Long> reactiveCrudService;
|
||||||
|
|
||||||
public Mono<UserRoomEntity> selectUserRoomByRequest(UserRoomRequest request){
|
public Mono<UserRoomEntity> selectUserRoomByRequest(UserRoomRequest request){
|
||||||
ReactiveQuery<UserRoomEntity> reactiveQuery = createQuery();
|
ReactiveQuery<UserRoomEntity> reactiveQuery = createQuery();
|
||||||
@ -67,7 +73,7 @@ public class UserRoomService extends GenericReactiveCrudService<UserRoomEntity,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Flux<UserRoomEntity> selectUserRoomsByRequest(UserRoomRequest request){
|
public Mono<PagerResult<UserRoomEntity>> selectUserRoomsByRequest(UserRoomRequest request){
|
||||||
ReactiveQuery<UserRoomEntity> reactiveQuery = createQuery();
|
ReactiveQuery<UserRoomEntity> reactiveQuery = createQuery();
|
||||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||||
if(request.getId() != null){
|
if(request.getId() != null){
|
||||||
@ -106,7 +112,12 @@ public class UserRoomService extends GenericReactiveCrudService<UserRoomEntity,
|
|||||||
}
|
}
|
||||||
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
||||||
}
|
}
|
||||||
return reactiveQuery.paging(request.getCurrPage(), request.getPageSize()).fetch();
|
QueryParamEntity param = new QueryParamEntity();
|
||||||
|
param.setPageSize(request.getPageSize());
|
||||||
|
param.setPageIndex(request.getCurrPage());
|
||||||
|
// reactiveQuery.
|
||||||
|
return queryPager(param);
|
||||||
|
// return reactiveQuery.paging(request.getCurrPage(),request.getPageSize()).fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,94 @@
|
|||||||
|
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.device.DeviceBatchService;
|
||||||
|
import com.qiuguo.iot.data.service.user.UserRoomService;
|
||||||
|
import com.qiuguo.iot.user.api.rest.RoomInitResp;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||||
|
import org.reactivestreams.Publisher;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("/family")
|
||||||
|
/*
|
||||||
|
房间管理
|
||||||
|
*/
|
||||||
|
public class RoomAdminController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserRoomService roomService;
|
||||||
|
|
||||||
|
//新增
|
||||||
|
@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为空
|
||||||
|
}
|
||||||
|
room.setCreateTime(new Date());
|
||||||
|
room.setIsDelete(1);
|
||||||
|
room.setModifyTime(new Date());
|
||||||
|
roomService.insertUserRoom(room);
|
||||||
|
return 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除
|
||||||
|
@GetMapping("/del/room")
|
||||||
|
public Mono<Integer> delFamily(@RequestParam Long id) {
|
||||||
|
if (ObjectUtil.isNull(id)){
|
||||||
|
//todo:为空
|
||||||
|
}
|
||||||
|
return roomService.deleteUserRoomById(id);
|
||||||
|
|
||||||
|
//return Mono.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询
|
||||||
|
@PostMapping("/get/room")
|
||||||
|
public Mono<PagerResult<UserRoomEntity>> getFamily(@RequestBody RoomInitResp resp) {
|
||||||
|
List<UserRoomEntity> aa = new ArrayList<>();
|
||||||
|
|
||||||
|
UserRoomRequest room = new UserRoomRequest();
|
||||||
|
room.setRoomName(resp.getRoomName());
|
||||||
|
room.setCurrPage(20);
|
||||||
|
room.setPageSize(2);
|
||||||
|
return roomService.selectUserRoomsByRequest(room);
|
||||||
|
/**
|
||||||
|
* 判空
|
||||||
|
* 查询对应设备id
|
||||||
|
* 调用TuyaDeviceConnector.getByid接口
|
||||||
|
* 返回
|
||||||
|
*/
|
||||||
|
//return Mono.just(aa);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.qiuguo.iot.user.api.rest;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RoomInitResp {
|
||||||
|
//房间名称
|
||||||
|
private String roomName;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user