多表Mapper.xml

remark:

<resultMap type="me.gacl.domain.Classes" id="ClassResultMap">
         <id property="id" column="c_id"/>
         <result property="name" column="c_name"/>

	<!-- 多对一,配置 property表示在类中定义的对象的属性名 -->
         <association property="teacher" column="teacher_id" javaType="me.gacl.domain.Teacher">
             <id property="id" column="t_id"/>
             <result property="name" column="t_name"/>
         </association>

         /* 一对多 */
         <!-- ofType指定students集合中的对象类型 -->
         <collection property="students" ofType="me.gacl.domain.Student">
             <id property="id" column="s_id"/>
             <result property="name" column="s_name"/>
         </collection>
</resultMap>

 

<?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.project.system.crmUser.mapper.CrmUserMapper">
    
    <resultMap type="CrmUser" id="CrmUserResult">
        <result property="id"    column="id"    />
        <result property="customerId"    column="customer_id"    />
        <result property="customerType"    column="customer_type"    />
        <result property="customerName"    column="customer_name"    />
        <result property="headPhoto"    column="head_photo"    />
        <result property="nationality"    column="nationality"    />
        <result property="vocation"    column="vocation"    />
        <result property="linkman"    column="linkman"    />
        <result property="tel"    column="tel"    />
        <result property="fax"    column="fax"    />
        <result property="mail"    column="mail"    />
        <result property="linkAddress"    column="link_address"    />
        <result property="addressProvince"    column="address_province"    />
        <result property="addressCity"    column="address_city"    />
        <result property="addressCounty"    column="address_county"    />
        <result property="addressStreet"    column="address_street"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="remarks"    column="remarks"    />
        <result property="createDate"    column="create_date"    />
        <result property="updateDate"    column="update_date"    />
        <result property="optPerson"    column="opt_person"    />
        <result property="customerStatus"    column="customer_status"    />
        <result property="creditRating"    column="credit_rating"    />
        <result property="tid"    column="tid"    />
    </resultMap>

    <!-- CrmDOResult resultMap -->
    <resultMap type="CrmDO" id="CrmDOResult">
        <result property="id"    column="id"    />
        <result property="customerId"    column="customer_id"    />
        <result property="customerType"    column="customer_type"    />
        <result property="customerName"    column="customer_name"    />
        <result property="headPhoto"    column="head_photo"    />
        <result property="nationality"    column="nationality"    />
        <result property="vocation"    column="vocation"    />
        <result property="linkman"    column="linkman"    />
        <result property="tel"    column="tel"    />
        <result property="fax"    column="fax"    />
        <result property="mail"    column="mail"    />
        <result property="linkAddress"    column="link_address"    />
        <result property="addressProvince"    column="address_province"    />
        <result property="addressCity"    column="address_city"    />
        <result property="addressCounty"    column="address_county"    />
        <result property="addressStreet"    column="address_street"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="remarks"    column="remarks"    />
        <result property="inboundDateOne"    column="create_date"    />
        <result property="inboundDateTwo"    column="create_date"    />
        <result property="updateDate"    column="update_date"    />
        <result property="optPerson"    column="opt_person"    />
        <result property="customerStatus"    column="customer_status"    />
        <result property="creditRating"    column="credit_rating"    />
    </resultMap>
	
	<sql id="selectCrmUserVo">
        select id, customer_id, customer_type, customer_name, head_photo, nationality, vocation, linkman, tel, fax, mail, link_address, address_province, address_city, address_county, address_street, del_flag, remarks, create_date, update_date, opt_person, customer_status, credit_rating, tid from crm_user
    </sql>
	
    <select id="selectCrmUserList" parameterType="CrmUser" resultMap="CrmUserResult">
        <include refid="selectCrmUserVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
             <if test="customerId != null  and customerId != '' "> and customer_id = #{customerId}</if>
             <if test="customerType != null  and customerType != '' "> and customer_type = #{customerType}</if>
             <if test="customerName != null  and customerName != '' "> and customer_name = #{customerName}</if>
             <if test="headPhoto != null  and headPhoto != '' "> and head_photo = #{headPhoto}</if>
             <if test="nationality != null  and nationality != '' "> and nationality = #{nationality}</if>
             <if test="vocation != null  and vocation != '' "> and vocation = #{vocation}</if>
             <if test="linkman != null  and linkman != '' "> and linkman = #{linkman}</if>
             <if test="tel != null  and tel != '' "> and tel = #{tel}</if>
             <if test="fax != null  and fax != '' "> and fax = #{fax}</if>
             <if test="mail != null  and mail != '' "> and mail = #{mail}</if>
             <if test="linkAddress != null  and linkAddress != '' "> and link_address = #{linkAddress}</if>
             <if test="addressProvince != null  and addressProvince != '' "> and address_province = #{addressProvince}</if>
             <if test="addressCity != null  and addressCity != '' "> and address_city = #{addressCity}</if>
             <if test="addressCounty != null  and addressCounty != '' "> and address_county = #{addressCounty}</if>
             <if test="addressStreet != null  and addressStreet != '' "> and address_street = #{addressStreet}</if>
             <if test="delFlag != null  and delFlag != '' "> and del_flag = #{delFlag}</if>
             <if test="remarks != null  and remarks != '' "> and remarks = #{remarks}</if>
             <if test="createDate != null "> and create_date = #{createDate}</if>
             <if test="updateDate != null "> and update_date = #{updateDate}</if>
             <if test="optPerson != null  and optPerson != '' "> and opt_person = #{optPerson}</if>
             <if test="customerStatus != null  and customerStatus != '' "> and customer_status = #{customerStatus}</if>
             <if test="creditRating != null  and creditRating != '' "> and credit_rating = #{creditRating}</if>
             <if test="tid != null  and tid != '' "> and tid = #{tid}</if>
         </where>
    </select>

    <!-- todo 修改createDate条件查询 -->
    <!-- explain select * from crm_user where create_date between DATE_FORMAT('2019-06-17', '%Y-%m-%d') and DATE_FORMAT('2019-06-19', '%Y-%m-%d'); -->
    <!-- select * from crm_user where create_date between DATE_FORMAT('2019-06-17', '%Y-%m-%d') and DATE_FORMAT('2019-06-19', '%Y-%m-%d') and customer_id='ZS-KH-20191022-001' and vocation='信息'; -->
    <select id="selectCrmUserListByCondition" parameterType="CrmDO" resultMap="CrmDOResult">
        <include refid="selectCrmUserVo"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="customerId != null  and customerId != '' "> and customer_id = #{customerId}</if>
            <if test="customerType != null  and customerType != '' "> and customer_type = #{customerType}</if>
            <if test="customerName != null  and customerName != '' "> and customer_name = #{customerName}</if>
            <if test="headPhoto != null  and headPhoto != '' "> and head_photo = #{headPhoto}</if>
            <if test="nationality != null  and nationality != '' "> and nationality = #{nationality}</if>
            <if test="vocation != null  and vocation != '' "> and vocation = #{vocation}</if>
            <if test="linkman != null  and linkman != '' "> and linkman = #{linkman}</if>
            <if test="tel != null  and tel != '' "> and tel = #{tel}</if>
            <if test="fax != null  and fax != '' "> and fax = #{fax}</if>
            <if test="mail != null  and mail != '' "> and mail = #{mail}</if>
            <if test="linkAddress != null  and linkAddress != '' "> and link_address = #{linkAddress}</if>
            <if test="addressProvince != null  and addressProvince != '' "> and address_province = #{addressProvince}</if>
            <if test="addressCity != null  and addressCity != '' "> and address_city = #{addressCity}</if>
            <if test="addressCounty != null  and addressCounty != '' "> and address_county = #{addressCounty}</if>
            <if test="addressStreet != null  and addressStreet != '' "> and address_street = #{addressStreet}</if>
            <if test="delFlag != null  and delFlag != '' "> and del_flag = #{delFlag}</if>
            <if test="remarks != null  and remarks != '' "> and remarks = #{remarks}</if>
            <if test="inboundDateOne != null and inboundDateTwo != null "> and create_date between DATE_FORMAT(#{inboundDateOne}, '%Y-%m-%d') and DATE_FORMAT(#{inboundDateTwo}, '%Y-%m-%d')</if>
            <if test="optPerson != null  and optPerson != '' "> and opt_person = #{optPerson}</if>
            <if test="customerStatus != null  and customerStatus != '' "> and customer_status = #{customerStatus}</if>
            <if test="creditRating != null  and creditRating != '' "> and credit_rating = #{creditRating}</if>
            <if test="tid != null  and tid != '' "> and tid = #{tid}</if>
        </where>
    </select>


    <!-- 三表连接 -->
    <sql id="crmColumns">
		a.id AS "id",
		a.customer_id AS "customerId",
		a.customer_type AS "customerType",
		a.customer_name AS "customerName",
		a.head_photo AS "headPhoto",
		a.nationality AS "nationality",
		a.vocation AS "vocation",
		a.linkman AS "linkman",
		a.tel AS "tel",
		a.fax AS "fax",
		a.mail AS "mail",
		a.link_address AS "linkAddress",
		a.address_province AS "addressProvince",
		a.address_city AS "addressCity",
		a.address_county AS "addressCounty",
		a.address_street AS "addressStreet",
		a.del_flag AS "delFlag",
		a.remarks AS "remarks",
		a.create_date AS "createDate",
		a.update_date AS "updateDate",
		a.opt_person AS "optPerson",
		a.customer_status AS "customerStatus",
		a.credit_rating AS "creditRating",
		a.tid AS "tid",
		a2.dict_code AS "dictData.dictCode",
		a2.dict_label AS "dictData.dictLabel",
		a3.name AS "nationData.name",
		a3.code AS "nationData.code"
	</sql>

    <sql id="crmJoins">
		left join sys_dict_data a2 on  a.vocation = a2.dict_code
		left join sys_nationality a3 on a.nationality = a3.`code`
	</sql>

    <!-- select a.*, b.*,c.* from crm_user a left join sys_dict_data b on  a.vocation = b.dict_code left join sys_nationality c on a.nationality = c.`code` -->
    <select id="getMorelist" resultType="CrmUser">
        SELECT
        <include refid="crmColumns"/>
        FROM crm_user a
        <include refid="crmJoins"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="customerId != null  and customerId != '' "> and a.customer_id = #{customerId}</if>
            <if test="customerType != null  and customerType != '' "> and a.customer_type = #{customerType}</if>
            <if test="customerName != null  and customerName != '' "> and a.customer_name = #{customerName}</if>
            <if test="headPhoto != null  and headPhoto != '' "> and a.head_photo = #{headPhoto}</if>
            <if test="nationality != null  and nationality != '' "> and a.nationality = #{nationality}</if>
            <if test="vocation != null  and vocation != '' "> and a.vocation = #{vocation}</if>
            <if test="linkman != null  and linkman != '' "> and a.linkman = #{linkman}</if>
            <if test="tel != null  and tel != '' "> and a.tel = #{tel}</if>
            <if test="fax != null  and fax != '' "> and a.fax = #{fax}</if>
            <if test="mail != null  and mail != '' "> and a.mail = #{mail}</if>
            <if test="linkAddress != null  and linkAddress != '' "> and a.link_address = #{linkAddress}</if>
            <if test="addressProvince != null  and addressProvince != '' "> and a.address_province = #{addressProvince}</if>
            <if test="addressCity != null  and addressCity != '' "> and a.address_city = #{addressCity}</if>
            <if test="addressCounty != null  and addressCounty != '' "> and a.address_county = #{addressCounty}</if>
            <if test="addressStreet != null  and addressStreet != '' "> and a.address_street = #{addressStreet}</if>
            <if test="delFlag != null  and delFlag != '' "> and a.del_flag = #{delFlag}</if>
            <if test="remarks != null  and remarks != '' "> and a.remarks = #{remarks}</if>
            <if test="inboundDateOne != null and inboundDateTwo != null "> and a.create_date between DATE_FORMAT(#{inboundDateOne}, '%Y-%m-%d') and DATE_FORMAT(#{inboundDateTwo}, '%Y-%m-%d')</if>
            <if test="optPerson != null  and optPerson != '' "> and a.opt_person = #{optPerson}</if>
            <if test="customerStatus != null  and customerStatus != '' "> and a.customer_status = #{customerStatus}</if>
            <if test="creditRating != null  and creditRating != '' "> and a.credit_rating = #{creditRating}</if>
            <if test="tid != null  and tid != '' "> and a.tid = #{tid}</if>
        </where>
    </select>



    <select id="selectCrmUserById" parameterType="Integer" resultMap="CrmUserResult">
        <include refid="selectCrmUserVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCrmUser" parameterType="CrmUser" useGeneratedKeys="true" keyProperty="id">
        insert into crm_user
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="customerId != null  and customerId != ''  ">customer_id,</if>
			<if test="customerType != null  and customerType != ''  ">customer_type,</if>
			<if test="customerName != null  and customerName != ''  ">customer_name,</if>
			<if test="headPhoto != null  and headPhoto != ''  ">head_photo,</if>
			<if test="nationality != null  and nationality != ''  ">nationality,</if>
			<if test="vocation != null  and vocation != ''  ">vocation,</if>
			<if test="linkman != null  and linkman != ''  ">linkman,</if>
			<if test="tel != null  and tel != ''  ">tel,</if>
			<if test="fax != null  and fax != ''  ">fax,</if>
			<if test="mail != null  and mail != ''  ">mail,</if>
			<if test="linkAddress != null  and linkAddress != ''  ">link_address,</if>
			<if test="addressProvince != null  and addressProvince != ''  ">address_province,</if>
			<if test="addressCity != null  and addressCity != ''  ">address_city,</if>
			<if test="addressCounty != null  and addressCounty != ''  ">address_county,</if>
			<if test="addressStreet != null  and addressStreet != ''  ">address_street,</if>
			<if test="delFlag != null  and delFlag != ''  ">del_flag,</if>
			<if test="remarks != null  and remarks != ''  ">remarks,</if>
			<if test="createDate != null  ">create_date,</if>
			<if test="updateDate != null  ">update_date,</if>
			<if test="optPerson != null  and optPerson != ''  ">opt_person,</if>
			<if test="customerStatus != null  and customerStatus != ''  ">customer_status,</if>
			<if test="creditRating != null  and creditRating != ''  ">credit_rating,</if>
			<if test="tid != null  and tid != ''  ">tid,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="customerId != null  and customerId != ''  ">#{customerId},</if>
			<if test="customerType != null  and customerType != ''  ">#{customerType},</if>
			<if test="customerName != null  and customerName != ''  ">#{customerName},</if>
			<if test="headPhoto != null  and headPhoto != ''  ">#{headPhoto},</if>
			<if test="nationality != null  and nationality != ''  ">#{nationality},</if>
			<if test="vocation != null  and vocation != ''  ">#{vocation},</if>
			<if test="linkman != null  and linkman != ''  ">#{linkman},</if>
			<if test="tel != null  and tel != ''  ">#{tel},</if>
			<if test="fax != null  and fax != ''  ">#{fax},</if>
			<if test="mail != null  and mail != ''  ">#{mail},</if>
			<if test="linkAddress != null  and linkAddress != ''  ">#{linkAddress},</if>
			<if test="addressProvince != null  and addressProvince != ''  ">#{addressProvince},</if>
			<if test="addressCity != null  and addressCity != ''  ">#{addressCity},</if>
			<if test="addressCounty != null  and addressCounty != ''  ">#{addressCounty},</if>
			<if test="addressStreet != null  and addressStreet != ''  ">#{addressStreet},</if>
			<if test="delFlag != null  and delFlag != ''  ">#{delFlag},</if>
			<if test="remarks != null  and remarks != ''  ">#{remarks},</if>
			<if test="createDate != null  ">#{createDate},</if>
			<if test="updateDate != null  ">#{updateDate},</if>
			<if test="optPerson != null  and optPerson != ''  ">#{optPerson},</if>
			<if test="customerStatus != null  and customerStatus != ''  ">#{customerStatus},</if>
			<if test="creditRating != null  and creditRating != ''  ">#{creditRating},</if>
			<if test="tid != null  and tid != ''  ">#{tid},</if>
         </trim>
    </insert>
	 
    <update id="updateCrmUser" parameterType="CrmUser">
        update crm_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="customerId != null  and customerId != ''  ">customer_id = #{customerId},</if>
            <if test="customerType != null  and customerType != ''  ">customer_type = #{customerType},</if>
            <if test="customerName != null  and customerName != ''  ">customer_name = #{customerName},</if>
            <if test="headPhoto != null  and headPhoto != ''  ">head_photo = #{headPhoto},</if>
            <if test="nationality != null  and nationality != ''  ">nationality = #{nationality},</if>
            <if test="vocation != null  and vocation != ''  ">vocation = #{vocation},</if>
            <if test="linkman != null  and linkman != ''  ">linkman = #{linkman},</if>
            <if test="tel != null  and tel != ''  ">tel = #{tel},</if>
            <if test="fax != null  and fax != ''  ">fax = #{fax},</if>
            <if test="mail != null  and mail != ''  ">mail = #{mail},</if>
            <if test="linkAddress != null  and linkAddress != ''  ">link_address = #{linkAddress},</if>
            <if test="addressProvince != null  and addressProvince != ''  ">address_province = #{addressProvince},</if>
            <if test="addressCity != null  and addressCity != ''  ">address_city = #{addressCity},</if>
            <if test="addressCounty != null  and addressCounty != ''  ">address_county = #{addressCounty},</if>
            <if test="addressStreet != null  and addressStreet != ''  ">address_street = #{addressStreet},</if>
            <if test="delFlag != null  and delFlag != ''  ">del_flag = #{delFlag},</if>
            <if test="remarks != null  and remarks != ''  ">remarks = #{remarks},</if>
            <if test="createDate != null  ">create_date = #{createDate},</if>
            <if test="updateDate != null  ">update_date = #{updateDate},</if>
            <if test="optPerson != null  and optPerson != ''  ">opt_person = #{optPerson},</if>
            <if test="customerStatus != null  and customerStatus != ''  ">customer_status = #{customerStatus},</if>
            <if test="creditRating != null  and creditRating != ''  ">credit_rating = #{creditRating},</if>
            <if test="tid != null  and tid != ''  ">tid = #{tid},</if>
        </trim>
        where id = #{id}
    </update>

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

 

<?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.jgxt.dao.takeover.DiscussMapper">
	<!--添加消息  -->
 	<insert id="addDiscuss" parameterType="com.jgxt.bean.takeover.DiscussBean">
		insert into t_discuss values(null,#{userId},#{content},#{createDate},#{repayDate},#{oneself},#{sendto})
	</insert>
	
	<!--history.jsp -->
	<resultMap type="com.jgxt.bean.takeover.DiscussBean" id="resultMapId">
		<id column="discussId" property="discussId"/>
		<result column="discussId" property="discussId"/>
		<result column="userId" property="userId"/>
		<result column="content" property="content"/>
		<result column="createDate" property="createDate"/>
		<result column="replyDate" property="repayDate"/>
		<result column="oneself" property="oneself"/>
		<result column="sendto" property="sendto"/>
		
		<!-- 多个讨论对一用户,配置 property表示在类中定义的对象的属性名 -->
  		<association property="userinfo" javaType="com.jgxt.bean.UserInfo" >
  			<id column="id" property="id" />
  			<result column="realname" property="realname" />
  			<result column="banktype_id" property="banktype_id" />
  			
  		</association>
  		
		<!-- 多个讨论对一用户,配置 property表示在类中定义的对象的属性名 -->
  		<association property="banktype" javaType="com.jgxt.bean.Banktype" >
  			<id column="id" property="id" />
  			<result column="name" property="name" />
  		</association>
	</resultMap>
	
	<!-- 降序查询讨论区历史信息 -->
	<select id="getDisList" parameterType="java.util.HashMap" resultMap="resultMapId">
		select t1.discussId,t1.userId,t1.content,t1.createDate,t1.oneself,t1.sendto from t_discuss t1 
		<where>
	   		<if test="starttime !='' and starttime !=undefined">  <!-- 日期:起始 -->
	        	 AND DATE_FORMAT(t1.createDate,'%Y-%m-%d') &gt;=#{starttime}
	    	</if>
	    	<if test="endtime !='' and endtime !=undefined">  <!-- 截止-->
	        	 AND DATE_FORMAT(t1.createDate,'%Y-%m-%d') &lt;=#{endtime}
	    	</if>
	    	<if test="context !='' and context != null">  <!-- 消息内容-->
	        	 AND t1.content like concat('%',#{context},'%')
	    	</if>
	    	<if test="isenterprise ==1">  <!-- 消息类型 -->
	        	 AND t1.oneself = #{isenterprise}
	    	</if>
		</where>
		 order by createDate desc
		 LIMIT #{start,jdbcType=INTEGER},#{count,jdbcType=INTEGER}
	</select>
	
	<!-- 查询讨论区历史信息 -->
	<select id="getDisListForAll" parameterType="java.util.HashMap" resultMap="resultMapId">
		select t1.discussId,t1.userId,t1.content,t1.createDate,t1.oneself,t1.sendto from t_discuss t1 
	</select>
	
	<!-- 首页查看更多进行滚动查看 -->
	<select id="selectNameAndContent" parameterType="java.util.HashMap" resultMap="resultMapId">
		select t1.discussId,t1.userId,t1.createDate,t1.content from t_discuss t1 
		 LIMIT #{start,jdbcType=INTEGER},#{count,jdbcType=INTEGER}
	</select>
	
	<!-- id查当天所有discuss的list -->
<!-- 	<select id="getDisList" resultMap="resultMapId">
		select t1.discussId,t1.userId,t1.content,DATE_FORMAT(createDate,'%m-%d %H:%i:%s')createDate,t2.username 
		from (select * from t_discuss order by createDate desc limit 11) t1 inner join userinfo t2 on t1.userid=t2.id ORDER BY createDate
	</select> -->
	
	
	<!-- 查询discuss的count -->
	<select id="getDisCount" resultType="java.lang.Integer" parameterType="java.util.HashMap">
		SELECT COUNT(1) FROM t_discuss d
		<where>
	   		<if test="starttime !='' and starttime !=undefined">  <!-- 日期:起始 -->
	        	 AND DATE_FORMAT(d.createDate,'%Y-%m-%d') &gt;=#{starttime}
	    	</if>
	    	<if test="endtime !='' and endtime !=undefined">  <!-- 截止-->
	        	 AND DATE_FORMAT(d.createDate,'%Y-%m-%d') &lt;=#{endtime}
	    	</if>
	    	<if test="context !='' and context != null">  <!-- 消息内容-->
	        	 AND d.content like concat('%',#{context},'%')
	    	</if>
			<if test="isenterprise ==1">  <!-- 消息类型 -->
	        	 AND d.oneself = #{isenterprise}
	    	</if>
		</where>
	</select>
	
	
	<!-- 查询max -->
	<select id="selectMax" resultType="java.lang.Integer">
		select max(t.discussId) from t_discuss t
	</select>
	
	
	<!--根据id查整条讨论信息 -->
	<resultMap type="com.jgxt.bean.takeover.DiscussBean" id="resultMapId2">
		<id column="discussId" property="discussId"/>
		<result column="discussId" property="discussId"/>
		<result column="userId" property="userId"/>
		<result column="content" property="content"/>
		<result column="createDate" property="createDate"/>
		<result column="replyDate" property="repayDate"/>
		<result column="sendto" property="sendto"/>
	</resultMap>
	<select id="getListById" resultMap="resultMapId2">
		select t1.* from t_discuss t1 where discussId=#{discussId}
	</select>
</mapper>

 

### 回答1: mapper.java和mapper.xml是MyBatis框架中的两个重要文件。 mapper.java是一个Java接口,用于定义数据库操作的方法。在mapper.java中,我们可以定义增删改查等操作的方法,并且可以通过注解或XML文件来映射SQL语句。 mapper.xml是一个XML文件,用于定义SQL语句和参数映射。在mapper.xml中,我们可以定义SQL语句,以及SQL语句中的参数和返回值的映射关系。同时,我们也可以在mapper.xml中定义一些复杂的SQL语句,如多表查询、分页查询等。 在MyBatis框架中,mapper.java和mapper.xml是一一对应的,即每个mapper.java对应一个mapper.xml文件。这种设计可以使代码更加清晰,易于维护。 ### 回答2: mapper.java和mapper.xml都是MyBatis框架中的重要组成部分。其中mapper.java是MyBatis框架中定义DAO的接口,而mapper.xml是DAO接口的具体实现。 mapper.java是DAO层的接口,定义了基本的业务操作方法,例如查询、插入、更新、删除等。它主要由两部分组成:一是声明DAO接口的名称和方法,二是声明DAO接口方法的参数和返回值类型。 mapper.xml则是为DAO接口提供具体的实现。mapper.xml中定义了SQL语句,用于访问数据库。它包含SQL语句、参数映射、结果映射等信息。在MyBatis中,mapper.xml文件中的SQL语句是可以动态生成的,这使得MyBatis易于开发。 映射器的使用可以实现业务逻辑与数据访问之间的解耦。它们提供了一个清晰的接口,使开发人员能够快速实现数据访问逻辑。在使用MyBatis框架时,mapper.java和mapper.xml通常是组合起来使用的,其中mapper.java提供的接口方法将会调用mapper.xml中定义的SQL语句来实现具体业务逻辑。这种实现方式非常灵活,并且易于维护。 ### 回答3: Mapper.java和Mapper.xml是MyBatis框架描述SQL语句和Java类之间映射关系的两种方式。 Mapper.java是使用Java代码来描述SQL语句和对应的参数、返回值类型。Mapper.java中的方法对应SQL语句,参数是该语句需要传递的参数,返回值是SQL语句执行结果。Mapper.java可以使得编写Java程序更加直观,同时也可以静态类型检查,减少代码错误。 Mapper.xml则是使用XML文件来描述SQL语句和Java类之间的映射关系。Mapper.xml中包含了SQL语句、参数类型、返回值类型等信息,而且还可以使用一些特殊标签来处理SQL语句的动态条件、循环等逻辑。Mapper.xml可以使得SQL语句的编写更加灵活,而且可以方便地对SQL语句进行管理和调试。 在实际使用中,通常建议使用Mapper.xml描述复杂的SQL语句逻辑,而使用Mapper.java来描述简单的SQL语句。同时,Mapper.java和Mapper.xml并不是互斥的,可以同时使用,也可以根据具体情况只使用其中一种。无论是使用Mapper.java还是Mapper.xml,都可以通过MyBatis框架来解析映射描述文件,并根据映射关系来执行SQL语句。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值