123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <?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.hehe.dao.CmHeheProductDao">
-
- <sql id="cmHeheProductColumns">
- a.id AS "id",
- a.productId AS "productId",
- a.sort AS "sort",
- a.recommend AS "recommend",
- a.validFlag AS "validFlag",
- a.price AS "price",
- a.includedTax AS "includedTax",
- a.invoiceType AS "invoiceType",
- a.clubTaxPoint AS "clubTaxPoint",
- a.shopTaxPoint AS "shopTaxPoint",
- p.costCheckFlag AS "costType",
- p.costPrice AS "costPrice",
- p.costProportional AS "costProportional",
- a.addTime AS "addTime",
- p.name AS "name",
- p.mainImage AS "mainImage",
- s.name AS "shopName"
- </sql>
-
- <sql id="cmHeheProductJoins">
- LEFT JOIN product p ON a.productId = p.productID
- LEFT JOIN shop s ON s.shopID = p.shopID
- </sql>
-
- <select id="get" resultType="CmHeheProduct">
- SELECT
- <include refid="cmHeheProductColumns"/>
- FROM cm_hehe_product a
- <include refid="cmHeheProductJoins"/>
- WHERE a.id = #{id}
- </select>
-
- <select id="findList" resultType="CmHeheProduct">
- SELECT
- <include refid="cmHeheProductColumns"/>
- FROM cm_hehe_product a
- <include refid="cmHeheProductJoins"/>
- <where>
- <if test="productId != null and productId != ''">
- AND a.productId = #{productId}
- </if>
- <if test="validFlag != null and validFlag != ''">
- AND a.validFlag = #{validFlag}
- </if>
- <if test="includedTax != null and includedTax != ''">
- AND a.includedTax = #{includedTax}
- </if>
- <if test="invoiceType != null and invoiceType != ''">
- AND a.invoiceType = #{invoiceType}
- </if>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- <if test="name != null and name != ''">
- AND p.name LIKE CONCAT('%',#{name},'%')
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.shopName LIKE CONCAT('%',#{shopName},'%')
- </if>
- <if test="recommend != null and recommend != ''">
- AND a.recommend = #{recommend}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY -sort DESC
- </otherwise>
- </choose>
- </select>
-
- <select id="findAllList" resultType="CmHeheProduct">
- SELECT
- <include refid="cmHeheProductColumns"/>
- FROM cm_hehe_product a
- <include refid="cmHeheProductJoins"/>
- <where>
-
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
-
- <insert id="insert" parameterType="CmHeheProduct" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_hehe_product(
- productId,
- sort,
- recommend,
- validFlag,
- price,
- includedTax,
- invoiceType,
- clubTaxPoint,
- shopTaxPoint,
- addTime
- ) VALUES (
- #{productId},
- #{sort},
- #{recommend},
- #{validFlag},
- #{price},
- #{includedTax},
- #{invoiceType},
- #{clubTaxPoint},
- #{shopTaxPoint},
- NOW()
- )
- </insert>
-
- <update id="update">
- UPDATE cm_hehe_product SET
- productId = #{productId},
- sort = #{sort},
- recommend = #{recommend},
- validFlag = #{validFlag},
- price = #{price},
- includedTax = #{includedTax},
- invoiceType = #{invoiceType},
- clubTaxPoint = #{clubTaxPoint},
- shopTaxPoint = #{shopTaxPoint}
- WHERE id = #{id}
- </update>
-
- <delete id="delete">
- DELETE FROM cm_hehe_product
- WHERE id = #{id}
- </delete>
- <select id="findHeHeProductId" resultType="integer">
- SELECT productId FROM cm_hehe_product
- </select>
- <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 concat('%',#{name},'%')
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name LIKE concat('%',#{shopName},'%')
- </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>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by a.productID
- </otherwise>
- </choose>
- </select>
- <update id="saveSort">
- UPDATE cm_hehe_product SET sort = #{sort} WHERE id = #{id}
- </update>
-
- <update id="deleteActivityProduct">
- UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE productId = #{productId}
- </update>
-
- </mapper>
|