<resultMap id="CustomerDa" type="com.atguigu.jxc.entity.Customer"> <result column="customer_id" property="customerId" jdbcType="INTEGER"/>
<result column="customer_name" property="customerName" jdbcType="VARCHAR"/>
<result column="contacts" property="contacts" jdbcType="VARCHAR"/>
<result column="phone_number" property="phoneNumber" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<result column="remarks" property="remarks" jdbcType="VARCHAR"/></resultMap>
增
<insert id="insertCustomer" useGeneratedKeys="true" keyProperty="customerId" parameterType="com.atguigu.jxc.entity.Customer">
insert into t_customer
(customer_name,contacts,phone_number,address,remarks)
VALUES(#{customerName},#{contacts},#{phoneNumber},#{address},#{remarks})
</insert>
删
<delete id="deleteCustomer"> delete
from t_customer
where t_customer.customer_id =#{customerId}
</delete>
改
<update id="updateCustomer" parameterType="com.atguigu.jxc.entity.Customer">
UPDATE t_customer
<set>
<if test="customerName != '' and customerName != null"> t_customer.customer_name =#{customerName},
</if>
<if test="contacts != '' and contacts != null"> t_customer.contacts =#{contacts},
</if>
<if test="phoneNumber != '' and phoneNumber != null">
t_customer.phone_number =#{phoneNumber},
</if>
<if test="address != '' and address != null"> t_customer.address =#{address},
</if>
<if test="remarks != '' and remarks != null"> t_customer.remarks =#{remarks},
</if>
</set> WHERE t_customer.customer_id =#{customerId}
</update>
查
<select id="getCustomerReturnlist" resultMap="BaseResultMap"> SELECT
t_customer_return_list.customer_return_list_id,
t_customer_return_list.return_number,
t_customer_return_list.return_date,
t_customer_return_list.amount_paid,
t_customer_return_list.amount_payable,
t_customer_return_list.state,
t_customer_return_list.customer_id,
t_customer_return_list.user_id,
t_customer_return_list.remarks,
t_user.true_name,
t_customer.customer_name
FROM
t_customer_return_list
LEFT JOIN t_user ON t_customer_return_list.user_id = t_user.user_id
LEFT JOIN t_customer ON t_customer_return_list.customer_id = t_customer.customer_id
<where>
<if test="returnNumber != null and returnNumber != ''"> AND t_customer_return_list.return_number LIKE CONCAT('%',#{returnNumber} ,'%')
</if>
<if test="customerId != null"> AND t_customer_return_list.customer_id =#{customerId}
</if>
<if test="state != null"> AND t_customer_return_list.state =#{state}
</if>
<if test="sTime != null and sTime != ''"> AND t_customer_return_list.return_date >=#{sTime}
</if>
<if test="eTime != null and eTime != ''"> AND t_customer_return_list.return_date <=#{eTime}
</if>
</where>
</select>