Browse Source

房型开发完成

wangzhengliang 3 years ago
parent
commit
fc424c5861

+ 23 - 0
pom.xml

@@ -80,6 +80,29 @@
             <version>3.10.2</version>
             <version>3.10.2</version>
         </dependency>
         </dependency>
 
 
+        <!-- redis -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>io.lettuce</groupId>
+                    <artifactId>lettuce-core</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>redis.clients</groupId>
+            <artifactId>jedis</artifactId>
+        </dependency>
+
+        <!-- Spring Cache -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-cache</artifactId>
+        </dependency>
+
         <dependency>
         <dependency>
             <groupId>mysql</groupId>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <artifactId>mysql-connector-java</artifactId>

+ 2 - 0
src/main/java/com/chuanghai/ihotel/IhotelApplication.java

@@ -2,8 +2,10 @@ package com.chuanghai.ihotel;
 
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cache.annotation.EnableCaching;
 
 
 @SpringBootApplication
 @SpringBootApplication
+@EnableCaching
 public class IhotelApplication {
 public class IhotelApplication {
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {

+ 2 - 2
src/main/java/com/chuanghai/ihotel/common/utils/MyQuery.java

@@ -29,7 +29,7 @@ public class MyQuery<T> {
 
 
 
 
         //前端字段排序
         //前端字段排序
-        if(StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)){
+        if(StringUtils.isNotBlank(orderField) && StringUtils.isNotBlank(order)){
             if("asc".equalsIgnoreCase(order)) {
             if("asc".equalsIgnoreCase(order)) {
                 return  page.addOrder(OrderItem.asc(orderField));
                 return  page.addOrder(OrderItem.asc(orderField));
             }else {
             }else {
@@ -38,7 +38,7 @@ public class MyQuery<T> {
         }
         }
 
 
         // 没有排序字段,则不排序
         // 没有排序字段,则不排序
-        if(StringUtils.isEmpty(defaultOrderField)){
+        if(StringUtils.isBlank(defaultOrderField)){
             return page;
             return page;
         }
         }
 
 

+ 47 - 0
src/main/java/com/chuanghai/ihotel/config/MyCacheConfig.java

@@ -0,0 +1,47 @@
+package com.chuanghai.ihotel.config;
+
+import org.springframework.boot.autoconfigure.cache.CacheProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializationContext;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * @Author: codingliang
+ * @Description: SpringCache 配置
+ * @Date: 2022-07-27 15:05
+ * @Version: V1.0
+ **/
+@EnableConfigurationProperties(CacheProperties.class)
+@Configuration
+public class MyCacheConfig {
+
+    @Bean
+    public RedisCacheConfiguration redisCacheConfiguration(CacheProperties cacheProperties){
+        RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
+
+        config = config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()));
+        config = config.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer()));
+
+        CacheProperties.Redis redisProperties = cacheProperties.getRedis();
+
+        // 将配置文件中的所有配置都生效
+        if (redisProperties.getTimeToLive() != null) {
+            config = config.entryTtl(redisProperties.getTimeToLive());
+        }
+        if (redisProperties.getKeyPrefix() != null) {
+            config = config.prefixCacheNameWith(redisProperties.getKeyPrefix());
+        }
+        if (!redisProperties.isCacheNullValues()) {
+            config = config.disableCachingNullValues();
+        }
+        if (!redisProperties.isUseKeyPrefix()) {
+            config = config.disableKeyPrefix();
+        }
+
+        return config;
+    }
+}

+ 23 - 7
src/main/java/com/chuanghai/ihotel/controller/RoomTypeController.java

@@ -1,7 +1,11 @@
 package com.chuanghai.ihotel.controller;
 package com.chuanghai.ihotel.controller;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
+import java.util.List;
 
 
+import com.chuanghai.ihotel.anno.ParamCheck;
+import com.chuanghai.ihotel.controller.request.RoomTypeQueryRequest;
+import com.chuanghai.ihotel.vo.RoomTypeShortDescVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -33,18 +37,28 @@ public class RoomTypeController {
     private RoomTypeService roomTypeService;
     private RoomTypeService roomTypeService;
 
 
     /**
     /**
-     * 列表
+     * 房型列表(客户端)
+     * @return
      */
      */
     @GetMapping("/list")
     @GetMapping("/list")
-    public CommonResult<PageUtils<RoomTypeEntity>> list(PageParam pageParam){
-        PageUtils page = roomTypeService.queryPage(pageParam);
+    @ParamCheck
+    public CommonResult<List<RoomTypeShortDescVO>> list(RoomTypeQueryRequest request){
+        List<RoomTypeShortDescVO> list = roomTypeService.listForClientIndex(request);
+        return CommonResult.ok().setResult(list);
+    }
 
 
+    /**
+     * 房型列表(管理端)
+     */
+    @GetMapping("/page")
+    public CommonResult<PageUtils<RoomTypeEntity>> page(PageParam pageParam){
+        PageUtils page = roomTypeService.queryPage(pageParam);
         return CommonResult.ok().setResult(page);
         return CommonResult.ok().setResult(page);
     }
     }
 
 
 
 
     /**
     /**
-     * 信息
+     * 房型详细信息
      */
      */
     @GetMapping("/info/{id}")
     @GetMapping("/info/{id}")
     public CommonResult<RoomTypeEntity> info(@PathVariable("id") Long id){
     public CommonResult<RoomTypeEntity> info(@PathVariable("id") Long id){
@@ -54,9 +68,10 @@ public class RoomTypeController {
     }
     }
 
 
     /**
     /**
-     * 保存
+     * 新增房型
      */
      */
     @PostMapping("/save")
     @PostMapping("/save")
+    @ParamCheck
     public CommonResult<String> save(@RequestBody RoomTypeEntity roomType){
     public CommonResult<String> save(@RequestBody RoomTypeEntity roomType){
 		roomTypeService.save(roomType);
 		roomTypeService.save(roomType);
 
 
@@ -64,9 +79,10 @@ public class RoomTypeController {
     }
     }
 
 
     /**
     /**
-     * 修改
+     * 修改房型
      */
      */
     @PutMapping("/update")
     @PutMapping("/update")
+    @ParamCheck
     public CommonResult<String> update(@RequestBody RoomTypeEntity roomType){
     public CommonResult<String> update(@RequestBody RoomTypeEntity roomType){
 		boolean flag = roomTypeService.updateById(roomType);
 		boolean flag = roomTypeService.updateById(roomType);
 
 
@@ -78,7 +94,7 @@ public class RoomTypeController {
     }
     }
 
 
     /**
     /**
-     * 删除
+     * 删除房型
      */
      */
     @DeleteMapping("/delete")
     @DeleteMapping("/delete")
     public CommonResult<String> delete(@RequestBody Long[] ids){
     public CommonResult<String> delete(@RequestBody Long[] ids){

+ 30 - 0
src/main/java/com/chuanghai/ihotel/controller/request/RoomTypeQueryRequest.java

@@ -0,0 +1,30 @@
+package com.chuanghai.ihotel.controller.request;
+
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
+
+/**
+ * @Author: codingliang
+ * @Description: 房型查询request
+ * @Date: 2022-07-27 14:13
+ * @Version: V1.0
+ **/
+@Data
+public class RoomTypeQueryRequest {
+
+    /**
+     * 入住时间 yyyy-MM-dd HH:mm:ss
+     */
+    @NotNull(message = "入住时间不能为空")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime startTime;
+    /**
+     * 离店时间 yyyy-MM-dd HH:mm:ss
+     */
+    @NotNull(message = "离店时间不能为空")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime endTime;
+}

+ 5 - 1
src/main/java/com/chuanghai/ihotel/dao/RoomRealtimeStatuDao.java

@@ -3,6 +3,9 @@ package com.chuanghai.ihotel.dao;
 import com.chuanghai.ihotel.entity.RoomRealtimeStatuEntity;
 import com.chuanghai.ihotel.entity.RoomRealtimeStatuEntity;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDateTime;
 
 
 /**
 /**
  * 实时房态 
  * 实时房态 
@@ -13,5 +16,6 @@ import org.apache.ibatis.annotations.Mapper;
  */
  */
 @Mapper
 @Mapper
 public interface RoomRealtimeStatuDao extends BaseMapper<RoomRealtimeStatuEntity> {
 public interface RoomRealtimeStatuDao extends BaseMapper<RoomRealtimeStatuEntity> {
-	
+
+    int getBusyNum(@Param("roomTypeId") Long roomTypeId, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
 }
 }

+ 17 - 3
src/main/java/com/chuanghai/ihotel/entity/RoomTypeEntity.java

@@ -1,9 +1,13 @@
 package com.chuanghai.ihotel.entity;
 package com.chuanghai.ihotel.entity;
 
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.Data;
 
 
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 
 
@@ -20,37 +24,47 @@ public class RoomTypeEntity implements Serializable {
 	private static final long serialVersionUID = 1580689328484360501L;
 	private static final long serialVersionUID = 1580689328484360501L;
 
 
 	/**
 	/**
-	 * id
+	 * id,新增时不用传
 	 */
 	 */
-	@TableId
+	@TableId(type = IdType.ASSIGN_ID)
 	private Long id;
 	private Long id;
 	/**
 	/**
 	 * 房型名称
 	 * 房型名称
 	 */
 	 */
+	@NotBlank(message = "房型名称不能为空")
 	private String typeName;
 	private String typeName;
 	/**
 	/**
 	 * 日常价格 单位:元/间/晚
 	 * 日常价格 单位:元/间/晚
 	 */
 	 */
+	@NotNull(message = "日常价格不能为空")
+	@Min(value = 0, message = "日常价格不能为负数")
 	private BigDecimal usualPrice;
 	private BigDecimal usualPrice;
 	/**
 	/**
 	 * 优惠价格 单位:元/间/晚
 	 * 优惠价格 单位:元/间/晚
 	 */
 	 */
+	@NotNull(message = "优惠价格不能为空")
+	@Min(value = 0, message = "优惠价格不能为负数")
 	private BigDecimal discountPrice;
 	private BigDecimal discountPrice;
 	/**
 	/**
 	 * 房型简单描述
 	 * 房型简单描述
 	 */
 	 */
+	@NotBlank(message = "房型简单描述不能为空")
 	private String typeShortDesc;
 	private String typeShortDesc;
 	/**
 	/**
 	 * 房型详细描述
 	 * 房型详细描述
 	 */
 	 */
+	@NotBlank(message = "房型详细描述不能为空")
 	private String typeDesc;
 	private String typeDesc;
 	/**
 	/**
 	 * 房间数量
 	 * 房间数量
 	 */
 	 */
+	@NotNull(message = "房间数量不能为空")
+	@Min(value = 1, message = "房间数量不能少于1")
 	private Integer roomNum;
 	private Integer roomNum;
 	/**
 	/**
-	 * 房型图 第一张为主图,多张图片之间使用,分割
+	 * 房型图,使用阿里云上传获取图片链接 第一张为主图,多张图片之间使用,分割
 	 */
 	 */
+	@NotBlank(message = "房型图不能为空")
 	private String typeImage;
 	private String typeImage;
 
 
 }
 }

+ 26 - 0
src/main/java/com/chuanghai/ihotel/enums/RoomTypeEnum.java

@@ -0,0 +1,26 @@
+package com.chuanghai.ihotel.enums;
+
+import lombok.Getter;
+
+/**
+ * @Author: codingliang
+ * @Description: 房态枚举
+ * @Date: 2022-07-27 14:48
+ * @Version: V1.0
+ **/
+@Getter
+public enum RoomTypeEnum {
+
+    FREE("1", "空闲"),
+    ORDER("2", "预定"),
+    CHECK_IN("3", "入住"),
+    DIRTY("4", "脏房"),
+    LOCK("5", "锁定");
+
+    private String code;
+    private String desc;
+    RoomTypeEnum(String code, String desc) {
+        this.code = code;
+        this.desc = desc;
+    }
+}

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

@@ -5,6 +5,8 @@ import com.chuanghai.ihotel.common.utils.PageUtils;
 import com.chuanghai.ihotel.common.utils.PageParam;
 import com.chuanghai.ihotel.common.utils.PageParam;
 import com.chuanghai.ihotel.entity.RoomRealtimeStatuEntity;
 import com.chuanghai.ihotel.entity.RoomRealtimeStatuEntity;
 
 
+import java.time.LocalDateTime;
+
 /**
 /**
  * 实时房态 
  * 实时房态 
  *
  *
@@ -15,5 +17,16 @@ import com.chuanghai.ihotel.entity.RoomRealtimeStatuEntity;
 public interface RoomRealtimeStatuService extends IService<RoomRealtimeStatuEntity> {
 public interface RoomRealtimeStatuService extends IService<RoomRealtimeStatuEntity> {
 
 
     PageUtils queryPage(PageParam pageParam);
     PageUtils queryPage(PageParam pageParam);
+
+    /**
+     * 获取当前时间段处在繁忙状态的房间数量
+     *
+     *  状态为2预定、3入住、4脏房、5锁定表示当前处于繁忙状态
+     * @param roomTypeId 房型id
+     * @param startTime 开始时间
+     * @param endTime 结束时间
+     * @return
+     */
+    int getBusyNum(Long roomTypeId, LocalDateTime startTime, LocalDateTime endTime);
 }
 }
 
 

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

@@ -3,7 +3,11 @@ package com.chuanghai.ihotel.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.chuanghai.ihotel.common.utils.PageUtils;
 import com.chuanghai.ihotel.common.utils.PageUtils;
 import com.chuanghai.ihotel.common.utils.PageParam;
 import com.chuanghai.ihotel.common.utils.PageParam;
+import com.chuanghai.ihotel.controller.request.RoomTypeQueryRequest;
 import com.chuanghai.ihotel.entity.RoomTypeEntity;
 import com.chuanghai.ihotel.entity.RoomTypeEntity;
+import com.chuanghai.ihotel.vo.RoomTypeShortDescVO;
+
+import java.util.List;
 
 
 /**
 /**
  * 房型 
  * 房型 
@@ -15,5 +19,7 @@ import com.chuanghai.ihotel.entity.RoomTypeEntity;
 public interface RoomTypeService extends IService<RoomTypeEntity> {
 public interface RoomTypeService extends IService<RoomTypeEntity> {
 
 
     PageUtils queryPage(PageParam pageParam);
     PageUtils queryPage(PageParam pageParam);
+
+    List<RoomTypeShortDescVO> listForClientIndex(RoomTypeQueryRequest request);
 }
 }
 
 

+ 10 - 4
src/main/java/com/chuanghai/ihotel/service/impl/RoomRealtimeStatuServiceImpl.java

@@ -1,16 +1,17 @@
 package com.chuanghai.ihotel.service.impl;
 package com.chuanghai.ihotel.service.impl;
 
 
-import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.chuanghai.ihotel.common.utils.PageUtils;
 import com.chuanghai.ihotel.common.utils.MyQuery;
 import com.chuanghai.ihotel.common.utils.MyQuery;
 import com.chuanghai.ihotel.common.utils.PageParam;
 import com.chuanghai.ihotel.common.utils.PageParam;
-
+import com.chuanghai.ihotel.common.utils.PageUtils;
 import com.chuanghai.ihotel.dao.RoomRealtimeStatuDao;
 import com.chuanghai.ihotel.dao.RoomRealtimeStatuDao;
 import com.chuanghai.ihotel.entity.RoomRealtimeStatuEntity;
 import com.chuanghai.ihotel.entity.RoomRealtimeStatuEntity;
 import com.chuanghai.ihotel.service.RoomRealtimeStatuService;
 import com.chuanghai.ihotel.service.RoomRealtimeStatuService;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
 
 
 
 
 @Service("roomRealtimeStatuService")
 @Service("roomRealtimeStatuService")
@@ -20,10 +21,15 @@ public class RoomRealtimeStatuServiceImpl extends ServiceImpl<RoomRealtimeStatuD
     public PageUtils queryPage(PageParam pageParam) {
     public PageUtils queryPage(PageParam pageParam) {
         IPage<RoomRealtimeStatuEntity> page = this.page(
         IPage<RoomRealtimeStatuEntity> page = this.page(
                 new MyQuery<RoomRealtimeStatuEntity>().getPage(pageParam),
                 new MyQuery<RoomRealtimeStatuEntity>().getPage(pageParam),
-                new QueryWrapper<RoomRealtimeStatuEntity>()
+                new QueryWrapper<>()
         );
         );
 
 
         return new PageUtils(page);
         return new PageUtils(page);
     }
     }
 
 
+    @Override
+    public int getBusyNum(Long roomTypeId, LocalDateTime startTime, LocalDateTime endTime) {
+        return this.getBaseMapper().getBusyNum(roomTypeId, startTime, endTime);
+    }
+
 }
 }

+ 34 - 1
src/main/java/com/chuanghai/ihotel/service/impl/RoomTypeServiceImpl.java

@@ -1,5 +1,11 @@
 package com.chuanghai.ihotel.service.impl;
 package com.chuanghai.ihotel.service.impl;
 
 
+import com.chuanghai.ihotel.controller.request.RoomTypeQueryRequest;
+import com.chuanghai.ihotel.service.RoomRealtimeStatuService;
+import com.chuanghai.ihotel.vo.RoomTypeShortDescVO;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -12,18 +18,45 @@ import com.chuanghai.ihotel.dao.RoomTypeDao;
 import com.chuanghai.ihotel.entity.RoomTypeEntity;
 import com.chuanghai.ihotel.entity.RoomTypeEntity;
 import com.chuanghai.ihotel.service.RoomTypeService;
 import com.chuanghai.ihotel.service.RoomTypeService;
 
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 
 
 @Service("roomTypeService")
 @Service("roomTypeService")
 public class RoomTypeServiceImpl extends ServiceImpl<RoomTypeDao, RoomTypeEntity> implements RoomTypeService {
 public class RoomTypeServiceImpl extends ServiceImpl<RoomTypeDao, RoomTypeEntity> implements RoomTypeService {
 
 
+    @Autowired
+    private RoomRealtimeStatuService roomRealtimeStatuService;
+
     @Override
     @Override
     public PageUtils queryPage(PageParam pageParam) {
     public PageUtils queryPage(PageParam pageParam) {
         IPage<RoomTypeEntity> page = this.page(
         IPage<RoomTypeEntity> page = this.page(
                 new MyQuery<RoomTypeEntity>().getPage(pageParam),
                 new MyQuery<RoomTypeEntity>().getPage(pageParam),
-                new QueryWrapper<RoomTypeEntity>()
+                new QueryWrapper<>()
         );
         );
 
 
         return new PageUtils(page);
         return new PageUtils(page);
     }
     }
 
 
+    @Cacheable(value = {"roomType"},key = "#root.method.name + '-' + #request.startTime + '-' + #request.endTime")
+    @Override
+    public List<RoomTypeShortDescVO> listForClientIndex(RoomTypeQueryRequest request) {
+        List<RoomTypeEntity> all = this.list();
+        List<RoomTypeShortDescVO> vos = all.stream().map(e -> {
+            RoomTypeShortDescVO vo = new RoomTypeShortDescVO();
+            BeanUtils.copyProperties(e, vo);
+
+            // 获取主图
+            String masterImage = e.getTypeImage().split(",")[0];
+            vo.setMasterImage(masterImage);
+
+            // 获取当前时间繁忙状态的房间数量
+            int num = roomRealtimeStatuService.getBusyNum(e.getId(), request.getStartTime(), request.getEndTime());
+            int enableNum = e.getRoomNum() - num;
+            vo.setEnableNum(enableNum >= 0 ? enableNum : 0);
+            return vo;
+        }).collect(Collectors.toList());
+        return vos;
+    }
+
 }
 }

+ 46 - 0
src/main/java/com/chuanghai/ihotel/vo/RoomTypeShortDescVO.java

@@ -0,0 +1,46 @@
+package com.chuanghai.ihotel.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @Author: codingliang
+ * @Description: 房型简介vo
+ * @Date: 2022-07-27 14:17
+ * @Version: V1.0
+ **/
+@Data
+public class RoomTypeShortDescVO {
+    /**
+     * 房型id
+     */
+    private Long id;
+    /**
+     * 房型名称
+     */
+    private String typeName;
+    /**
+     * 日常价格 单位:元/间/晚
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
+    private BigDecimal usualPrice;
+    /**
+     * 优惠价格 单位:元/间/晚
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
+    private BigDecimal discountPrice;
+    /**
+     * 房型简单描述
+     */
+    private String typeShortDesc;
+    /**
+     * 房间剩余数量
+     */
+    private Integer enableNum;
+    /**
+     * 房型图
+     */
+    private String masterImage;
+}

+ 9 - 0
src/main/resources/application.yml

@@ -15,6 +15,15 @@ spring:
     password: root
     password: root
     url: jdbc:mysql://192.168.161.230:3306/ihotel?characterEncoding=UTF-8&useSSL=false&useUnicode=true&serverTimezone=Asia/Shanghai
     url: jdbc:mysql://192.168.161.230:3306/ihotel?characterEncoding=UTF-8&useSSL=false&useUnicode=true&serverTimezone=Asia/Shanghai
     driver-class-name: com.mysql.cj.jdbc.Driver
     driver-class-name: com.mysql.cj.jdbc.Driver
+  cache:
+    type: redis
+    redis:
+      time-to-live: 3600000
+      key-prefix: SPRING_CACHE_
+      use-key-prefix: true
+      cache-null-values: true
+  redis:
+    host: 192.168.126.131
 #  rabbitmq:
 #  rabbitmq:
 #    host: 192.168.126.131
 #    host: 192.168.126.131
 #    port: 5672
 #    port: 5672

+ 8 - 1
src/main/resources/mapper/ihotel/RoomRealtimeStatuDao.xml

@@ -15,5 +15,12 @@
         <result property="bizId" column="biz_id"/>
         <result property="bizId" column="biz_id"/>
     </resultMap>
     </resultMap>
 
 
-
+    <select id="getBusyNum" resultType="int">
+        select count(1)
+        from room_realtime_statu
+        where
+              room_type_id = #{roomTypeId}
+            and statu != '1'
+            and not(end_time <![CDATA[<]]> #{startTime} or start_time <![CDATA[>]]> #{endTime})
+    </select>
 </mapper>
 </mapper>