| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package com.chuanghai.ihotel.controller;
- import com.chuanghai.ihotel.anno.ParamCheck;
- import com.chuanghai.ihotel.common.utils.CommonResult;
- import com.chuanghai.ihotel.common.utils.PageParam;
- import com.chuanghai.ihotel.common.utils.PageUtils;
- import com.chuanghai.ihotel.controller.request.RoomQueryRequest;
- import com.chuanghai.ihotel.entity.RoomEntity;
- import com.chuanghai.ihotel.service.RoomService;
- import com.chuanghai.ihotel.vo.RoomGroupVO;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.DeleteMapping;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.PutMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.Arrays;
- /**
- * 房间
- *
- * @author codingliang
- * @email codingliang@gmail.com
- * @date 2022-07-27 10:02:04
- */
- @RestController
- @RequestMapping("room")
- public class RoomController {
- @Autowired
- private RoomService roomService;
- /**
- * 房间列表(分页)
- */
- @GetMapping("/page")
- public CommonResult<PageUtils<RoomEntity>> page(PageParam pageParam, RoomQueryRequest request){
- PageUtils page = roomService.queryPage(pageParam, request);
- return CommonResult.ok().setResult(page);
- }
- /**
- * 房间列表(分页分组)
- */
- @GetMapping("/page/group")
- public CommonResult<PageUtils<RoomGroupVO>> pageGroup(PageParam pageParam, RoomQueryRequest request){
- PageUtils page = roomService.queryPageGroup(pageParam, request);
- return CommonResult.ok().setResult(page);
- }
- /**
- * 新增房间
- */
- @PostMapping("/save")
- @ParamCheck
- public CommonResult<String> save(@RequestBody RoomEntity room){
- roomService.mySave(room);
- return CommonResult.ok();
- }
- /**
- * 修改房间
- * @apiNote 修改房间,房型数据不能被修改,若要修改房间房型,请先删除后新增
- */
- @PutMapping("/update")
- @ParamCheck
- public CommonResult<String> update(@RequestBody RoomEntity room){
- room.setRoomTypeId(null);
- room.setRoomTypeName(null);
- boolean flag = roomService.updateById(room);
- if (flag) {
- return CommonResult.ok();
- } else {
- return CommonResult.fail();
- }
- }
- /**
- * 删除房间
- */
- @DeleteMapping("/delete")
- public CommonResult<String> delete(@RequestBody Long[] ids){
- boolean flag = roomService.removeByIds(Arrays.asList(ids));
- if (flag) {
- return CommonResult.ok();
- } else {
- return CommonResult.fail();
- }
- }
- }
|