后端创建订单接口完成;删除service层interface
This commit is contained in:
@@ -21,3 +21,8 @@ spring:
|
||||
url: jdbc:mysql://127.0.0.1:3306/epp?useUnicode=true&characterEncoding=utf8&useSSL=false
|
||||
username: root
|
||||
password: root
|
||||
|
||||
logging:
|
||||
level:
|
||||
org.mybatis.spring.SqlSessionFactoryBean: DEBUG
|
||||
# org.mybatis.spring.SqlSessionFactoryBean: TRACE
|
||||
|
@@ -3,6 +3,24 @@
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cxyxiaomo.epp.shop.dao.GoodsDao">
|
||||
<resultMap id="GoodsResultMap" type="com.cxyxiaomo.epp.common.pojo.Good">
|
||||
<id column="id" property="id" />
|
||||
<result column="goods_name" property="goodsName" />
|
||||
<result column="category_id" property="categoryId" />
|
||||
<result column="brand" property="brand" />
|
||||
<result column="gallery" property="gallery" />
|
||||
<result column="brief" property="brief" />
|
||||
<result column="is_on_sale" property="isOnSale" />
|
||||
<result column="sort_order" property="sortOrder" />
|
||||
<result column="pic_url" property="picUrl" />
|
||||
<result column="type" property="type" />
|
||||
<result column="unit" property="unit" />
|
||||
<result column="counter_price" property="counterPrice" />
|
||||
<result column="retail_price" property="retailPrice" />
|
||||
<result column="detail" property="detail" />
|
||||
<result column="deleted" property="deleted" />
|
||||
</resultMap>
|
||||
|
||||
<!--<insert id="insert" parameterType="com.cxyxiaomo.epp.common.pojo.Good">-->
|
||||
<!-- INSERT INTO report (`user_id`, `name`, `address`, `time`, `temperature`)-->
|
||||
<!-- VALUES (#{userId}, #{name}, #{address}, #{time}, #{temperature})-->
|
||||
@@ -25,4 +43,50 @@
|
||||
WHERE id = #{id}
|
||||
order by `sort_order` asc
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultMap="GoodsResultMap">
|
||||
SELECT *
|
||||
FROM goods
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!--<select id="selectByCategoryId" resultMap="GoodsResultMap">-->
|
||||
<!-- SELECT *-->
|
||||
<!-- FROM goods-->
|
||||
<!-- WHERE category_id = #{categoryId}-->
|
||||
<!--</select>-->
|
||||
|
||||
<!--<select id="selectAll" resultMap="GoodsResultMap">-->
|
||||
<!-- SELECT *-->
|
||||
<!-- FROM goods-->
|
||||
<!--</select>-->
|
||||
|
||||
<insert id="insert" parameterType="com.cxyxiaomo.epp.common.pojo.Good" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO goods (goods_name, category_id, brand, gallery, brief, is_on_sale, sort_order, pic_url, type, unit, counter_price, retail_price, detail, deleted)
|
||||
VALUES (#{goodsName}, #{categoryId}, #{brand}, #{gallery}, #{brief}, #{isOnSale}, #{sortOrder}, #{picUrl}, #{type}, #{unit}, #{counterPrice}, #{retailPrice}, #{detail}, #{deleted})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.cxyxiaomo.epp.common.pojo.Good">
|
||||
UPDATE goods
|
||||
SET goods_name = #{goodsName},
|
||||
category_id = #{categoryId},
|
||||
brand = #{brand},
|
||||
gallery = #{gallery},
|
||||
brief = #{brief},
|
||||
is_on_sale = #{isOnSale},
|
||||
sort_order = #{sortOrder},
|
||||
pic_url = #{picUrl},
|
||||
type = #{type},
|
||||
unit = #{unit},
|
||||
counter_price = #{counterPrice},
|
||||
retail_price = #{retailPrice},
|
||||
detail = #{detail},
|
||||
deleted = #{deleted}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM goods
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cxyxiaomo.epp.shop.dao.OrderDao">
|
||||
|
||||
<resultMap id="OrderResultMap" type="com.cxyxiaomo.epp.common.pojo.Order">
|
||||
<id column="id" property="id"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="order_date" property="orderDate"/>
|
||||
<result column="order_status" property="orderStatus"/>
|
||||
</resultMap>
|
||||
<resultMap id="OrderDetailResultMap" type="com.cxyxiaomo.epp.common.pojo.OrderDetail">
|
||||
<id property="id" column="id" />
|
||||
<result property="orderId" column="order_id" />
|
||||
<result property="goodId" column="good_id" />
|
||||
<result property="goodCount" column="good_count" />
|
||||
<result property="unitPrice" column="unit_price" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 根据订单 ID 查询订单信息 -->
|
||||
<select id="getOrderById" resultMap="OrderResultMap">
|
||||
SELECT * FROM order WHERE order_id=#{orderId}
|
||||
</select>
|
||||
|
||||
<!-- 根据用户 ID 查询订单列表 -->
|
||||
<select id="listOrdersByUserId" resultType="com.cxyxiaomo.epp.common.pojo.Order">
|
||||
SELECT *
|
||||
FROM order
|
||||
WHERE user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<!-- 创建订单 -->
|
||||
<insert id="insertOrder" parameterType="com.cxyxiaomo.epp.common.pojo.Order" useGeneratedKeys="true" keyProperty="orderId">
|
||||
INSERT INTO `order` (id, user_id, order_date, order_status) VALUES
|
||||
(#{id}, #{userId}, #{orderDate,javaType=java.time.LocalDateTime,jdbcType=TIMESTAMP}, #{orderStatus})
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入订单详情 -->
|
||||
<insert id="batchInsertOrderDetail" parameterType="java.util.List">
|
||||
INSERT INTO order_detail (order_id, good_id, good_count, unit_price)
|
||||
VALUES
|
||||
<if test="list != null and list.size() > 0">
|
||||
<foreach collection="list" item="detail" separator=",">
|
||||
(#{detail.orderId}, #{detail.goodId}, #{detail.goodCount}, #{detail.unitPrice})
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="list == null or list.size() == 0">
|
||||
()
|
||||
</if>
|
||||
</insert>
|
||||
|
||||
<update id="updateOrderStatus" parameterType="com.cxyxiaomo.epp.common.pojo.Order">
|
||||
UPDATE order SET order_status=#{orderStatus} WHERE order_id=#{orderId}
|
||||
</update>
|
||||
|
||||
<!-- 根据订单 ID 删除订单信息及订单详情信息 -->
|
||||
<delete id="deleteOrderById" parameterType="java.lang.Integer">
|
||||
DELETE FROM order WHERE order_id = #{orderId};
|
||||
DELETE FROM goods_order_details WHERE order_id = #{orderId};
|
||||
</delete>
|
||||
</mapper>
|
@@ -9,5 +9,9 @@
|
||||
|
||||
<!--下划线转小驼峰-->
|
||||
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||
|
||||
<!-- 打印 SQL 日志 -->
|
||||
<!-- 设置logImpl为STDOUT_LOGGING,表示使用标准输出打印SQL日志 -->
|
||||
<setting name="logImpl" value="STDOUT_LOGGING"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
Reference in New Issue
Block a user