StudentCourseMapper.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. <mapper namespace="com.jeeplus.modules.test.manytomany.mapper.StudentCourseMapper">
  4. <sql id="studentCourseColumns">
  5. a.id AS "id",
  6. a.student_id AS "student.id",
  7. a.course_id AS "course.id",
  8. a.score AS "score",
  9. a.create_by AS "createBy.id",
  10. a.create_date AS "createDate",
  11. a.update_by AS "updateBy.id",
  12. a.update_date AS "updateDate",
  13. a.remarks AS "remarks",
  14. a.del_flag AS "delFlag",
  15. student.name AS "student.name",
  16. course.name AS "course.name"
  17. </sql>
  18. <sql id="studentCourseJoins">
  19. LEFT JOIN test_student student ON student.id = a.student_id
  20. LEFT JOIN test_course course ON course.id = a.course_id
  21. </sql>
  22. <select id="get" resultType="StudentCourse" >
  23. SELECT
  24. <include refid="studentCourseColumns"/>
  25. FROM test_student_course a
  26. <include refid="studentCourseJoins"/>
  27. WHERE a.id = #{id}
  28. </select>
  29. <select id="findList" resultType="StudentCourse" >
  30. SELECT
  31. <include refid="studentCourseColumns"/>
  32. FROM test_student_course a
  33. <include refid="studentCourseJoins"/>
  34. <where>
  35. a.del_flag = #{DEL_FLAG_NORMAL}
  36. ${dataScope}
  37. <if test="student != null and student.id != null and student.id != ''">
  38. AND a.student_id = #{student.id}
  39. </if>
  40. <if test="course != null and course.id != null and course.id != ''">
  41. AND a.course_id = #{course.id}
  42. </if>
  43. </where>
  44. <choose>
  45. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  46. ORDER BY ${page.orderBy}
  47. </when>
  48. <otherwise>
  49. ORDER BY a.update_date DESC
  50. </otherwise>
  51. </choose>
  52. </select>
  53. <select id="findAllList" resultType="StudentCourse" >
  54. SELECT
  55. <include refid="studentCourseColumns"/>
  56. FROM test_student_course a
  57. <include refid="studentCourseJoins"/>
  58. <where>
  59. a.del_flag = #{DEL_FLAG_NORMAL}
  60. ${dataScope}
  61. </where>
  62. <choose>
  63. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  64. ORDER BY ${page.orderBy}
  65. </when>
  66. <otherwise>
  67. ORDER BY a.update_date DESC
  68. </otherwise>
  69. </choose>
  70. </select>
  71. <insert id="insert">
  72. INSERT INTO test_student_course(
  73. id,
  74. student_id,
  75. course_id,
  76. score,
  77. create_by,
  78. create_date,
  79. update_by,
  80. update_date,
  81. remarks,
  82. del_flag
  83. ) VALUES (
  84. #{id},
  85. #{student.id},
  86. #{course.id},
  87. #{score},
  88. #{createBy.id},
  89. #{createDate},
  90. #{updateBy.id},
  91. #{updateDate},
  92. #{remarks},
  93. #{delFlag}
  94. )
  95. </insert>
  96. <update id="update">
  97. UPDATE test_student_course SET
  98. student_id = #{student.id},
  99. course_id = #{course.id},
  100. score = #{score},
  101. update_by = #{updateBy.id},
  102. update_date = #{updateDate},
  103. remarks = #{remarks}
  104. WHERE id = #{id}
  105. </update>
  106. <!--物理删除-->
  107. <update id="delete">
  108. DELETE FROM test_student_course
  109. WHERE id = #{id}
  110. </update>
  111. <!--逻辑删除-->
  112. <update id="deleteByLogic">
  113. UPDATE test_student_course SET
  114. del_flag = #{DEL_FLAG_DELETE}
  115. WHERE id = #{id}
  116. </update>
  117. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  118. <select id="findUniqueByProperty" resultType="StudentCourse" statementType="STATEMENT">
  119. select * FROM test_student_course where ${propertyName} = '${value}'
  120. </select>
  121. </mapper>