mapper sql语句

	<?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="crm.mapper.CustomerMapper">
	
	    <!--根据条件查询分页查用户-->
	    <select id="selectByQueryVo" resultType="crm.pojo.Customer" parameterType="crm.pojo.QueryVo">
	      select * from customer
	      <where>
	            <if test="custName != null and custName != ''  " >
	                cust_name like "%"#{custName}"%"
	            </if>
	            <if test="custSource != '' and custSource != null">
	                and cust_source = #{custSource}
	            </if>
	            <if test="custIndustry != '' and custIndustry != null">
	                and cust_industry = #{custIndustry}
	            </if>
	            <if test="custLevel != '' and custLevel != null">
	                and cust_level = #{custLevel}
	            </if>
	        </where>
	        limit #{begin},#{size}
	    </select>
	
	    <!--总条数-->
	    <select id="countByQueryVo" resultType="Integer" parameterType="crm.pojo.QueryVo">
	        select count(1) from customer
	        <where>
	            <if test="custName != null and custName != ''  " >
	                cust_name like "%"#{custName}"%"
	            </if>
	
	            <if test="custSource != null and custSource != ''">
	                and cust_source = #{custSource}
	            </if>
	
	            <if test="custIndustry != null and custIndustry != ''">
	                and cust_industry = #{custIndustry}
	            </if>
	
	            <if test="custLevel != null and custLevel != ''">
	                and cust_level = #{custLevel}
	            </if>
	        </where>
	    </select>
	    <!--根据用户id查-->
	    <select id="selectCustomerById" resultType="crm.pojo.Customer" parameterType="Integer">
	        select * from customer
	        <where>
	            cust_id = #{id}
	        </where>
	    </select>
	
	    <!--更新用户-->
	    <update id="updateCustomer" parameterType="crm.pojo.Customer">
	        update customer
	        <!--set可以去掉里面最后一句多的,-->
	        <set>
	            <if test="cust_name != null">
	                cust_name = #{cust_name},
	            </if>
	            <if test="cust_linkman != null">
	                cust_linkman = #{cust_linkman}
	            </if>
	        </set>
	        <where>
	            cust_id = #{cust_id}
	        </where>
	
	    </update>
	
	    <!--删除用户-->
	    <delete id="deleteCustomer" parameterType="Integer">
	        delete  from customer where cust_id = #{id}
	    </delete>
	</mapper>

猜你喜欢

转载自blog.csdn.net/weixin_42465206/article/details/88418746