SchoolMapper.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.web.dal.dao.SchoolDao">
  8. <resultMap type="com.ym.mec.web.dal.entity.School" id="School">
  9. <result column="id_" property="id"/>
  10. <result column="name_" property="name"/>
  11. <result column="organ_id_" property="organId"/>
  12. <result column="address_" property="address"/>
  13. <result column="contact_phone_" property="contactPhone"/>
  14. <result column="create_time_" property="createTime"/>
  15. <result column="update_time_" property="updateTime"/>
  16. <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  17. <result column="contact_name_" property="contactName"/>
  18. <result column="longitude_latitude_" property="longitudeLatitude"/>
  19. <result column="subsidy_" property="subsidy"/>
  20. </resultMap>
  21. <!-- 根据主键查询一条记录 -->
  22. <select id="get" resultMap="School">
  23. SELECT * FROM school WHERE id_ = #{id}
  24. </select>
  25. <!-- 全查询 -->
  26. <select id="findAll" resultMap="School">
  27. SELECT * FROM school ORDER BY id_
  28. </select>
  29. <!-- 向数据库增加一条记录 -->
  30. <insert id="insert" parameterType="com.ym.mec.web.dal.entity.School" useGeneratedKeys="true" keyColumn="id"
  31. keyProperty="id">
  32. <!--
  33. <selectKey resultClass="int" keyProperty="id" >
  34. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  35. </selectKey>
  36. -->
  37. INSERT INTO school
  38. (id_,name_,organ_id_,address_,contact_phone_,create_time_,update_time_,contact_name_,longitude_latitude_,subsidy_)
  39. VALUES(#{id},#{name},#{organId},#{address},#{contactPhone},now(),now(),#{contactName},#{longitudeLatitude},#{subsidy})
  40. </insert>
  41. <!-- 根据主键查询一条记录 -->
  42. <update id="update" parameterType="com.ym.mec.web.dal.entity.School">
  43. UPDATE school
  44. <set>
  45. <if test="delFlag != null">
  46. del_flag_ = #{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  47. </if>
  48. <if test="organId != null">
  49. organ_id_ = #{organId},
  50. </if>
  51. <if test="updateTime != null">
  52. update_time_ = #{updateTime},
  53. </if>
  54. <if test="contactPhone != null">
  55. contact_phone_ = #{contactPhone},
  56. </if>
  57. <if test="longitudeLatitude != null">
  58. longitude_latitude_ = #{longitudeLatitude},
  59. </if>
  60. <if test="address != null">
  61. address_ = #{address},
  62. </if>
  63. <if test="contactName != null">
  64. contact_name_ = #{contactName},
  65. </if>
  66. <if test="name != null">
  67. name_ = #{name},
  68. </if>
  69. <if test="subsidy != null">
  70. subsidy_ = #{subsidy},
  71. </if>
  72. </set>
  73. WHERE id_ = #{id}
  74. </update>
  75. <!-- 根据主键删除一条记录 -->
  76. <delete id="delete">
  77. UPDATE school SET del_flag_ = 1 WHERE id_ = #{id}
  78. </delete>
  79. <!-- 分页查询 -->
  80. <select id="queryPage" resultMap="School" parameterType="map">
  81. SELECT * FROM school ORDER BY id_
  82. <include refid="global.limit"/>
  83. </select>
  84. <!-- 查询当前表的总记录数 -->
  85. <select id="queryCount" resultType="int">
  86. SELECT COUNT(*) FROM school
  87. </select>
  88. <select id="queryByOrganId" resultMap="School">
  89. SELECT * FROM school
  90. <where>
  91. <if test="organId != null">
  92. organ_id_ = #{organId}
  93. </if>
  94. <if test="delFlag != null">
  95. AND del_flag_ = #{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  96. </if>
  97. </where>
  98. </select>
  99. </mapper>