123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?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.brand.dao.BrandPurchaserDao">
- <sql id="brandPurchaserColumns">
- a.id AS "id",
- a.name AS "name",
- a.purchase_date AS "purchaseDate",
- a.intro AS "intro",
- a.publicty_material_images AS "publictyMaterialImages",
- a.large_Images AS "largeImages",
- a.enabled_status AS "enabledStatus",
- a.create_by AS "createBy.id",
- a.create_date AS "createDate",
- a.update_by AS "updateBy.id",
- a.update_date AS "updateDate"
- </sql>
- <sql id="brandPurchaserColumnsWithProductCount">
- a.id AS "id",
- a.name AS "name",
- a.purchase_date AS "purchaseDate",
- a.intro AS "intro",
- a.publicty_material_images AS "publictyMaterialImages",
- a.large_Images AS "largeImages",
- a.enabled_status AS "enabledStatus",
- a.create_by AS "createBy.id",
- a.create_date AS "createDate",
- a.update_by AS "updateBy.id",
- a.update_date AS "updateDate",
- COUNT(b.id) AS "productTotalCount",
- COUNT(DISTINCT c.productID) AS "productTypeCount"
- </sql>
- <sql id="brandPurchaserJoins">
- </sql>
- <sql id="brandPurchaserJoinsWithProductCount">
- LEFT JOIN brand_product b ON a.id = b.purchaser_id
- LEFT JOIN product c ON b.productID = c.productID
- </sql>
- <select id="get" resultType="BrandPurchaser">
- SELECT
- <include refid="brandPurchaserColumns"/>
- FROM brand_purchaser a
- <include refid="brandPurchaserJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="findList" resultType="BrandPurchaser">
- SELECT
- <include refid="brandPurchaserColumnsWithProductCount"/>
- FROM brand_purchaser a
- <include refid="brandPurchaserJoinsWithProductCount"/>
- <where>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE concat('%',#{name},'%')
- </if>
- <if test="enabledStatus != null and enabledStatus != ''">
- AND a.enabled_status = #{enabledStatus}
- </if>
- and c.productCategory = 1
- </where>
- GROUP BY a.id
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.enabled_status DESC,a.update_date DESC
- </otherwise>
- </choose>
- </select>
- <select id="findAllList" resultType="BrandPurchaser">
- SELECT
- <include refid="brandPurchaserColumns"/>
- FROM brand_purchaser a
- <include refid="brandPurchaserJoins"/>
- <where>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.update_date DESC
- </otherwise>
- </choose>
- </select>
- <insert id="insert" parameterType="BrandPurchaser" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO brand_purchaser(
- name,
- purchase_date,
- intro,
- publicty_material_images,
- large_Images,
- enabled_status,
- create_by,
- create_date,
- update_by,
- update_date
- ) VALUES (
- #{name},
- #{purchaseDate},
- #{intro},
- #{publictyMaterialImages},
- #{largeImages},
- #{enabledStatus},
- #{createBy.id},
- #{createDate},
- #{updateBy.id},
- #{updateDate}
- )
- </insert>
- <update id="update">
- UPDATE brand_purchaser SET
- name = #{name},
- purchase_date = #{purchaseDate},
- intro = #{intro},
- publicty_material_images = #{publictyMaterialImages},
- large_Images = #{largeImages},
- enabled_status = #{enabledStatus},
- update_by = #{updateBy.id},
- update_date = #{updateDate}
- WHERE id = #{id}
- </update>
- <delete id="delete">
- DELETE FROM brand_purchaser
- WHERE id = #{id}
- </delete>
- <update id="changeStatus" parameterType="Map">
- UPDATE brand_purchaser SET
- enabled_status = #{enabledStatus}
- WHERE id = #{id}
- </update>
- </mapper>
|