mirror of
				https://github.com/FreeeBird/hotel.git
				synced 2025-10-30 20:14:47 +08:00 
			
		
		
		
	update RoomType
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| # 酒店管理系统 | ||||
|  | ||||
| ## 1.背景说明 | ||||
| ## 1 背景说明 | ||||
|  | ||||
| ### 1.1  整体背景 | ||||
|   随着旅游业的发展,以及世界商贸活动的频繁举行,其周边行业如酒店、餐饮、娱乐等行业也日趋发达。其中酒店宾馆组织庞大、服务项目多、信息量庞大,传统的人工管理方式已经无法满足要求。此时需要借助于计算机来进行现代化信息管理,从而提高服务质量和管理水平,同时降低管理成本。 | ||||
| @@ -9,7 +9,7 @@ | ||||
| ### 1.3 业务背景 | ||||
|   传统的酒店管理往往需要酒店管理人花大量时间和精力来处理顾客查询、顾客登记等等事务。而错误的查询、繁琐的登记和结账手续、费用的结算错误、空余客房不能及时提供等等问题,可能导致顾客的频繁投诉,从而影响酒店的出租率。这些问题都可以通过计算机辅助系统来解决。酒店管理的信息化,不仅是酒店现代化形象的标志,而且能够酒店员工的工作效率,加速资金周转、降低各项成本以及改善服务质量。并支持客户直接在线预订,为客户提供方便快捷的服务. | ||||
|  | ||||
| ## 2.项目说明 | ||||
| ## 2 项目说明 | ||||
| ### 2.1 问题说明 | ||||
| 由于酒店的客房有不同的档次,所以需要能够对客房进行分类处理。同时为了方便对客房价格的设置,需要提供一个能够对不同档次的客房能够进行预订价格、预订折扣、计时最低价格等的设置。需要提供一个客房设置功能,用来设置酒店的所有客房信息。在设置客房信息时,应该提供对不同房间的实际价格、实际折扣的设置。特别重要的是能够对房间的状态以及是否可用进行设置,这样能够方便酒店对客房的及时管理。需要提供一个入住登记和结账功能,并且能够对客户的登记时间、离店时间、客户资料、入住房间等信息进行登记。需要提供一个预定中心,能够处理客户的各种预定,如电话预定、总台面约、网上预定以及领导安排等等预定方式。需要提供一个客户管理功能,从而实现对酒店的客户信息的统一管理。最后还需要提供一个业务统计报表功能,能够对酒店一年中每月的住宿率进行统计,然后生成柱状图进行显示。 | ||||
| ### 2.2 用户期望 | ||||
|   | ||||
| @@ -0,0 +1,26 @@ | ||||
| package cn.mafangui.hotel.controller; | ||||
|  | ||||
| import cn.mafangui.hotel.entity.RoomType; | ||||
| import cn.mafangui.hotel.service.RoomTypeService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
|  | ||||
| @RestController | ||||
| @RequestMapping(value = "/roomType") | ||||
| public class RoomTypeController { | ||||
|  | ||||
|     @Autowired | ||||
|     private RoomTypeService roomTypeService; | ||||
|  | ||||
|     @RequestMapping(value = "/add") | ||||
|     public int addNewType(int roomType,String typeName,double bookingPrice,double bookingDiscount){ | ||||
|         RoomType rt = new RoomType(roomType,typeName,bookingPrice,bookingDiscount); | ||||
|         return roomTypeService.addRoomType(rt); | ||||
|     } | ||||
|  | ||||
|     public int delType(int roomType,String typeName){ | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -10,9 +10,9 @@ public class RoomType { | ||||
|  | ||||
|     private String typeName; | ||||
|  | ||||
|     private BigDecimal bookingPrice; | ||||
|     private Double bookingPrice; | ||||
|  | ||||
|     private Float bookingDiscount; | ||||
|     private Double bookingDiscount; | ||||
|  | ||||
|     private Date createTime; | ||||
|  | ||||
| @@ -42,19 +42,19 @@ public class RoomType { | ||||
|         this.typeName = typeName == null ? null : typeName.trim(); | ||||
|     } | ||||
|  | ||||
|     public BigDecimal getBookingPrice() { | ||||
|     public Double getBookingPrice() { | ||||
|         return bookingPrice; | ||||
|     } | ||||
|  | ||||
|     public void setBookingPrice(BigDecimal bookingPrice) { | ||||
|     public void setBookingPrice(Double bookingPrice) { | ||||
|         this.bookingPrice = bookingPrice; | ||||
|     } | ||||
|  | ||||
|     public Float getBookingDiscount() { | ||||
|     public Double getBookingDiscount() { | ||||
|         return bookingDiscount; | ||||
|     } | ||||
|  | ||||
|     public void setBookingDiscount(Float bookingDiscount) { | ||||
|     public void setBookingDiscount(Double bookingDiscount) { | ||||
|         this.bookingDiscount = bookingDiscount; | ||||
|     } | ||||
|  | ||||
| @@ -73,4 +73,25 @@ public class RoomType { | ||||
|     public void setUpdateTime(Date updateTime) { | ||||
|         this.updateTime = updateTime; | ||||
|     } | ||||
|  | ||||
|     public RoomType(Integer roomType, String typeName, Double bookingPrice, Double bookingDiscount) { | ||||
|         this.roomType = roomType; | ||||
|         this.typeName = typeName; | ||||
|         this.bookingPrice = bookingPrice; | ||||
|         this.bookingDiscount = bookingDiscount; | ||||
|     } | ||||
|     public RoomType(){} | ||||
|  | ||||
|     @Override | ||||
|     public String toString() { | ||||
|         return "RoomType{" + | ||||
|                 "typeId=" + typeId + | ||||
|                 ", roomType=" + roomType + | ||||
|                 ", typeName='" + typeName + '\'' + | ||||
|                 ", bookingPrice=" + bookingPrice + | ||||
|                 ", bookingDiscount=" + bookingDiscount + | ||||
|                 ", createTime=" + createTime + | ||||
|                 ", updateTime=" + updateTime + | ||||
|                 '}'; | ||||
|     } | ||||
| } | ||||
| @@ -1,17 +1,21 @@ | ||||
| package cn.mafangui.hotel.mapper; | ||||
|  | ||||
| import cn.mafangui.hotel.entity.RoomType; | ||||
| import org.springframework.stereotype.Component; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| @Component | ||||
| public interface RoomTypeMapper { | ||||
|     int deleteByPrimaryKey(Integer typeId); | ||||
|  | ||||
|     int insert(RoomType record); | ||||
|     RoomType selectByPrimaryKey(Integer typeId); | ||||
|     int updateByPrimaryKeySelective(RoomType record); | ||||
|     int updateByPrimaryKey(RoomType record); | ||||
|  | ||||
|     int insertSelective(RoomType record); | ||||
|  | ||||
|     RoomType selectByPrimaryKey(Integer typeId); | ||||
|  | ||||
|     int updateByPrimaryKeySelective(RoomType record); | ||||
|  | ||||
|     int updateByPrimaryKey(RoomType record); | ||||
|     int updateByRoomTypeSelective(RoomType record); | ||||
|     int deleteByRoomType(RoomType roomType); | ||||
|     RoomType selectByRoomType(RoomType roomType); | ||||
|     List<RoomType> findAll(); | ||||
| } | ||||
							
								
								
									
										18
									
								
								src/main/java/cn/mafangui/hotel/service/RoomTypeService.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/main/java/cn/mafangui/hotel/service/RoomTypeService.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| package cn.mafangui.hotel.service; | ||||
|  | ||||
| import cn.mafangui.hotel.entity.RoomType; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| public interface RoomTypeService { | ||||
|  | ||||
|     int addRoomType(RoomType roomType); | ||||
|  | ||||
|     int delRoomType(RoomType roomType); | ||||
|  | ||||
|     int updateRoomType(RoomType roomType); | ||||
|  | ||||
|     RoomType selectByName(RoomType roomType); | ||||
|  | ||||
|     List<RoomType> findAllType(); | ||||
| } | ||||
| @@ -0,0 +1,40 @@ | ||||
| package cn.mafangui.hotel.service.impl; | ||||
|  | ||||
| import cn.mafangui.hotel.entity.RoomType; | ||||
| import cn.mafangui.hotel.mapper.RoomTypeMapper; | ||||
| import cn.mafangui.hotel.service.RoomTypeService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| @Service | ||||
| public class RoomTypeServiceImpl implements RoomTypeService { | ||||
|     @Autowired | ||||
|     private RoomTypeMapper roomTypeMapper; | ||||
|  | ||||
|     @Override | ||||
|     public int addRoomType(RoomType roomType) { | ||||
|         return roomTypeMapper.insertSelective(roomType); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int delRoomType(RoomType roomType) { | ||||
|         return roomTypeMapper.deleteByRoomType(roomType); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int updateRoomType(RoomType roomType) { | ||||
|         return roomTypeMapper.updateByRoomTypeSelective(roomType); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public RoomType selectByName(RoomType roomType) { | ||||
|         return roomTypeMapper.selectByRoomType(roomType); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<RoomType> findAllType() { | ||||
|         return roomTypeMapper.findAll(); | ||||
|     } | ||||
| } | ||||
| @@ -5,8 +5,8 @@ | ||||
|     <id column="type_id" jdbcType="INTEGER" property="typeId" /> | ||||
|     <result column="room_type" jdbcType="INTEGER" property="roomType" /> | ||||
|     <result column="type_name" jdbcType="VARCHAR" property="typeName" /> | ||||
|     <result column="booking_price" jdbcType="DECIMAL" property="bookingPrice" /> | ||||
|     <result column="booking_discount" jdbcType="REAL" property="bookingDiscount" /> | ||||
|     <result column="booking_price" jdbcType="DOUBLE" property="bookingPrice" /> | ||||
|     <result column="booking_discount" jdbcType="DOUBLE" property="bookingDiscount" /> | ||||
|     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | ||||
|     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> | ||||
|   </resultMap> | ||||
| @@ -19,6 +19,15 @@ | ||||
|     from room_type | ||||
|     where type_id = #{typeId,jdbcType=INTEGER} | ||||
|   </select> | ||||
|   <select id="selectByRoomType" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | ||||
|     select | ||||
|     <include refid="Base_Column_List" /> | ||||
|     from room_type | ||||
|     where room_type = #{roomType,jdbcType=INTEGER} | ||||
|   </select> | ||||
|   <select id="findAll" resultMap="BaseResultMap"> | ||||
|     select * FROM room_type | ||||
|   </select> | ||||
|   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> | ||||
|     delete from room_type | ||||
|     where type_id = #{typeId,jdbcType=INTEGER} | ||||
| @@ -28,15 +37,12 @@ | ||||
|       booking_price, booking_discount, create_time,  | ||||
|       update_time) | ||||
|     values (#{typeId,jdbcType=INTEGER}, #{roomType,jdbcType=INTEGER}, #{typeName,jdbcType=VARCHAR},  | ||||
|       #{bookingPrice,jdbcType=DECIMAL}, #{bookingDiscount,jdbcType=REAL}, #{createTime,jdbcType=TIMESTAMP},  | ||||
|       #{bookingPrice,jdbcType=DOUBLE}, #{bookingDiscount,jdbcType=DOUBLE}, #{createTime,jdbcType=TIMESTAMP}, | ||||
|       #{updateTime,jdbcType=TIMESTAMP}) | ||||
|   </insert> | ||||
|   <insert id="insertSelective" parameterType="cn.mafangui.hotel.entity.RoomType"> | ||||
|     insert into room_type | ||||
|     <trim prefix="(" suffix=")" suffixOverrides=","> | ||||
|       <if test="typeId != null"> | ||||
|         type_id, | ||||
|       </if> | ||||
|       <if test="roomType != null"> | ||||
|         room_type, | ||||
|       </if> | ||||
| @@ -49,17 +55,10 @@ | ||||
|       <if test="bookingDiscount != null"> | ||||
|         booking_discount, | ||||
|       </if> | ||||
|       <if test="createTime != null"> | ||||
|         create_time, | ||||
|       </if> | ||||
|       <if test="updateTime != null"> | ||||
|         update_time, | ||||
|       </if> | ||||
|     </trim> | ||||
|     <trim prefix="values (" suffix=")" suffixOverrides=","> | ||||
|       <if test="typeId != null"> | ||||
|         #{typeId,jdbcType=INTEGER}, | ||||
|       </if> | ||||
|       <if test="roomType != null"> | ||||
|         #{roomType,jdbcType=INTEGER}, | ||||
|       </if> | ||||
| @@ -67,17 +66,13 @@ | ||||
|         #{typeName,jdbcType=VARCHAR}, | ||||
|       </if> | ||||
|       <if test="bookingPrice != null"> | ||||
|         #{bookingPrice,jdbcType=DECIMAL}, | ||||
|         #{bookingPrice,jdbcType=DOUBLE}, | ||||
|       </if> | ||||
|       <if test="bookingDiscount != null"> | ||||
|         #{bookingDiscount,jdbcType=REAL}, | ||||
|       </if> | ||||
|       <if test="createTime != null"> | ||||
|         #{createTime,jdbcType=TIMESTAMP}, | ||||
|       </if> | ||||
|       <if test="updateTime != null"> | ||||
|         #{updateTime,jdbcType=TIMESTAMP}, | ||||
|         #{bookingDiscount,jdbcType=DOUBLE}, | ||||
|       </if> | ||||
|       now(), | ||||
|       now() | ||||
|     </trim> | ||||
|   </insert> | ||||
|   <update id="updateByPrimaryKeySelective" parameterType="cn.mafangui.hotel.entity.RoomType"> | ||||
| @@ -114,4 +109,24 @@ | ||||
|       update_time = #{updateTime,jdbcType=TIMESTAMP} | ||||
|     where type_id = #{typeId,jdbcType=INTEGER} | ||||
|   </update> | ||||
|   <delete id="deleteByRoomType" parameterType="java.lang.Integer"> | ||||
|     delete from room_type | ||||
|     where room_type = #{roomType,jdbcType=INTEGER} | ||||
|   </delete> | ||||
|   <update id="updateByRoomTypeSelective" parameterType="cn.mafangui.hotel.entity.RoomType"> | ||||
|     update room_type | ||||
|     <set> | ||||
|       <if test="typeName != null"> | ||||
|         type_name = #{typeName,jdbcType=VARCHAR}, | ||||
|       </if> | ||||
|       <if test="bookingPrice != null"> | ||||
|         booking_price = #{bookingPrice,jdbcType=DOUBLE}, | ||||
|       </if> | ||||
|       <if test="bookingDiscount != null"> | ||||
|         booking_discount = #{bookingDiscount,jdbcType=DOUBLE}, | ||||
|       </if> | ||||
|         update_time = now(), | ||||
|     </set> | ||||
|     where room_type = #{roomType,jdbcType=INTEGER} | ||||
|   </update> | ||||
| </mapper> | ||||
| @@ -0,0 +1,55 @@ | ||||
| package cn.mafangui.hotel.service.impl; | ||||
|  | ||||
| import cn.mafangui.hotel.entity.RoomType; | ||||
| import cn.mafangui.hotel.mapper.RoomTypeMapper; | ||||
| import org.junit.Assert; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.boot.test.context.SpringBootTest; | ||||
| import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||||
|  | ||||
| import static org.junit.Assert.*; | ||||
|  | ||||
| @RunWith(SpringJUnit4ClassRunner.class) | ||||
| @SpringBootTest | ||||
| public class RoomTypeServiceImplTest { | ||||
|  | ||||
|     @Autowired | ||||
|     private RoomTypeMapper roomTypeMapper; | ||||
|  | ||||
|     @Test | ||||
|     public void addRoomType() { | ||||
|         RoomType roomType = new RoomType(201,"豪华大床房",229.00,20.0); | ||||
|         Assert.assertEquals(1, roomTypeMapper.insertSelective(roomType)); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void delRoomType() { | ||||
|         RoomType roomType = new RoomType(); | ||||
|         roomType.setRoomType(201); | ||||
|         Assert.assertEquals(1, roomTypeMapper.deleteByRoomType(roomType)); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void updateRoomType() { | ||||
|         RoomType roomType = new RoomType(); | ||||
|         roomType.setRoomType(103); | ||||
|         roomType.setBookingDiscount(20.0); | ||||
|         Assert.assertEquals(1,roomTypeMapper.updateByRoomTypeSelective(roomType)); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void selectByName() { | ||||
|         RoomType roomType = new RoomType(); | ||||
|         roomType.setRoomType(103); | ||||
|         System.out.println(roomTypeMapper.selectByRoomType(roomType)); | ||||
|         Assert.assertNotNull(roomTypeMapper.selectByRoomType(roomType)); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void findAllType() { | ||||
|         System.out.println(roomTypeMapper.findAll()); | ||||
|         Assert.assertNotNull(roomTypeMapper.findAll()); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user