TeacherSalaryComplaintsMapper.xml 5.4 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. <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
  4. <mapper namespace="com.ym.mec.biz.dal.dao.TeacherSalaryComplaintsDao">
  5. <resultMap type="com.ym.mec.biz.dal.entity.TeacherSalaryComplaints" id="TeacherSalaryComplaints">
  6. <result column="id_" property="id" />
  7. <result column="teacher_id_" property="teacherId" />
  8. <result column="salary_settlement_month_" property="salarySettlementMonth" />
  9. <result column="reason_" property="reason" />
  10. <result column="status_" property="statusEnum" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  11. <result column="operator_id_" property="operatorId"/>
  12. <result column="handing_suggestion_" property="handingSuggestion" />
  13. <result column="organ_name_" property="organName" />
  14. <result column="real_name_" property="realName" />
  15. <result column="operator_real_name_" property="operatorRealName" />
  16. <result column="handing_suggestion_" property="handingSuggestion" />
  17. <result column="create_time_" property="createTime" />
  18. <result column="update_time_" property="updateTime" />
  19. </resultMap>
  20. <!-- 向数据库增加一条记录 -->
  21. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.TeacherSalaryComplaints"
  22. useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  23. INSERT INTO teacher_salary_complaints
  24. (teacher_id_,salary_settlement_month_,reason_,status_,operator_id_,handing_suggestion_,create_time_,update_time_)
  25. VALUES(#{teacherId},#{salarySettlementMonth},#{reason},#{statusEnum, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  26. #{operatorId},#{handingSuggestion},NOW(),NOW())
  27. </insert>
  28. <!-- 根据主键查询一条记录 -->
  29. <update id="update" parameterType="com.ym.mec.biz.dal.entity.TeacherSalaryComplaints">
  30. UPDATE teacher_salary_complaints
  31. <set>
  32. <if test="statusEnum != null">
  33. status_ = #{statusEnum, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  34. </if>
  35. <if test="teacherId != null">
  36. teacher_id_ = #{teacherId},
  37. </if>
  38. <if test="salarySettlementMonth != null">
  39. salary_settlement_month_ = #{salarySettlementMonth},
  40. </if>
  41. <if test="reason != null">
  42. reason_ = #{reason},
  43. </if>
  44. <if test="operatorId != null">
  45. operator_id_ = #{operatorId},
  46. </if>
  47. <if test="handingSuggestion != null">
  48. handing_suggestion_ = #{handingSuggestion},
  49. </if>
  50. <if test="updateTime != null">
  51. update_time_ = NOW()
  52. </if>
  53. </set>
  54. WHERE id_ = #{id}
  55. </update>
  56. <update id="repealComplaints">
  57. UPDATE teacher_salary_complaints tsc SET tsc.status_ = 'WITHDRAWN'
  58. WHERE tsc.teacher_id_ = #{teacherId} AND tsc.salary_settlement_month_ = #{salarySettlementMonth}
  59. AND tsc.status_ = 'PENDING'
  60. </update>
  61. <update id="updateComplaintStatusTuDoneWithMonth">
  62. UPDATE teacher_salary_complaints tsc SET tsc.status_ = 'DONE'
  63. WHERE tsc.salary_settlement_month_ = #{month}
  64. AND tsc.status_ = 'PENDING'
  65. </update>
  66. <!-- 根据主键查询一条记录 -->
  67. <select id="get" resultMap="TeacherSalaryComplaints">
  68. SELECT * FROM teacher_salary_complaints WHERE id_ = #{id}
  69. </select>
  70. <!-- 全查询 -->
  71. <select id="findAll" resultMap="TeacherSalaryComplaints">
  72. SELECT * FROM
  73. teacher_salary_complaints ORDER BY id_
  74. </select>
  75. <!-- 根据主键删除一条记录 -->
  76. <delete id="delete">
  77. DELETE FROM teacher_salary_complaints WHERE id_ =
  78. #{id}
  79. </delete>
  80. <!-- 分页查询 -->
  81. <select id="queryPage" resultMap="TeacherSalaryComplaints" parameterType="map">
  82. SELECT o.name_ organ_name_,su.real_name_,suo.real_name_ operator_real_name_,tsc.*
  83. FROM teacher_salary_complaints tsc
  84. LEFT JOIN teacher t ON t.id_ = tsc.teacher_id_
  85. LEFT JOIN sys_user su ON su.id_ = t.id_
  86. LEFT JOIN sys_user suo ON suo.id_ = tsc.operator_id_
  87. LEFT JOIN organization o ON o.id_ = t.organ_id_
  88. <include refid="queryPageSql"/>
  89. ORDER BY tsc.create_time_ DESC
  90. <include refid="global.limit" />
  91. </select>
  92. <sql id="queryPageSql">
  93. <where>
  94. <if test="organId != null and organId != ''">
  95. FIND_IN_SET(t.organ_id_,#{organId})
  96. </if>
  97. <if test="salarySettlementMonth != null and salarySettlementMonth != ''">
  98. AND tsc.salary_settlement_month_ = #{salarySettlementMonth}
  99. </if>
  100. <if test="teacherId != null">
  101. AND tsc.teacher_id_ = #{teacherId}
  102. </if>
  103. <if test="statusEnum != null">
  104. AND tsc.status_ = #{statusEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  105. </if>
  106. </where>
  107. </sql>
  108. <!-- 查询当前表的总记录数 -->
  109. <select id="queryCount" resultType="int">
  110. SELECT COUNT(tsc.id_)
  111. FROM teacher_salary_complaints tsc
  112. LEFT JOIN teacher t ON t.id_ = tsc.teacher_id_
  113. <include refid="queryPageSql"/>
  114. </select>
  115. <select id="findByMonthAndTeacherId" resultMap="TeacherSalaryComplaints">
  116. SELECT * FROM teacher_salary_complaints tsc
  117. WHERE tsc.teacher_id_ = #{teacherId} AND tsc.salary_settlement_month_ = #{settlementMonth}
  118. AND tsc.status_ = #{statusEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} LIMIT 1
  119. </select>
  120. <select id="findTeacherSalaryComplaintsWithMonth" resultMap="TeacherSalaryComplaints">
  121. SELECT * FROM teacher_salary_complaints tsc
  122. WHERE tsc.teacher_id_ = #{teacherId} AND tsc.salary_settlement_month_ = #{month}
  123. <if test="status!=null">
  124. AND tsc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  125. </if>
  126. </select>
  127. </mapper>