17 lines
946 B
XML
17 lines
946 B
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.zioinfo.mall.wishlist.mapper.WishlistMapper">
|
|
<select id="findByOwner" resultType="java.util.Map">
|
|
SELECT w.id, w.product_id AS "productId", p.name, p.thumbnail,
|
|
COALESCE(p.sale_price, p.price) AS price, p.status
|
|
FROM mall_wishlist w JOIN mall_product p ON p.id = w.product_id
|
|
WHERE w.owner = #{owner} ORDER BY w.id DESC
|
|
</select>
|
|
<insert id="add">
|
|
INSERT INTO mall_wishlist (owner, product_id) VALUES (#{owner}, #{productId})
|
|
ON CONFLICT (owner, product_id) DO NOTHING
|
|
</insert>
|
|
<delete id="remove">DELETE FROM mall_wishlist WHERE owner = #{owner} AND product_id = #{productId}</delete>
|
|
<select id="exists" resultType="int">SELECT COUNT(*) FROM mall_wishlist WHERE owner = #{owner} AND product_id = #{productId}</select>
|
|
</mapper>
|