ソースを参照

房态状态管理端修改

wangzhengliang 3 年 前
コミット
f945e3236d

+ 19 - 0
src/main/java/com/chuanghai/ihotel/controller/RoomRealtimeStatuController.java

@@ -10,6 +10,8 @@ import com.chuanghai.ihotel.service.RoomRealtimeStatuService;
 import com.chuanghai.ihotel.vo.RoomRealDataStatuVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -60,4 +62,21 @@ public class RoomRealtimeStatuController {
         List<RoomRealDataStatuVO> realData = roomRealtimeStatuService.realData(request);
         return CommonResult.ok().setResult(realData);
     }
+
+    /**
+     * 脏房修改为空闲房间
+     * @param adminToken
+     * @param statuId
+     * @return
+     * @apiNote 注意,只有当房间为脏房时,房间状态才可以被置为空闲房间
+     */
+    @AdminLoginCheck
+    @PutMapping("clean/{statuId}")
+    public CommonResult<String> cleanByStatuId(@RequestHeader("admin_token") String adminToken,
+                                               @PathVariable("statuId") Long statuId) {
+        roomRealtimeStatuService.cleanByStatuId(statuId);
+
+        return CommonResult.ok();
+    }
+
 }

+ 6 - 0
src/main/java/com/chuanghai/ihotel/service/RoomRealtimeStatuService.java

@@ -65,5 +65,11 @@ public interface RoomRealtimeStatuService extends IService<RoomRealtimeStatuEnti
      * @param orderId
      */
     void userReturnOrder(Long orderId);
+
+    /**
+     * 房态状态改为干净
+     * @param statuId
+     */
+    void cleanByStatuId(Long statuId);
 }
 

+ 16 - 0
src/main/java/com/chuanghai/ihotel/service/impl/RoomRealtimeStatuServiceImpl.java

@@ -174,6 +174,22 @@ public class RoomRealtimeStatuServiceImpl extends ServiceImpl<RoomRealtimeStatuD
         this.updateById(roomRealtimeStatuEntity);
     }
 
+    @Override
+    public void cleanByStatuId(Long statuId) {
+        RoomRealtimeStatuEntity statu = this.getById(statuId);
+
+        if (statu == null) {
+            throw new RRException(BizCodeEnume.PARAMETER_ERROR, "无效的statuId");
+        }
+
+        if (!RoomStatuEnum.DIRTY.getCode().equals(statu.getStatu())) {
+            throw new RRException(BizCodeEnume.PERMISSION_DENIED, "房间非脏房,不可以置为空闲房间");
+        }
+
+        statu.setStatu(RoomStatuEnum.FREE.getCode());
+        this.updateById(statu);
+    }
+
     private RoomRealtimeStatuEntity findByBizId(Long bizId) {
         QueryWrapper<RoomRealtimeStatuEntity> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("biz_id", bizId);