123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?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.kmall.admin.dao.FootprintDao">
- <!-- 可根据自己的需求,是否要使用 -->
- <resultMap type="com.kmall.admin.entity.FootprintEntity" id="footprintMap">
- <result property="id" column="id"/>
- <result property="userId" column="user_id"/>
- <result property="userName" column="user_name"/>
- <result property="goodsId" column="goods_id"/>
- <result property="goodsName" column="goods_name"/>
- <result property="addTime" column="add_time"/>
- </resultMap>
- <select id="queryObject" resultType="com.kmall.admin.entity.FootprintEntity">
- select * from mall_footprint where id = #{value}
- </select>
- <select id="queryList" resultMap="footprintMap">
- SELECT DISTINCT
- a.*,
- b.nickname AS user_name,
- c.NAME AS goods_name
- FROM
- mall_product_store_rela r
- INNER JOIN mall_footprint a ON r.goods_id = a.goods_id
- INNER JOIN mall_store s ON r.store_id = s.id
- INNER JOIN mall_goods c ON r.goods_id = c.id
- INNER JOIN mall_merch_user d ON r.store_id = d.store_id
- AND r.merch_sn = d.merch_sn
- INNER JOIN mall_user b ON a.user_id = b.id
- AND d.user_id = b.id
- WHERE 1=1
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
- AND s.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- <if test="storeId != null">
- and r.store_id = #{storeId}
- </if>
- <if test="merchSn != null and merchSn.trim() != ''">
- and c.merch_sn = #{merchSn}
- </if>
- <if test="userName != null and userName != ''">
- AND b.username LIKE concat('%',#{userName},'%')
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- <otherwise>
- order by a.id desc
- </otherwise>
- </choose>
- <if test="offset != null and limit != null">
- limit #{offset}, #{limit}
- </if>
- </select>
- <select id="queryTotal" resultType="int">
- select count(distinct a.id) FROM
- mall_product_store_rela r
- INNER JOIN mall_footprint a ON r.goods_id = a.goods_id
- INNER JOIN mall_store s ON r.store_id = s.id
- INNER JOIN mall_goods c ON r.goods_id = c.id
- INNER JOIN mall_merch_user d ON r.store_id = d.store_id
- AND r.merch_sn = d.merch_sn
- INNER JOIN mall_user b ON a.user_id = b.id
- AND d.user_id = b.id
- WHERE 1=1
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
- AND s.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- <if test="storeId != null">
- and r.store_id = #{storeId}
- </if>
- <if test="merchSn != null and merchSn.trim() != ''">
- and c.merch_sn = #{merchSn}
- </if>
- <if test="name != null and name != ''">
- AND b.username LIKE concat('%',#{name},'%')
- </if>
- </select>
- <insert id="save" parameterType="com.kmall.admin.entity.FootprintEntity" useGeneratedKeys="true" keyProperty="id">
- insert into mall_footprint
- (
- `user_id`,
- `goods_id`,
- `add_time`
- )
- values
- (
- #{userId},
- #{goodsId},
- #{addTime}
- )
- </insert>
- <update id="update" parameterType="com.kmall.admin.entity.FootprintEntity">
- update mall_footprint
- <set>
- <if test="userId != null">`user_id` = #{userId},</if>
- <if test="goodsId != null">`goods_id` = #{goodsId},</if>
- <if test="addTime != null">`add_time` = #{addTime}</if>
- </set>
- where id = #{id}
- </update>
- <delete id="delete">
- delete from mall_footprint where id = #{value}
- </delete>
- <delete id="deleteBatch">
- delete from mall_footprint where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|