StudentMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.StudentDao">
  8. <resultMap type="com.keao.edu.user.api.entity.Student" id="Student">
  9. <result column="user_id_" property="userId" />
  10. <result column="certificate_photo_" property="certificatePhoto" />
  11. <result column="create_time_" property="createTime" />
  12. <result column="update_time_" property="updateTime" />
  13. <result column="tenant_id_" property="tenantId" />
  14. <result column="organ_id_" property="organId" />
  15. <association property="sysUser" resultMap="com.keao.edu.user.dao.SysUserDao.SysUser"/>
  16. </resultMap>
  17. <select id="get" resultMap="Student">
  18. SELECT * FROM student stu
  19. LEFT JOIN sys_user su ON su.id_=stu.user_id_
  20. WHERE stu.user_id_=#{id}
  21. </select>
  22. <!-- 全查询 -->
  23. <select id="findAll" resultMap="Student">
  24. SELECT * FROM student WHERE tenant_id_=#{tenantId}
  25. </select>
  26. <!-- 向数据库增加一条记录 -->
  27. <insert id="insert" parameterType="com.keao.edu.user.api.entity.Student" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  28. INSERT INTO student (user_id_,certificate_photo_,create_time_,update_time_,tenant_id_,organ_id_)
  29. VALUES(#{userId},#{certificatePhoto},NOW(),NOW(),#{tenantId},#{organId})
  30. </insert>
  31. <!-- 根据主键查询一条记录 -->
  32. <update id="update" parameterType="com.keao.edu.user.api.entity.Student">
  33. UPDATE student
  34. <set>
  35. <if test="certificatePhoto != null">
  36. certificate_photo_ = #{certificatePhoto},
  37. </if>
  38. <if test="tenantId != null">
  39. tenant_id_ = #{tenantId},
  40. </if>
  41. <if test="organId != null">
  42. organ_id_ = #{organId},
  43. </if>
  44. update_time_ = NOW()
  45. </set> WHERE user_id_ = #{userId}
  46. </update>
  47. <delete id="delete" >
  48. DELETE FROM student WHERE user_id_ = #{id}
  49. </delete>
  50. <sql id="queryCondition">
  51. <where>
  52. stu.tenant_id_ = #{tenantId}
  53. <if test="search != null and search != ''">
  54. AND (stu.user_id_ = #{search} OR su.real_name_ LIKE CONCAT (#{search}, '%'))
  55. </if>
  56. </where>
  57. </sql>
  58. <!-- 分页查询 -->
  59. <select id="queryPage" resultMap="Student" parameterType="map">
  60. SELECT * FROM student stu
  61. LEFT JOIN sys_user su ON su.id_=stu.user_id_
  62. <include refid="queryCondition"/>
  63. <include refid="global.limit"/>
  64. </select>
  65. <!-- 查询当前表的总记录数 -->
  66. <select id="queryCount" resultType="int">
  67. SELECT COUNT(*) FROM student stu
  68. LEFT JOIN sys_user su ON su.id_ = stu.user_id_
  69. <include refid="queryCondition"/>
  70. </select>
  71. <resultMap id="queryApplyListMap" type="com.keao.edu.user.dto.StudentExamPaymentDto">
  72. <association property="examRegistration" resultMap="com.keao.edu.user.dao.ExamRegistrationDao.ExamRegistration"/>
  73. <association property="studentExamResult" resultMap="com.keao.edu.user.dao.StudentExamResultDao.StudentExamResult"/>
  74. <association property="examRegistrationPayment" resultMap="com.keao.edu.user.dao.ExamRegistrationPaymentDao.ExamRegistrationPayment"/>
  75. </resultMap>
  76. <select id="queryApplyList" resultMap="queryApplyListMap">
  77. SELECT * FROM exam_registration er
  78. LEFT JOIN exam_registration_payment erp ON er.id_ = erp.exam_registration_id_
  79. LEFT JOIN student_exam_result ser ON ser.examination_basic_id_ = er.examination_basic_id_
  80. <include refid="queryApplyListSql"/>
  81. <include refid="global.limit"/>
  82. </select>
  83. <select id="countApplyList" resultType="java.lang.Integer">
  84. SELECT COUNT(er.id_) FROM exam_registration er
  85. LEFT JOIN exam_registration_payment erp ON er.id_ = erp.exam_registration_id_
  86. LEFT JOIN student_exam_result ser ON ser.examination_basic_id_ = er.examination_basic_id_
  87. <include refid="queryApplyListSql"/>
  88. </select>
  89. <sql id="queryApplyListSql">
  90. <where>
  91. er.student_id_ = erp.student_id_ AND er.student_id_ = ser.student_id_ AND erp.trans_status_ = 'SUCCESS'
  92. <if test="studentId != null">
  93. AND er.student_id_ = #{studentId}
  94. </if>
  95. <if test="tenantId != null">
  96. AND er.tenant_id_ = #{tenantId}
  97. </if>
  98. </where>
  99. </sql>
  100. </mapper>