CustomerMapper.xml 3.37 KB
Newer Older
张新旗 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
<?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.ruoyi.system.mapper.CustomerMapper">
    
    <resultMap type="Customer" id="CustomerResult">
        <result property="id"    column="id"    />
        <result property="userName"    column="user_name"    />
        <result property="phone"    column="phone"    />
        <result property="createTime"    column="create_time"    />
        <result property="headSculpturePath"    column="head_sculpture_path"    />
        <result property="soucre"    column="soucre"    />
    </resultMap>

    <sql id="selectCustomerVo">
        select id, user_name, phone, create_time, head_sculpture_path, soucre from customer
    </sql>

    <select id="selectCustomerList" parameterType="Customer" resultMap="CustomerResult">
        <include refid="selectCustomerVo"/>
        <where>  
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="headSculpturePath != null  and headSculpturePath != ''"> and head_sculpture_path = #{headSculpturePath}</if>
            <if test="soucre != null  and soucre != ''"> and soucre = #{soucre}</if>
        </where>
    </select>
    
30
    <select id="selectCustomerById"  resultMap="CustomerResult">
张新旗 committed
31 32 33 34 35 36 37
        <include refid="selectCustomerVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCustomer" parameterType="Customer" useGeneratedKeys="true" keyProperty="id">
        insert into customer
        <trim prefix="(" suffix=")" suffixOverrides=",">
38
            <if test="id != null">id,</if>
张新旗 committed
39 40 41 42 43 44 45
            <if test="userName != null">user_name,</if>
            <if test="phone != null">phone,</if>
            <if test="createTime != null">create_time,</if>
            <if test="headSculpturePath != null">head_sculpture_path,</if>
            <if test="soucre != null">soucre,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
46
            <if test="id != null">#{id},</if>
张新旗 committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
            <if test="userName != null">#{userName},</if>
            <if test="phone != null">#{phone},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="headSculpturePath != null">#{headSculpturePath},</if>
            <if test="soucre != null">#{soucre},</if>
         </trim>
    </insert>

    <update id="updateCustomer" parameterType="Customer">
        update customer
        <trim prefix="SET" suffixOverrides=",">
            <if test="userName != null">user_name = #{userName},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="headSculpturePath != null">head_sculpture_path = #{headSculpturePath},</if>
            <if test="soucre != null">soucre = #{soucre},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCustomerById" parameterType="Long">
        delete from customer where id = #{id}
    </delete>

    <delete id="deleteCustomerByIds" parameterType="String">
        delete from customer where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>