|
|
@@ -1,5 +1,6 @@
|
|
|
package com.chuanghai.ihotel.controller;
|
|
|
|
|
|
+import com.chuanghai.ihotel.anno.AdminLoginCheck;
|
|
|
import com.chuanghai.ihotel.anno.ParamCheck;
|
|
|
import com.chuanghai.ihotel.common.utils.CommonResult;
|
|
|
import com.chuanghai.ihotel.common.utils.PageParam;
|
|
|
@@ -14,6 +15,7 @@ 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.RequestHeader;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
@@ -35,8 +37,9 @@ public class RoomController {
|
|
|
/**
|
|
|
* 房间列表(分页)
|
|
|
*/
|
|
|
+ @AdminLoginCheck
|
|
|
@GetMapping("/page")
|
|
|
- public CommonResult<PageUtils<RoomEntity>> page(PageParam pageParam, RoomQueryRequest request){
|
|
|
+ public CommonResult<PageUtils<RoomEntity>> page(@RequestHeader("admin_token")String adminToken, PageParam pageParam, RoomQueryRequest request){
|
|
|
PageUtils page = roomService.queryPage(pageParam, request);
|
|
|
|
|
|
return CommonResult.ok().setResult(page);
|
|
|
@@ -45,20 +48,20 @@ public class RoomController {
|
|
|
/**
|
|
|
* 房间列表(分页分组)
|
|
|
*/
|
|
|
+ @AdminLoginCheck
|
|
|
@GetMapping("/page/group")
|
|
|
- public CommonResult<PageUtils<RoomGroupVO>> pageGroup(PageParam pageParam, RoomQueryRequest request){
|
|
|
+ public CommonResult<PageUtils<RoomGroupVO>> pageGroup(@RequestHeader("admin_token")String adminToken, 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){
|
|
|
+ @PostMapping("/save")
|
|
|
+ public CommonResult<String> save(@RequestHeader("admin_token")String adminToken, @RequestBody RoomEntity room){
|
|
|
roomService.mySave(room);
|
|
|
|
|
|
return CommonResult.ok();
|
|
|
@@ -68,9 +71,9 @@ public class RoomController {
|
|
|
* 修改房间
|
|
|
* @apiNote 修改房间,房型数据不能被修改,若要修改房间房型,请先删除后新增
|
|
|
*/
|
|
|
- @PutMapping("/update")
|
|
|
@ParamCheck
|
|
|
- public CommonResult<String> update(@RequestBody RoomEntity room){
|
|
|
+ @PutMapping("/update")
|
|
|
+ public CommonResult<String> update(@RequestHeader("admin_token")String adminToken, @RequestBody RoomEntity room){
|
|
|
room.setRoomTypeId(null);
|
|
|
room.setRoomTypeName(null);
|
|
|
boolean flag = roomService.updateById(room);
|
|
|
@@ -86,7 +89,7 @@ public class RoomController {
|
|
|
* 删除房间
|
|
|
*/
|
|
|
@DeleteMapping("/delete")
|
|
|
- public CommonResult<String> delete(@RequestBody Long[] ids){
|
|
|
+ public CommonResult<String> delete(@RequestHeader("admin_token")String adminToken, @RequestBody Long[] ids){
|
|
|
boolean flag = roomService.removeByIds(Arrays.asList(ids));
|
|
|
|
|
|
if (flag) {
|
|
|
@@ -95,5 +98,4 @@ public class RoomController {
|
|
|
return CommonResult.fail();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|