123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?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.CmHeheFloorProductDao">
-
- <sql id="cmHeheFloorProductColumns">
- a.id AS "id",
- a.floorId,
- a.productId,
- a.validFlag,
- a.recommend,
- a.sort AS "sort",
- a.addTime,
- p.mainImage,
- p.name as productName,
- s.name as shopName
- </sql>
-
- <sql id="cmHeheFloorProductJoins">
- left join cm_hehe_product cp on a.productId = cp.id
- left join cm_hehe_floor cf on a.floorId = cf.id
- left join product p on cp.productId = p.productID
- left join shop s on p.shopID = s.shopID
- </sql>
- <update id="updateSort">
- update cm_hehe_floor_product set sort = #{sort} where id = #{id}
- </update>
- <select id="get" resultType="cmHeheFloorProduct">
- SELECT
- <include refid="cmHeheFloorProductColumns"/>
- FROM cm_hehe_floor_product a
- <include refid="cmHeheFloorProductJoins"/>
- WHERE a.id = #{id}
- </select>
-
- <select id="findList" resultType="cmHeheFloorProduct">
- SELECT
- <include refid="cmHeheFloorProductColumns"/>
- FROM cm_hehe_floor_product a
- <include refid="cmHeheFloorProductJoins"/>
- <where>
- a.floorId = #{floorId}
- <if test="productId != null">
- and cp.id = #{productId}
- </if>
- <if test="productName != null and productName != ''">
- and p.name like concat('%',#{productName},'%')
- </if>
- <if test="shopName != null and shopName != ''">
- and s.name like concat('%',#{shopName},'%')
- </if>
- <if test="validFlag != null">
- and a.validFlag = #{validFlag}
- </if>
- <if test="recommend != null">
- 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 a.sort asc,a.addTime desc,a.productId desc
- </otherwise>
- </choose>
- </select>
-
- <select id="findAllList" resultType="cmHeheFloorProduct">
- SELECT
- <include refid="cmHeheFloorProductColumns"/>
- FROM cm_hehe_floor_product a
- <include refid="cmHeheFloorProductJoins"/>
- <where>
-
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findFloorProductId" resultType="java.lang.Integer">
- select productId from cm_hehe_floor_product where floorId = #{floorId}
- </select>
- <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
- select hp.id as productID,p.mainImage,p.name,s.name as shopName
- from cm_hehe_product hp left join product p on hp.productId = p.productID
- left join shop s on p.shopID = s.shopID
- <where>
- hp.validFlag = 1
- <if test="productID != null" >
- AND hp.id = #{productID}
- </if>
- <if test="name != null and name != ''">
- AND p.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 hp.id 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 hp.id
- </otherwise>
- </choose>
- </select>
- <insert id="insert" parameterType="cmHeheFloorProduct" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_hehe_floor_product(
- floorId, productId, validFlag, recommend, sort, addTime
- ) VALUES (
- #{floorId},
- #{productId},
- #{validFlag},
- #{recommend},
- #{sort},
- #{addTime}
- )
- </insert>
- <update id="update" parameterType="cmHeheFloorProduct">
- update cm_hehe_floor_product set validFlag = #{validFlag},recommend = #{recommend},sort = #{sort}
- where id = #{id}
- </update>
- <!-- <update id="updateStatusByFloorId">-->
- <!-- update cm_hehe_floor_product set status = #{status} where id = #{floorId}-->
- <!-- </update>-->
- <!-- -->
- <!-- <update id="saveSort">-->
- <!-- update cm_hehe_floor_product set sort = #{sort} where id = #{floorId}-->
- <!-- </update>-->
- <delete id="delete">
- DELETE FROM cm_hehe_floor_product
- WHERE id = #{id}
- </delete>
-
- </mapper>
|