<?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.panzhihua.service_community.dao.McsProductDAO">
|
|
<resultMap type="com.panzhihua.service_community.entity.McsProduct" id="McsProductMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="image" column="image" jdbcType="VARCHAR"/>
|
<result property="introduction" column="introduction" jdbcType="VARCHAR"/>
|
<result property="viewNum" column="view_num" jdbcType="INTEGER"/>
|
<result property="status" column="status" jdbcType="INTEGER"/>
|
<result property="isDel" column="is_del" jdbcType="VARCHAR"/>
|
<result property="merchantId" column="merchant_id" jdbcType="INTEGER"/>
|
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
<result property="createdBy" column="created_by" jdbcType="INTEGER"/>
|
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
<result property="updatedBy" column="updated_by" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<!-- 批量插入 -->
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.mcs_product(name, image, introduction, view_num, status, is_del, merchant_id, created_at,
|
created_by, updated_at, updated_by)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.name}, #{entity.image}, #{entity.introduction}, #{entity.viewNum}, #{entity.status},
|
#{entity.isDel}, #{entity.merchantId}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt},
|
#{entity.updatedBy})
|
</foreach>
|
</insert>
|
<!-- 批量插入或按主键更新 -->
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.mcs_product(name, image, introduction, view_num, status, is_del, merchant_id, created_at,
|
created_by, updated_at, updated_by)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.name}, #{entity.image}, #{entity.introduction}, #{entity.viewNum}, #{entity.status},
|
#{entity.isDel}, #{entity.merchantId}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt},
|
#{entity.updatedBy})
|
</foreach>
|
on duplicate key update
|
name = values(name) , image = values(image) , introduction = values(introduction) , view_num = values(view_num)
|
, status = values(status) , is_del = values(is_del) , merchant_id = values(merchant_id) , created_at =
|
values(created_at) , created_by = values(created_by) , updated_at = values(updated_at) , updated_by =
|
values(updated_by)
|
</insert>
|
<select id="pageMcsProduct"
|
resultType="com.panzhihua.common.model.vos.community.microCommercialStreet.McsProductVO">
|
SELECT t1.id, t1.`name`, t1.image, t1.view_num, t1.`status`, t1.introduction, t3.productLabel
|
FROM mcs_product t1
|
LEFT JOIN mcs_merchant t2 ON t1.merchant_id = t2.id
|
LEFT JOIN (SELECT product_id, GROUP_CONCAT(label_name) AS productLabel FROM mcs_product_label GROUP BY product_id) t3 ON t1.id = t3.product_id
|
WHERE t1.is_del = 0 AND t2.is_del = 0
|
<if test="pageMcsProductDTO.merchantId != null">
|
AND t1.merchant_id = #{pageMcsProductDTO.merchantId}
|
AND t1.status = 1
|
</if>
|
<if test="pageMcsProductDTO.merchantId == null">
|
AND t2.user_id = #{pageMcsProductDTO.userId}
|
</if>
|
<if test="pageMcsProductDTO.status != null">
|
AND t1.`status` = #{pageMcsProductDTO.status}
|
</if>
|
<if test="pageMcsProductDTO.keyword != null and pageMcsProductDTO.keyword != """>
|
AND t1.`name` LIKE CONCAT(#{pageMcsProductDTO.keyword}, '%')
|
</if>
|
ORDER BY t1.created_at DESC
|
</select>
|
|
</mapper>
|