You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.3 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.mapper.OrdersMapper">
<select id="selectAll" resultType="com.example.entity.Orders">
select orders.*, goods.name as goodsName, goods.img as goodsImg, user.name as userName from orders
left join goods on orders.goods_id = goods.id
left join user on orders.user_id = user.id
<where>
<if test="orderNo != null"> and orders.order_no like concat('%', #{orderNo}, '%')</if>
<if test="userId != null"> and orders.user_id = #{userId}</if>
</where>
order by orders.id desc
</select>
<insert id="insert" parameterType="com.example.entity.Orders" useGeneratedKeys="true">
insert into orders(id, order_no, goods_id, num, user_id, status, time)
values (#{id}, #{orderNo}, #{goodsId}, #{num}, #{userId}, #{status}, #{time})
</insert>
<update id="updateById" parameterType="com.example.entity.Orders">
update orders set order_no = #{orderNo}, goods_id = #{goodsId}, num = #{num},
user_id = #{userId}, status = #{status}, time = #{time}
where id = #{id}
</update>
</mapper>