123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?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.caimei.modules.product.dao.CmActivityDao">
- <sql id="cmActivityColumns">
- a.id AS "id",
- a.activityName AS "activityName",
- a.startTime AS "startTime",
- a.endTime AS "endTime",
- a.addTime AS "addTime",
- a.delFlag AS "delFlag"
- </sql>
- <insert id="insertProductActivity">
- INSERT INTO cm_product_activity(
- activityId,
- productId,
- actPrice,
- addTime,
- delFlag
- ) VALUES (
- #{activityId},
- #{productId},
- #{price},
- now(),
- 0
- )
- </insert>
- <delete id="deleteProduct">
- DELETE FROM cm_product_activity
- WHERE activityId = #{id}
- </delete>
- <select id="findProduct" resultType="com.caimei.modules.product.entity.Product">
- SELECT
- p.*,
- s.name AS "shopName",
- cpa.actPrice AS "activityPrice"
- FROM
- cm_product_activity cpa
- LEFT JOIN product p ON cpa.productId = p.productID
- LEFT JOIN shop s ON s.shopID = p.shopID
- WHERE
- cpa.activityId = #{id}
- and p.productCategory = 1
- AND delFlag = '0'
- </select>
- <delete id="deleteActivityProduct">
- DELETE FROM cm_product_activity
- WHERE activityId = #{activityId}
- AND productId = #{productId}
- </delete>
- <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
- SELECT
- a.*,s.name AS "shopName"
- FROM product a
- LEFT JOIN shop s on s.shopID = a.shopID
- <where>
- <if test="productID != null" >
- AND a.productID = #{productID}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE
- <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name LIKE
- <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
- </if>
- <if test="ids != null and ids.size() > 0 ">
- AND a.productID NOT IN
- <foreach collection="ids" open="(" close=")" item="id" separator=",">
- #{id}
- </foreach>
- </if>
- AND a.validFlag = 2
- and a.productCategory = 1
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by a.productID desc
- </otherwise>
- </choose>
- </select>
- <select id="findActivityId" resultType="integer">
- SELECT productId FROM cm_product_activity WHERE delFlag='0'
- </select>
- </mapper>
|