City.xml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <!-- namespace必须指向DAO接口 -->
  5. <mapper namespace="com.jpsoft.employment.modules.base.dao.CityDAO">
  6. <resultMap id="CityMap" type="com.jpsoft.employment.modules.base.entity.City">
  7. <id property="id" column="id_" />
  8. <result property="cityName" column="city_name" />
  9. <result property="type" column="type_" />
  10. <result property="pid" column="pid_" />
  11. </resultMap>
  12. <insert id="insert" parameterType="com.jpsoft.employment.modules.base.entity.City">
  13. <!--
  14. <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
  15. select sys_guid() from dual
  16. </selectKey>
  17. -->
  18. <![CDATA[
  19. insert into base_city
  20. (id_,city_name,type_,pid_)
  21. values
  22. (
  23. #{id,jdbcType= NUMERIC }
  24. ,#{cityName,jdbcType=VARCHAR}
  25. ,#{type,jdbcType= NUMERIC }
  26. ,#{pid,jdbcType= NUMERIC }
  27. )
  28. ]]>
  29. </insert>
  30. <delete id="delete" parameterType="string">
  31. delete from base_city where id_=#{id,jdbcType=VARCHAR}
  32. </delete>
  33. <update id="update" parameterType="com.jpsoft.employment.modules.base.entity.City">
  34. update base_city
  35. <set>
  36. <if test="cityName!=null">
  37. city_name=#{cityName,jdbcType=VARCHAR},
  38. </if>
  39. <if test="type!=null">
  40. type_=#{type,jdbcType= NUMERIC },
  41. </if>
  42. <if test="pid!=null">
  43. pid_=#{pid,jdbcType= NUMERIC },
  44. </if>
  45. </set>
  46. where id_=#{id}
  47. </update>
  48. <select id="get" parameterType="string" resultMap="CityMap">
  49. select
  50. id_,city_name,type_,pid_ from base_city where id_=#{0}
  51. </select>
  52. <select id="exist" parameterType="string" resultType="int">
  53. select count(*) from base_city where id_=#{0}
  54. </select>
  55. <select id="list" resultMap="CityMap">
  56. select * from base_city
  57. </select>
  58. <select id="search" parameterType="hashmap" resultMap="CityMap">
  59. <![CDATA[
  60. select * from base_city
  61. ]]>
  62. <where>
  63. <if test="searchParams.type != null">
  64. and type_ = #{searchParams.type}
  65. </if>
  66. <if test="searchParams.pid != null">
  67. and pid_ = #{searchParams.pid}
  68. </if>
  69. </where>
  70. <foreach item="sort" collection="sortList" open="order by" separator=",">
  71. ${sort.name} ${sort.order}
  72. </foreach>
  73. </select>
  74. </mapper>