|
@@ -1,7 +1,65 @@
|
|
|
<?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.lovecoding.mapper.BrandMapper">
|
|
|
- <select id="getBrandLIst" resultType="com.lovecoding.pojo.Brand">
|
|
|
- SELECT id, brand_name AS brandName, company_name AS companyName, ordered, description, `status` FROM tb_brand;
|
|
|
+ <resultMap id="brand_resultmap" type="com.lovecoding.pojo.Brand">
|
|
|
+ <result property="brandName" column="brand_name" />
|
|
|
+ <result property="companyName" column="company_name" />
|
|
|
+ <result property="description" column="company_name" />
|
|
|
+ <result property="id" column="id" />
|
|
|
+ <result property="ordered" column="ordered" />
|
|
|
+ <result property="status" column="status" />
|
|
|
+ </resultMap>
|
|
|
+ <sql id="brand_column" >
|
|
|
+ id, brand_name, company_name, ordered, description, `status`
|
|
|
+ </sql>
|
|
|
+ <insert id="insertBrand" useGeneratedKeys="true" keyProperty="id" >
|
|
|
+ INSERT INTO tb_brand ( brand_name, company_name, ordered, `status` )
|
|
|
+ VALUES ( #{brandName}, #{companyName},#{ordered},#{status} );
|
|
|
+ </insert>
|
|
|
+ <insert id="insertBrands" parameterType="com.lovecoding.pojo.Brand" useGeneratedKeys="true" keyProperty="id">
|
|
|
+ INSERT INTO tb_brand ( brand_name, company_name, ordered, `status` )
|
|
|
+ VALUES ( #{brandName}, #{companyName},#{ordered},#{status} );
|
|
|
+ </insert>
|
|
|
+ <update id="updateBrand">
|
|
|
+ UPDATE tb_brand
|
|
|
+ <set>
|
|
|
+ <if test="brandName != null" >
|
|
|
+ brand_name = #{brandName},
|
|
|
+ </if>
|
|
|
+ <if test="companyName != null" >
|
|
|
+ company_name = #{companyName},
|
|
|
+ </if>
|
|
|
+ <if test="ordered != null and ordered > 0" >
|
|
|
+ ordered = #{ordered},
|
|
|
+ </if>
|
|
|
+ <if test="status != null and status > 0" >
|
|
|
+ status = #{status},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ WHERE id = #{id}
|
|
|
+ </update>
|
|
|
+ <delete id="deleteById">
|
|
|
+ DELETE FROM tb_brand WHERE id = #{id};
|
|
|
+ </delete>
|
|
|
+ <select id="getBrandLIst" resultMap="brand_resultmap" >
|
|
|
+ SELECT
|
|
|
+ <include refid="brand_column"></include>
|
|
|
+ FROM tb_brand;
|
|
|
+ </select>
|
|
|
+ <select id="getBrandByCondition" resultMap="brand_resultmap" >
|
|
|
+ SELECT
|
|
|
+ <include refid="brand_column"></include>
|
|
|
+ FROM tb_brand
|
|
|
+ <where>
|
|
|
+ <if test="brandName != null">
|
|
|
+ AND brand_name like concat( '%', #{brandName}, '%' )
|
|
|
+ </if>
|
|
|
+ <if test="companyName != null">
|
|
|
+ AND company_name like #{companyName}
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ AND status <![CDATA[<]]> #{status}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
</select>
|
|
|
</mapper>
|