123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <?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.BrandSupplierDao">
- <sql id="brandSupplierColumns">
- a.id AS "id",
- a.shopid AS "shopID",
- a.logo AS "LOGO",
- a.name AS "name",
- a.business_license AS "businessLicense",
- a.business_address AS "businessAddress",
- a.business_phone AS "businessPhone",
- a.legal_representaive AS "legalRepresentaive",
- a.registered_capital AS "registeredCapital",
- a.enterprise_type AS "enterpriseType",
- a.business_scope AS "businessScope",
- 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="brandSupplierColumnsWithProductCount">
- a.id AS "id",
- a.shopid AS "shopID",
- a.logo AS "LOGO",
- a.name AS "name",
- a.business_license AS "businessLicense",
- a.business_address AS "businessAddress",
- a.business_phone AS "businessPhone",
- a.legal_representaive AS "legalRepresentaive",
- a.registered_capital AS "registeredCapital",
- a.enterprise_type AS "enterpriseType",
- a.business_scope AS "businessScope",
- 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="brandSupplierJoins">
- </sql>
- <sql id="brandSupplierJoinsWithProductCount">
- LEFT JOIN brand_product b ON a.id = b.supplier_id
- LEFT JOIN product c ON b.productID = c.productID
- </sql>
- <select id="get" resultType="BrandSupplier">
- SELECT
- <include refid="brandSupplierColumns"/>, b.name AS shopName
- FROM brand_supplier a LEFT JOIN shop b ON a.shopID = b.shopID
- <include refid="brandSupplierJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="findList" resultType="BrandSupplier">
- SELECT
- <include refid="brandSupplierColumnsWithProductCount"/>
- FROM brand_supplier a
- <include refid="brandSupplierJoinsWithProductCount"/>
- <where>
- <if test="shopID != null and shopID != ''">
- AND a.shopid = #{shopID}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE
- <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
- </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="BrandSupplier">
- SELECT
- <include refid="brandSupplierColumns"/>
- FROM brand_supplier a
- <include refid="brandSupplierJoins"/>
- <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="BrandSupplier" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO brand_supplier(
- shopid,
- logo,
- name,
- business_license,
- business_address,
- business_phone,
- legal_representaive,
- registered_capital,
- enterprise_type,
- business_scope,
- enabled_status,
- create_by,
- create_date,
- update_by,
- update_date
- ) VALUES (
- #{shopID},
- #{LOGO},
- #{name},
- #{businessLicense},
- #{businessAddress},
- #{businessPhone},
- #{legalRepresentaive},
- #{registeredCapital},
- #{enterpriseType},
- #{businessScope},
- #{enabledStatus},
- #{createBy.id},
- #{createDate},
- #{updateBy.id},
- #{updateDate}
- )
- </insert>
- <update id="update">
- UPDATE brand_supplier SET
- shopid = #{shopID},
- logo = #{LOGO},
- name = #{name},
- business_license = #{businessLicense},
- business_address = #{businessAddress},
- business_phone = #{businessPhone},
- legal_representaive = #{legalRepresentaive},
- registered_capital = #{registeredCapital},
- enterprise_type = #{enterpriseType},
- business_scope = #{businessScope},
- enabled_status = #{enabledStatus},
- update_by = #{updateBy.id},
- update_date = #{updateDate}
- WHERE id = #{id}
- </update>
- <delete id="delete">
- DELETE FROM brand_supplier
- WHERE id = #{id}
- </delete>
- <update id="changeStatus" parameterType="Map">
- UPDATE brand_supplier SET enabled_status = #{enabledStatus}
- WHERE id = #{id}
- </update>
- <update id="updateEnabledStatusByIds" parameterType="Map">
- UPDATE brand_supplier a SET a.enabled_status = #{param1}
- WHERE a.id IN
- <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
- #{id}
- </foreach>
- </update>
- </mapper>
|