ProtocolMapper.xml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!DOCTYPE mapper
  2. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.bosshand.virgo.api.test.dao.ProtocolDao">
  5. <resultMap type="com.bosshand.virgo.api.test.model.Protocol" id="setAResult" >
  6. <id column="id" property="id"/>
  7. <result column="name" property="name"/>
  8. <result column="comment" property="comment"/>
  9. <result column="delState" property="delState"/>
  10. </resultMap>
  11. <select id="get" resultMap="setAResult">
  12. SELECT * FROM test_set_a
  13. <where>
  14. <if test="data.id != 0">
  15. and id = #{data.id}
  16. </if>
  17. <if test="data.name != null">
  18. and name = #{data.name}
  19. </if>
  20. <if test="data.delState != 1">
  21. and delState = #{data.delState}
  22. </if>
  23. </where>
  24. limit #{currIndex}, #{pageSize}
  25. </select>
  26. <select id="count" parameterType="map" resultType="Integer">
  27. SELECT count(*) FROM test_set_a
  28. <where>
  29. <if test="id != 0">
  30. and id = #{id}
  31. </if>
  32. <if test="name != null">
  33. and name = #{name}
  34. </if>
  35. <if test="delState != 1">
  36. and delState = #{delState}
  37. </if>
  38. </where>
  39. </select>
  40. <insert id="save" parameterType="com.bosshand.virgo.api.test.model.Protocol" useGeneratedKeys="true" keyProperty="id">
  41. INSERT into test_set_a(name, comment) values (#{name}, #{comment})
  42. </insert>
  43. <update id="update" parameterType="com.bosshand.virgo.api.test.model.Protocol">
  44. UPDATE test_set_a
  45. <trim prefix="set" suffixOverrides=",">
  46. <if test="name!=null">name=#{name},</if>
  47. <if test="comment!=null">comment=#{comment},</if>
  48. <if test="delState!=0">delState=#{delState},</if>
  49. </trim>
  50. WHERE id=#{id}
  51. </update>
  52. </mapper>