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.CmHeheDiscountDao">
-
- <sql id="cmHeheDiscountColumns">
- a.id AS "id",
- a.title AS "title",
- a.discount AS "discount",
- a.status AS "status",
- a.productType AS "productType",
- a.addTime AS "addTime"
- </sql>
-
- <sql id="cmHeheDiscountJoins">
- </sql>
-
- <select id="get" resultType="CmHeheDiscount">
- SELECT
- <include refid="cmHeheDiscountColumns"/>
- FROM cm_hehe_discount a
- <include refid="cmHeheDiscountJoins"/>
- WHERE a.id = #{id}
- </select>
-
- <select id="findList" resultType="CmHeheDiscount">
- SELECT
- <include refid="cmHeheDiscountColumns"/>
- FROM cm_hehe_discount a
- <include refid="cmHeheDiscountJoins"/>
- <where>
-
- <if test="title != null and title != ''">
- AND a.title LIKE
- <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
- </if>
- <if test="status != null and status != ''">
- AND a.status = #{status}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by addTime desc
- </otherwise>
- </choose>
- </select>
-
- <select id="findAllList" resultType="CmHeheDiscount">
- SELECT
- <include refid="cmHeheDiscountColumns"/>
- FROM cm_hehe_discount a
- <include refid="cmHeheDiscountJoins"/>
- <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="CmHeheDiscount" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_hehe_discount(
- title,
- discount,
- status,
- productType,
- addTime
- ) VALUES (
- #{title},
- #{discount},
- #{status},
- #{productType},
- NOW()
- )
- </insert>
-
- <update id="update">
- UPDATE cm_hehe_discount SET
- title = #{title},
- discount = #{discount},
- status = #{status},
- productType = #{productType}
- WHERE id = #{id}
- </update>
- <update id="updateStatus">
- update cm_hehe_discount
- set status = #{status}
- where id = #{id}
- </update>
- <delete id="delete">
- DELETE FROM cm_hehe_discount
- WHERE id = #{id}
- </delete>
- <select id="findDiscountProductIds" resultType="java.lang.Integer">
- SELECT id FROM cm_hehe_discount_product WHERE discountId = #{discountId}
- </select>
- <select id="findDiscountUserIds" resultType="java.lang.Integer">
- SELECT id FROM cm_hehe_discount_user where discountId = #{discountId}
- </select>
- <insert id="insertDiscountProduct">
- INSERT INTO `cm_hehe_discount_product` (
- `discountId`, `productId`, discountPrice, `status`,
- `sort`, `addTime`
- )
- VALUES
- (
- #{discountId}, #{productId}, #{discountPrice}, #{status},
- #{sort}, #{addTime}
- )
- </insert>
- <insert id="insertDiscountUser">
- insert into cm_hehe_discount_user (discountId, userId, addTime) values (#{discountId}, #{userId}, #{addTime})
- </insert>
- <update id="updateDiscountProduct">
- UPDATE
- `cm_hehe_discount_product`
- <set>
- <if test="status != null">
- `status` = #{status},
- </if>
- <if test="sort != null">
- `sort` = #{sort},
- </if>
- discountPrice = #{discountPrice}
- </set>
- WHERE
- `id` = #{id}
- </update>
- <delete id="deleteDiscountProduct">
- delete from cm_hehe_discount_product where id = #{id}
- </delete>
- <delete id="deleteDiscountUser">
- delete from cm_hehe_discount_user where id = #{id}
- </delete>
- <delete id="deleteUserByDiscountId">
- delete from cm_hehe_discount_user where discountId = #{id}
- </delete>
- <select id="findDiscountProductList" resultType="com.caimei.modules.hehe.entity.CmHeheDiscountProduct">
- SELECT
- cca.id,
- cca.discountId,
- cca.productId,
- cca.discountPrice,
- cca.status,
- cca.sort,
- cca.addTime,
- s.name AS shopName,
- p.name AS productName,
- p.mainImage AS image
- FROM
- cm_hehe_discount_product cca
- left join cm_hehe_product chp on cca.productId = chp.productId
- LEFT JOIN product p ON chp.productId = p.productID
- LEFT JOIN shop s ON p.shopID = s.shopID
- WHERE
- cca.discountId = #{discountId}
- ORDER BY
- - cca.sort DESC
- </select>
- <select id="findDiscountUserList" resultType="com.caimei.modules.hehe.entity.CmHeheDiscountUser">
- select chu.id, chu.userId, chu.discountId, chu.addTime, u.nickName, u.mobile, u.userIdentity
- from cm_hehe_discount_user chu
- left join cm_hehe_user u on chu.userId = u.userId
- where chu.discountId = #{id}
- order by chu.addTime desc
- </select>
- <select id="findAllUserIds" resultType="java.lang.String">
- select group_concat(userId) from cm_hehe_discount_user;
- </select>
- </mapper>
|