mybatis增删改查sql,带分页,新增可以返回id

**

mybatis增删改查sql,带分页,新增可以返回id

<resultMap type="com.spring.pojo.T_Form" id="T_FormMap">
   <result column="formId" property="formId"/>
   <result column="form_no" property="form_no"/>
   <result column="p_money" property="p_money"/>
   <result column="r_money" property="r_money"/>
   <result column="p_state" property="p_state"/>
   <result column="n_datatime" property="n_datatime"/>
   <result column="p_datatime" property="p_datatime"/>
   <result column="e_state" property="e_state"/>
   <result column="e_datatime" property="e_datatime"/>
   <result column="ShopNO" property="ShopNO"/>
   <result column="ShopName" property="ShopName"/>
   <result column="ShopAddress" property="ShopAddress"/>
   <result column="ShopPhone" property="ShopPhone"/>
   <result column="UnionID" property="UnionID"/>
   <result column="PhoneWX" property="PhoneWX"/>
   <result column="PersonWX" property="personWX"/>
   <result column="addressWX" property="addressWX"/>
   <result column="delivery" property="delivery"/>
   <result column="ShopID" property="ShopID"/>
</resultMap>

<select id="selectAllT_Form" resultMap="T_FormMap">
    select * from(select rownum rom,rn.* from (select * from T_Form t 
	where t.unionID =#{unionId} order by t.formid desc)rn)rom where rom <![CDATA[<]]>= #{pageSize,jdbcType=NUMERIC} and rom <![CDATA[>]]> #{pageNo,jdbcType=NUMERIC}
</select>

<select id="queryT_FormByStatus" resultMap="T_FormMap">
    select * from(select rownum rom,rn.* from (select * from T_Form t  
	where t.unionID =#{unionId} 
    <if test="p_state != null">
		and t.p_state != #{p_state}
	</if>
	<if test="delivery != null">
		and t.delivery = #{delivery}
	</if>
	order by t.formid desc)rn)rom where rom <![CDATA[<]]>= #{pageSize,jdbcType=NUMERIC} and rom <![CDATA[>]]> #{pageNo,jdbcType=NUMERIC}
</select>

<insert id="addT_Form" parameterType="com.spring.pojo.T_Form">
	
	<selectKey keyProperty="formId" order="AFTER" resultType="java.lang.Integer">
		select Tab_T_Form_Sequence.CURRVAL as formId from dual
	</selectKey>
	
	insert into T_Form values(null,#{form_no},#{p_money},#{r_money},#{p_state},#{n_datatime},#{p_datatime},#{e_state},#{e_datatime},#{ShopNO,jdbcType=VARCHAR},#{ShopName,jdbcType=VARCHAR},#{ShopAddress,jdbcType=VARCHAR},#{ShopPhone,jdbcType=VARCHAR},#{UnionID,jdbcType=VARCHAR},#{personWX,jdbcType=VARCHAR},#{PhoneWX,jdbcType=VARCHAR},#{addressWX,jdbcType=VARCHAR},#{delivery,jdbcType=NUMERIC},#{ShopID,jdbcType=NUMERIC})	
			
</insert>

<delete id="deleteT_Form">
	
	delete from T_Form t where t.formid=#{formid}	
			
</delete>

导入

在写mapper接口时参数的注解别忘了,最需要注意的是传的如果是对象也就是添加时千万别加参数注解!!!

猜你喜欢

转载自blog.csdn.net/qq_39999419/article/details/84853867