更新数据库结构,重写接口

This commit is contained in:
freeebird
2018-11-26 18:20:22 +08:00
parent ab33c31665
commit 346dca6e65
12 changed files with 125 additions and 35 deletions

View File

@@ -0,0 +1,14 @@
server:
port: 8080
servlet:
context-path: "/hotel"
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
url: jdbc:mysql://127.0.0.1:3306/hotel?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
mybatis:
type-aliases-package: classpath*:cn.mafangui.hotel.entity
mapper-locations: classpath*:mybatis/mapper/*.xml

View File

@@ -7,7 +7,7 @@ spring:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
url: jdbc:mysql://127.0.0.1:3306/hotel?useUnicode=true&characterEncoding=UTF-8
url: jdbc:mysql://127.0.0.1:3306/hotel?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
mybatis:
type-aliases-package: classpath*:cn.mafangui.hotel.entity
mapper-locations: classpath*:mybatis/mapper/*.xml

View File

@@ -5,6 +5,7 @@
<id column="order_id" jdbcType="INTEGER" property="orderId" />
<result column="order_type" jdbcType="VARCHAR" property="orderType" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="room_type" jdbcType="VARCHAR" property="roomType" />
<result column="order_date" jdbcType="DATE" property="orderDate" />
@@ -15,11 +16,11 @@
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
order_id, order_type, user_id, phone, room_type, order_date, order_days, order_status,
order_id, order_type, user_id, name,phone, room_type, order_date, order_days, order_status,
order_cost, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
select
<include refid="Base_Column_List" />
from order_info
where order_id = #{orderId,jdbcType=INTEGER}
@@ -35,18 +36,25 @@
<include refid="Base_Column_List" />
from order_info
</select>
<select id="userSelectAll" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
*
from order_info
where order_status >= -2 and user_id = #{userId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from order_info
where order_id = #{orderId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="cn.mafangui.hotel.entity.Order">
insert into order_info (order_id, order_type, phone,
room_type, num_of_room, order_date,
order_days, order_status, order_cost,
insert into order_info (order_id, order_type,name, phone,
room_type, order_date,
order_days, order_status, order_cost,
create_time, update_time)
values (#{orderId,jdbcType=INTEGER}, #{orderType,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
#{roomType,jdbcType=VARCHAR}, #{numOfRoom,jdbcType=INTEGER}, #{orderDate,jdbcType=DATE},
#{orderDays,jdbcType=INTEGER}, #{orderStatus,jdbcType=INTEGER}, #{orderCost,jdbcType=DOUBLE},
values (#{orderId,jdbcType=INTEGER}, #{orderType,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},#{phone,jdbcType=VARCHAR},
#{roomType,jdbcType=VARCHAR},#{orderDate,jdbcType=DATE},
#{orderDays,jdbcType=INTEGER}, #{orderStatus,jdbcType=INTEGER}, #{orderCost,jdbcType=DOUBLE},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="cn.mafangui.hotel.entity.Order">
@@ -58,15 +66,18 @@
<if test="orderType != null">
order_type,
</if>
<if test="userId != null">
user_id,
</if>
<if test="name != null">
name,
</if>
<if test="phone != null">
phone,
</if>
<if test="roomType != null">
room_type,
</if>
<if test="numOfRoom != null">
num_of_room,
</if>
<if test="orderDate != null">
order_date,
</if>
@@ -89,15 +100,18 @@
<if test="orderType != null">
#{orderType,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="roomType != null">
#{roomType,jdbcType=VARCHAR},
</if>
<if test="numOfRoom != null">
#{numOfRoom,jdbcType=INTEGER},
</if>
<if test="orderDate != null">
#{orderDate,jdbcType=DATE},
</if>
@@ -120,15 +134,15 @@
<if test="orderType != null">
order_type = #{orderType,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR}
</if>
<if test="phone != null">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="roomType != null">
room_type = #{roomType,jdbcType=VARCHAR},
</if>
<if test="numOfRoom != null">
num_of_room = #{numOfRoom,jdbcType=INTEGER},
</if>
<if test="orderDate != null">
order_date = #{orderDate,jdbcType=DATE},
</if>
@@ -148,9 +162,9 @@
<update id="updateByPrimaryKey" parameterType="cn.mafangui.hotel.entity.Order">
update order_info
set order_type = #{orderType,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
phone = #{phone,jdbcType=VARCHAR},
room_type = #{roomType,jdbcType=VARCHAR},
num_of_room = #{numOfRoom,jdbcType=INTEGER},
order_date = #{orderDate,jdbcType=DATE},
order_days = #{orderDays,jdbcType=INTEGER},
order_status = #{orderStatus,jdbcType=INTEGER},
@@ -158,4 +172,4 @@
update_time = now()
where order_id = #{orderId,jdbcType=INTEGER}
</update>
</mapper>
</mapper>