123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?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.AttributeDao">
- <resultMap type="com.kmall.admin.entity.AttributeEntity" id="attributeMap">
- <result property="id" column="id"/>
- <result property="attributeCategoryId" column="attribute_category_id"/>
- <result property="name" column="name"/>
- <result property="storeId" column="store_id"/>
- <result property="merchSn" column="merch_sn"/>
- <result property="inputType" column="input_type"/>
- <result property="value" column="value"/>
- <result property="sortOrder" column="sort_order"/>
- <result property="storeName" column="storeName"/>
- <result column="merchName" property="merchName" />
- </resultMap>
- <select id="queryObject" resultType="com.kmall.admin.entity.AttributeEntity">
- select
- id,
- attribute_category_id,
- name,
- store_id,
- merch_sn,
- input_type,
- value,
- sort_order
- from mall_attribute
- where id = #{id}
- </select>
- <select id="queryList" resultType="com.kmall.admin.entity.AttributeEntity">
- SELECT
- a.id,
- a.attribute_category_id,
- a.NAME,
- a.store_id,
- a.merch_sn,
- a.input_type,
- a.VALUE,
- a.sort_order,
- c.NAME category_name,
- s.store_name storeName,
- m.merch_name merchName
- FROM mall_attribute a
- LEFT JOIN mall_category c ON a.attribute_category_id = c.id
- left join mall_store s on a.store_id = s.id
- left join mall_merch m on a.merch_sn = m.merch_sn
- WHERE 1=1
- <if test="storeId != null and storeId != ''">
- AND a.store_id = #{storeId}
- </if>
- <if test="merchSn != null and merchSn.trim() != ''">
- AND a.merch_sn = #{merchSn}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
- AND s.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- <if test="name != null and name.trim() != ''">
- AND a.name LIKE concat('%', #{name},'%')
- </if>
- <if test="categoryName != null and categoryName.trim() != ''">
- AND c.name LIKE concat('%', #{categoryName},'%')
- </if>
- <if test="attributeCategoryId != null and attributeCategoryId.trim() != ''">
- AND a.attribute_category_id = #{attributeCategoryId}
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- <otherwise>
- order by a.attribute_category_id desc
- </otherwise>
- </choose>
- <if test="offset != null and limit != null">
- limit #{offset}, #{limit}
- </if>
- </select>
- <select id="queryTotal" resultType="int">
- select count(*) from mall_attribute a
- LEFT JOIN mall_category c ON a.attribute_category_id = c.id
- left join mall_store s on a.store_id = s.id
- WHERE 1=1
- <if test="storeId != null and storeId != ''">
- AND a.store_id = #{storeId}
- </if>
- <if test="merchSn != null and merchSn.trim() != ''">
- AND a.merch_sn = #{merchSn}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
- AND s.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- <if test="name != null and name.trim() != ''">
- AND a.name LIKE concat('%', #{name},'%')
- </if>
- <if test="categoryName != null and categoryName.trim() != ''">
- AND c.name LIKE concat('%', #{categoryName},'%')
- </if>
- <if test="attributeCategoryId != null and attributeCategoryId.trim() != ''">
- AND a.attribute_category_id = #{attributeCategoryId}
- </if>
- </select>
- <insert id="save" parameterType="com.kmall.admin.entity.AttributeEntity" useGeneratedKeys="true" keyProperty="id">
- insert into mall_attribute(
- `attribute_category_id`,
- `name`,
- `store_id`,
- `merch_sn`,
- `input_type`,
- `value`,
- `sort_order`)
- values(
- #{attributeCategoryId},
- #{name},
- #{storeId},
- #{merchSn},
- #{inputType},
- #{value},
- #{sortOrder})
- </insert>
- <update id="update" parameterType="com.kmall.admin.entity.AttributeEntity">
- update mall_attribute
- <set>
- <if test="attributeCategoryId != null">`attribute_category_id` = #{attributeCategoryId},</if>
- <if test="name != null">`name` = #{name},</if>
- <if test="storeId != null">`store_id` = #{storeId}, </if>
- <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
- <if test="inputType != null">`input_type` = #{inputType},</if>
- <if test="value != null">`value` = #{value},</if>
- <if test="sortOrder != null">`sort_order` = #{sortOrder}</if>
- </set>
- where id = #{id}
- </update>
- <delete id="delete">
- delete from mall_attribute where id = #{value}
- </delete>
- <delete id="deleteBatch">
- delete from mall_attribute where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|