guoyuji
2024-04-16 6d6e2c77e34e7dbae4fba340c423eaafc2b9c231
north-glass-erp/src/main/resources/mapper/sd/Customer.xml
@@ -2,10 +2,93 @@
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.erp.mapper.sd.CustomerMapper">
    <select id="getCustomerList">
        select
            *
        from
            customer
            sd.customer
    </select>
    <select id="getSelectCustomer">
        select
            *
        from
            sd.customer c
        <where>
            <if test="customer.id != null and customer.id != ''">
                and c.id regexp #{customer.id}
            </if>
            <if test="customer.customerName != null and customer.customerName != ''">
                and c.customer_name regexp #{customer.customerName}
            </if>
            <if test="customer.grade != null and customer.grade != ''">
                and c.grade regexp #{customer.grade}
            </if>
            <if test="customer.moneyLimit != null and customer.moneyLimit != ''">
                and c.money_limit regexp REGEXP_REPLACE(#{customer.moneyLimit},'\\.0+$','')
            </if>
            <if test="customer.address != null and customer.address != ''">
                and c.address regexp #{customer.address}
            </if>
            <if test="customer.contact != null and customer.contact != ''">
                and c.contact regexp #{customer.contact}
            </if>
            <if test="customer.phone != null and customer.phone != ''">
                and c.phone regexp #{customer.phone}
            </if>
        </where>
        limit #{offset},#{pageSize};
    </select>
    <select id="getSelectCustomerPageTotal">
        select
            CEILING(count(id)/#{pageSize}) as 'pageTotal',
            count(id) as 'total'
        from
            sd.customer c
        <where>
            <if test="customer.id != null and customer.id != ''">
                and c.id regexp #{customer.id}
            </if>
            <if test="customer.customerName != null and customer.customerName != ''">
                and c.customer_name regexp #{customer.customerName}
            </if>
            <if test="customer.grade != null and customer.grade != ''">
                and c.grade regexp #{customer.grade}
            </if>
            <if test="customer.moneyLimit != null and customer.moneyLimit != ''">
                and c.money_limit regexp REGEXP_REPLACE(#{customer.moneyLimit},'\\.0+$','')
            </if>
            <if test="customer.address != null and customer.address != ''">
                and c.address regexp #{customer.address}
            </if>
            <if test="customer.contact != null and customer.contact != ''">
                and c.contact regexp #{customer.contact}
            </if>
            <if test="customer.phone != null and customer.phone != ''">
                and c.phone regexp #{customer.phone}
            </if>
        </where>
        limit #{offset},#{pageSize};
    </select>
    <insert id="insertCustomer"  useGeneratedKeys="true" >
        insert into sd.customer(customer_name,grade,money_limit,address,contact,phone)
        values (
                   #{customer.customerName},#{customer.grade},#{customer.moneyLimit},
                #{customer.address},#{customer.contact},#{customer.phone}
               )
    </insert>
    <update id="updateCustomer"  useGeneratedKeys="true" >
        update sd.customer set customer_name=#{customer.customerName},grade=#{customer.grade},
                                    money_limit=#{customer.moneyLimit},address= #{customer.address},
                                    contact=#{customer.contact},phone=#{customer.phone} where id=#{customer.id}
    </update>
    <delete id="deleteCustomer" >
        delete from sd.customer  where id=#{customer.id}
    </delete>
</mapper>