mirror of
https://github.com/FreeeBird/hotel.git
synced 2025-05-06 19:49:26 +08:00
完成入住登记接口编写
This commit is contained in:
parent
37dc55809e
commit
c39dcd5dfa
@ -0,0 +1,57 @@
|
||||
package cn.mafangui.hotel.controller;
|
||||
|
||||
import cn.mafangui.hotel.entity.CheckIn;
|
||||
import cn.mafangui.hotel.service.CheckInService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/checkIn")
|
||||
public class CheckInController {
|
||||
|
||||
@Autowired
|
||||
private CheckInService checkInService;
|
||||
|
||||
@RequestMapping(value = "/add")
|
||||
public int addCheckIn(int peo_count, String persons, String ids){
|
||||
CheckIn checkIn = new CheckIn();
|
||||
checkIn.setPeoCount(peo_count);
|
||||
checkIn.setPersons(persons);
|
||||
checkIn.setIds(ids);
|
||||
checkIn.setCheckInTime(new Date());
|
||||
return checkInService.insert(checkIn);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete")
|
||||
public int deleteCheckIn(int checkId){
|
||||
return checkInService.delete(checkId)
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update")
|
||||
public int update(int checkId,String roomNumber){
|
||||
CheckIn checkIn = new CheckIn();
|
||||
checkIn.setCheckInId(checkId);
|
||||
checkIn.setRoomNumber(roomNumber);
|
||||
return checkInService.update(checkIn);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/checkOut")
|
||||
public int checkOut(String roomNumber){
|
||||
return checkInService.updateByRoomNumber(roomNumber);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/withId")
|
||||
public CheckIn getById(int checkId){
|
||||
return checkInService.selectById(checkId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/all")
|
||||
public List<CheckIn> getAll(){
|
||||
return checkInService.selectAll();
|
||||
}
|
||||
|
||||
}
|
@ -9,8 +9,6 @@ public class CheckIn {
|
||||
|
||||
private String roomNumber;
|
||||
|
||||
private String roomType;
|
||||
|
||||
private Integer peoCount;
|
||||
|
||||
private String persons;
|
||||
@ -19,10 +17,20 @@ public class CheckIn {
|
||||
|
||||
private Date checkInTime;
|
||||
|
||||
private Date checkOutTime;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
public Date getCheckOutTime() {
|
||||
return checkOutTime;
|
||||
}
|
||||
|
||||
public void setCheckOutTime(Date checkOutTime) {
|
||||
this.checkOutTime = checkOutTime;
|
||||
}
|
||||
|
||||
public Integer getCheckInId() {
|
||||
return checkInId;
|
||||
}
|
||||
@ -47,13 +55,6 @@ public class CheckIn {
|
||||
this.roomNumber = roomNumber == null ? null : roomNumber.trim();
|
||||
}
|
||||
|
||||
public String getRoomType() {
|
||||
return roomType;
|
||||
}
|
||||
|
||||
public void setRoomType(String roomType) {
|
||||
this.roomType = roomType == null ? null : roomType.trim();
|
||||
}
|
||||
|
||||
public Integer getPeoCount() {
|
||||
return peoCount;
|
||||
@ -102,4 +103,31 @@ public class CheckIn {
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public CheckIn() {
|
||||
}
|
||||
|
||||
public CheckIn(String roomNumber, String roomType, Integer peoCount, String persons, String ids, Date checkInTime) {
|
||||
this.roomNumber = roomNumber;
|
||||
this.peoCount = peoCount;
|
||||
this.persons = persons;
|
||||
this.ids = ids;
|
||||
this.checkInTime = checkInTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CheckIn{" +
|
||||
"checkInId=" + checkInId +
|
||||
", orderId=" + orderId +
|
||||
", roomNumber='" + roomNumber + '\'' +
|
||||
", peoCount=" + peoCount +
|
||||
", persons='" + persons + '\'' +
|
||||
", ids='" + ids + '\'' +
|
||||
", checkInTime=" + checkInTime +
|
||||
", checkOutTime=" + checkOutTime +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -1,7 +1,11 @@
|
||||
package cn.mafangui.hotel.mapper;
|
||||
|
||||
import cn.mafangui.hotel.entity.CheckIn;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public interface CheckInMapper {
|
||||
int deleteByPrimaryKey(Integer checkInId);
|
||||
|
||||
@ -11,7 +15,12 @@ public interface CheckInMapper {
|
||||
|
||||
CheckIn selectByPrimaryKey(Integer checkInId);
|
||||
|
||||
int updateByRoomNumber(String roomNumber);
|
||||
|
||||
int updateByPrimaryKeySelective(CheckIn record);
|
||||
|
||||
int updateByPrimaryKey(CheckIn record);
|
||||
|
||||
List<CheckIn> selectAll();
|
||||
|
||||
}
|
21
src/main/java/cn/mafangui/hotel/service/CheckInService.java
Normal file
21
src/main/java/cn/mafangui/hotel/service/CheckInService.java
Normal file
@ -0,0 +1,21 @@
|
||||
package cn.mafangui.hotel.service;
|
||||
|
||||
import cn.mafangui.hotel.entity.CheckIn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CheckInService {
|
||||
|
||||
int insert(CheckIn checkIn);
|
||||
|
||||
int delete(int checkInId);
|
||||
|
||||
int update(CheckIn checkIn);
|
||||
|
||||
int updateByRoomNumber(String roomNumber);
|
||||
|
||||
CheckIn selectById(int checkInId);
|
||||
|
||||
List<CheckIn> selectAll();
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package cn.mafangui.hotel.service.impl;
|
||||
|
||||
import cn.mafangui.hotel.entity.CheckIn;
|
||||
import cn.mafangui.hotel.mapper.CheckInMapper;
|
||||
import cn.mafangui.hotel.service.CheckInService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CheckInServiceImpl implements CheckInService {
|
||||
@Autowired
|
||||
private CheckInMapper checkInMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public int insert(CheckIn checkIn) {
|
||||
return checkInMapper.insert(checkIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(int checkInId) {
|
||||
return checkInMapper.deleteByPrimaryKey(checkInId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(CheckIn checkIn) {
|
||||
return checkInMapper.updateByPrimaryKeySelective(checkIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByRoomNumber(String roomNumber) {
|
||||
return checkInMapper.updateByRoomNumber(roomNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckIn selectById(int checkInId) {
|
||||
return checkInMapper.selectByPrimaryKey(checkInId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CheckIn> selectAll() {
|
||||
return checkInMapper.selectAll();
|
||||
}
|
||||
}
|
@ -5,16 +5,16 @@
|
||||
<id column="check_in_id" jdbcType="INTEGER" property="checkInId" />
|
||||
<result column="order_id" jdbcType="INTEGER" property="orderId" />
|
||||
<result column="room_number" jdbcType="VARCHAR" property="roomNumber" />
|
||||
<result column="room_type" jdbcType="VARCHAR" property="roomType" />
|
||||
<result column="peo_count" jdbcType="INTEGER" property="peoCount" />
|
||||
<result column="persons" jdbcType="VARCHAR" property="persons" />
|
||||
<result column="ids" jdbcType="VARCHAR" property="ids" />
|
||||
<result column="check_in_time" jdbcType="TIMESTAMP" property="checkInTime" />
|
||||
<result column="check_out_time" jdbcType="TIMESTAMP" property="checkOutTime" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
check_in_id, order_id, room_number, room_type, peo_count, persons, ids, check_in_time,
|
||||
check_in_id, order_id, room_number,peo_count, persons, ids, check_in_time, check_out_time,
|
||||
create_time, update_time
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
@ -23,17 +23,22 @@
|
||||
from check_in
|
||||
where check_in_id = #{checkInId,jdbcType=INTEGER}
|
||||
</select>
|
||||
<select id="selectAll" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from check_in
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from check_in
|
||||
where check_in_id = #{checkInId,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="cn.mafangui.hotel.entity.CheckIn">
|
||||
insert into check_in (check_in_id, order_id, room_number,
|
||||
room_type, peo_count, persons,
|
||||
peo_count, persons,
|
||||
ids, check_in_time, create_time,
|
||||
update_time)
|
||||
values (#{checkInId,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER}, #{roomNumber,jdbcType=VARCHAR},
|
||||
#{roomType,jdbcType=VARCHAR}, #{peoCount,jdbcType=INTEGER}, #{persons,jdbcType=VARCHAR},
|
||||
#{peoCount,jdbcType=INTEGER}, #{persons,jdbcType=VARCHAR},
|
||||
#{ids,jdbcType=VARCHAR}, #{checkInTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
|
||||
#{updateTime,jdbcType=TIMESTAMP})
|
||||
</insert>
|
||||
@ -49,9 +54,6 @@
|
||||
<if test="roomNumber != null">
|
||||
room_number,
|
||||
</if>
|
||||
<if test="roomType != null">
|
||||
room_type,
|
||||
</if>
|
||||
<if test="peoCount != null">
|
||||
peo_count,
|
||||
</if>
|
||||
@ -64,12 +66,8 @@
|
||||
<if test="checkInTime != null">
|
||||
check_in_time,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="checkInId != null">
|
||||
@ -81,9 +79,6 @@
|
||||
<if test="roomNumber != null">
|
||||
#{roomNumber,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="roomType != null">
|
||||
#{roomType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="peoCount != null">
|
||||
#{peoCount,jdbcType=INTEGER},
|
||||
</if>
|
||||
@ -96,12 +91,11 @@
|
||||
<if test="checkInTime != null">
|
||||
#{checkInTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=TIMESTAMP},
|
||||
<if test="checkOutTime != null">
|
||||
#{checkOutTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
now(),
|
||||
now(),
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="cn.mafangui.hotel.entity.CheckIn">
|
||||
@ -113,9 +107,6 @@
|
||||
<if test="roomNumber != null">
|
||||
room_number = #{roomNumber,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="roomType != null">
|
||||
room_type = #{roomType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="peoCount != null">
|
||||
peo_count = #{peoCount,jdbcType=INTEGER},
|
||||
</if>
|
||||
@ -128,26 +119,30 @@
|
||||
<if test="checkInTime != null">
|
||||
check_in_time = #{checkInTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
<if test="checkOutTime != null">
|
||||
check_out_time = #{checkOutTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
update_time = now(),
|
||||
</set>
|
||||
where check_in_id = #{checkInId,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByRoomNumber" parameterType="String">
|
||||
update check_in
|
||||
set
|
||||
check_out_time = now(),
|
||||
update_time = now()
|
||||
where room_number = #{roomNumber,jdbcType=VARCHAR} and check_out_time = '0000-00-00 00:00:00'
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="cn.mafangui.hotel.entity.CheckIn">
|
||||
update check_in
|
||||
set order_id = #{orderId,jdbcType=INTEGER},
|
||||
room_number = #{roomNumber,jdbcType=VARCHAR},
|
||||
room_type = #{roomType,jdbcType=VARCHAR},
|
||||
peo_count = #{peoCount,jdbcType=INTEGER},
|
||||
persons = #{persons,jdbcType=VARCHAR},
|
||||
ids = #{ids,jdbcType=VARCHAR},
|
||||
check_in_time = #{checkInTime,jdbcType=TIMESTAMP},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
||||
check_out_time = #{checkOutTime,jdbcType=TIMESTAMP},
|
||||
update_time = now()
|
||||
where check_in_id = #{checkInId,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user