123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?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.SearchHistoryDao">
- <!-- 可根据自己的需求,是否要使用 -->
- <resultMap type="com.kmall.admin.entity.SearchHistoryEntity" id="searchHistoryMap">
- <result property="id" column="id"/>
- <result property="keyword" column="keyword"/>
- <result property="from" column="from"/>
- <result property="addTime" column="add_time"/>
- <result property="userId" column="user_id"/>
- <result property="userName" column="user_name"/>
- </resultMap>
- <select id="queryObject" resultType="com.kmall.admin.entity.SearchHistoryEntity">
- select * from mall_search_history where id = #{value}
- </select>
- <select id="queryList" resultMap="searchHistoryMap">
- select distinct a.* ,b.nickname as user_name
- from mall_search_history a
- left join mall_user b on a.user_id = b.id
- LEFT JOIN mall_merch_user d ON a.user_id=d.user_id
- left join mall_store s on d.store_id = s.id
- where 1=1
- <if test="storeId != null">
- and d.store_id = #{storeId}
- </if>
- <if test="merchSn != null and merchSn.trim() != ''">
- and d.merch_sn = #{merchSn}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
- AND s.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- <if test="keyword != null and keyword.trim() != ''">
- AND a.keyword LIKE CONCAT('%',#{keyword},'%')
- </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_search_history a
- LEFT JOIN mall_merch_user d ON a.user_id=d.user_id
- left join mall_store s on d.store_id = s.id
- where 1=1
- <if test="storeId != null">
- and d.store_id = #{storeId}
- </if>
- <if test="merchSn != null and merchSn.trim() != ''">
- and d.merch_sn = #{merchSn}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
- AND s.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- </select>
- <insert id="save" parameterType="com.kmall.admin.entity.SearchHistoryEntity" useGeneratedKeys="true" keyProperty="id">
- insert into mall_search_history
- (
- `keyword`,
- `from`,
- `add_time`,
- `user_id`
- )
- values
- (
- #{keyword},
- #{from},
- #{addTime},
- #{userId}
- )
- </insert>
- <update id="update" parameterType="com.kmall.admin.entity.SearchHistoryEntity">
- update mall_search_history
- <set>
- <if test="keyword != null">`keyword` = #{keyword},</if>
- <if test="from != null">`from` = #{from},</if>
- <if test="addTime != null">`add_time` = #{addTime},</if>
- <if test="userId != null">`user_id` = #{userId}</if>
- </set>
- where id = #{id}
- </update>
- <delete id="delete">
- delete from mall_search_history where id = #{value}
- </delete>
- <delete id="deleteBatch">
- delete from mall_search_history where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|