ExamLocationMapper.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.keao.edu.user.dao.ExamLocationDao">
  8. <resultMap type="com.keao.edu.user.entity.ExamLocation" id="ExamLocation">
  9. <result column="id_" property="id" />
  10. <result column="name_" property="name" />
  11. <result column="contact_name_" property="contactName" />
  12. <result column="contact_phone_" property="contactPhone" />
  13. <result column="is_available_" property="isAvailable" />
  14. <result column="address_" property="address" />
  15. <result column="create_time_" property="createTime" />
  16. <result column="update_time_" property="updateTime" />
  17. <result column="tenant_id_" property="tenantId" />
  18. </resultMap>
  19. <!-- 根据主键查询一条记录 -->
  20. <select id="get" resultMap="ExamLocation" >
  21. SELECT * FROM exam_location WHERE id_ = #{id}
  22. </select>
  23. <!-- 全查询 -->
  24. <select id="findAll" resultMap="ExamLocation">
  25. SELECT * FROM exam_location WHERE tenant_id_ = #{tenantId} ORDER BY id_
  26. </select>
  27. <!-- 向数据库增加一条记录 -->
  28. <insert id="insert" parameterType="com.keao.edu.user.entity.ExamLocation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  29. INSERT INTO exam_location (id_,name_,contact_name_,contact_phone_,address_,is_available_,create_time_,update_time_,tenant_id_)
  30. VALUES(#{id},#{name},#{contactName},#{contactPhone},#{address},#{isAvailable},NOW(),NOW(),#{tenantId})
  31. </insert>
  32. <!-- 根据主键查询一条记录 -->
  33. <update id="update" parameterType="com.keao.edu.user.entity.ExamLocation">
  34. UPDATE exam_location
  35. <set>
  36. <if test="address != null">
  37. address_ = #{address},
  38. </if>
  39. <if test="isAvailable != null">
  40. is_available_ = #{isAvailable},
  41. </if>
  42. <if test="contactPhone != null">
  43. contact_phone_ = #{contactPhone},
  44. </if>
  45. <if test="contactName != null">
  46. contact_name_ = #{contactName},
  47. </if>
  48. <if test="name != null">
  49. name_ = #{name},
  50. </if>
  51. <if test="delFlag!=null">
  52. del_flag_=#{delFlag},
  53. </if>
  54. <if test="tenantId != null">
  55. tenant_id_ = #{tenantId},
  56. </if>
  57. update_time_ = NOW()
  58. </set> WHERE id_ = #{id}
  59. </update>
  60. <!-- 根据主键删除一条记录 -->
  61. <update id="delete" >
  62. UPDATE exam_location SET del_flag_=1 WHERE id_ = #{id}
  63. </update>
  64. <sql id="queryCondition">
  65. <where>
  66. del_flag_=0
  67. <if test="isAvailable!=null">
  68. AND is_available_=#{isAvailable}
  69. </if>
  70. <if test="search!=null">
  71. AND (id_=#{search} OR name_ LIKE CONCAT('%', #{serch}, '%'))
  72. </if>
  73. <if test="tenantId != null and tenantId!=0">
  74. AND tenant_id_ = #{tenantId}
  75. </if>
  76. </where>
  77. </sql>
  78. <!-- 分页查询 -->
  79. <select id="queryPage" resultMap="ExamLocation" parameterType="map">
  80. SELECT * FROM exam_location
  81. <include refid="queryCondition"/>
  82. ORDER BY id_
  83. <include refid="global.limit"/>
  84. </select>
  85. <!-- 查询当前表的总记录数 -->
  86. <select id="queryCount" resultType="int">
  87. SELECT COUNT(*) FROM exam_location
  88. <include refid="queryCondition"/>
  89. </select>
  90. <!-- 根据ids获取考点 -->
  91. <select id="getExamLocationByIds" resultMap="ExamLocation">
  92. SELECT * FROM exam_location WHERE FIND_IN_SET(id_,#{ids})
  93. </select>
  94. <select id="getTenantAllLocations" resultMap="ExamLocation">
  95. SELECT * FROM exam_location WHERE tenant_id_ = #{tenantId} AND is_available_=1 ORDER BY id_
  96. </select>
  97. </mapper>