liding
2025-05-07 3f2a477b1c3e4323e9de59fe96b75e69a1fb90d3
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?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.basic.mapper.CustomerMapper">
    
    <resultMap type="com.ruoyi.basic.pojo.Customer" id="CustomerResult">
        <result property="id"    column="id"    />
        <result property="customerName"    column="customer_name"    />
        <result property="taxpayerIdentificationNumber"    column="taxpayer_identification_number"    />
        <result property="companyAddress"    column="company_address"    />
        <result property="companyPhone"    column="company_phone"    />
        <result property="contactPerson"    column="contact_person"    />
        <result property="contactPhone"    column="contact_phone"    />
        <result property="maintainer"    column="maintainer"    />
        <result property="maintenanceTime"    column="maintenance_time"    />
    </resultMap>
 
    <sql id="selectCustomerVo">
        select id, customer_name, taxpayer_identification_number, company_address, company_phone, contact_person, contact_phone, maintainer, maintenance_time from customer
    </sql>
 
    <select id="selectCustomerList" parameterType="com.ruoyi.basic.pojo.Customer" resultMap="CustomerResult">
        <include refid="selectCustomerVo"/>
        <where>  
            <if test="customerName != null  and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
            <if test="taxpayerIdentificationNumber != null  and taxpayerIdentificationNumber != ''"> and taxpayer_identification_number = #{taxpayerIdentificationNumber}</if>
            <if test="companyAddress != null  and companyAddress != ''"> and company_address = #{companyAddress}</if>
            <if test="companyPhone != null  and companyPhone != ''"> and company_phone = #{companyPhone}</if>
            <if test="contactPerson != null  and contactPerson != ''"> and contact_person = #{contactPerson}</if>
            <if test="contactPhone != null  and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
            <if test="maintainer != null  and maintainer != ''"> and maintainer = #{maintainer}</if>
            <if test="maintenanceTime != null "> and maintenance_time = #{maintenanceTime}</if>
        </where>
    </select>
    
    <select id="selectCustomerById" parameterType="Long" resultMap="CustomerResult">
        <include refid="selectCustomerVo"/>
        where id = #{id}
    </select>
 
    <insert id="insertCustomer" parameterType="com.ruoyi.basic.pojo.Customer" useGeneratedKeys="true" keyProperty="id">
        insert into customer
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="customerName != null and customerName != ''">customer_name,</if>
            <if test="taxpayerIdentificationNumber != null and taxpayerIdentificationNumber != ''">taxpayer_identification_number,</if>
            <if test="companyAddress != null and companyAddress != ''">company_address,</if>
            <if test="companyPhone != null and companyPhone != ''">company_phone,</if>
            <if test="contactPerson != null and contactPerson != ''">contact_person,</if>
            <if test="contactPhone != null and contactPhone != ''">contact_phone,</if>
            <if test="maintainer != null and maintainer != ''">maintainer,</if>
            <if test="maintenanceTime != null">maintenance_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="customerName != null and customerName != ''">#{customerName},</if>
            <if test="taxpayerIdentificationNumber != null and taxpayerIdentificationNumber != ''">#{taxpayerIdentificationNumber},</if>
            <if test="companyAddress != null and companyAddress != ''">#{companyAddress},</if>
            <if test="companyPhone != null and companyPhone != ''">#{companyPhone},</if>
            <if test="contactPerson != null and contactPerson != ''">#{contactPerson},</if>
            <if test="contactPhone != null and contactPhone != ''">#{contactPhone},</if>
            <if test="maintainer != null and maintainer != ''">#{maintainer},</if>
            <if test="maintenanceTime != null">#{maintenanceTime},</if>
         </trim>
    </insert>
 
    <update id="updateCustomer" parameterType="com.ruoyi.basic.pojo.Customer">
        update customer
        <trim prefix="SET" suffixOverrides=",">
            <if test="customerName != null and customerName != ''">customer_name = #{customerName},</if>
            <if test="taxpayerIdentificationNumber != null and taxpayerIdentificationNumber != ''">taxpayer_identification_number = #{taxpayerIdentificationNumber},</if>
            <if test="companyAddress != null and companyAddress != ''">company_address = #{companyAddress},</if>
            <if test="companyPhone != null and companyPhone != ''">company_phone = #{companyPhone},</if>
            <if test="contactPerson != null and contactPerson != ''">contact_person = #{contactPerson},</if>
            <if test="contactPhone != null and contactPhone != ''">contact_phone = #{contactPhone},</if>
            <if test="maintainer != null and maintainer != ''">maintainer = #{maintainer},</if>
            <if test="maintenanceTime != null">maintenance_time = #{maintenanceTime},</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>