EmployeeMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.EmployeeDao">
  8. <resultMap type="com.keao.edu.user.entity.Employee" id="Employee">
  9. <result column="user_id_" property="userId" />
  10. <result column="job_nature_" property="jobNature" />
  11. <result column="education_background_" property="educationBackground" />
  12. <result column="graduate_school_" property="graduateSchool" />
  13. <result column="technical_titles_" property="technicalTitles" />
  14. <result column="entry_date_" property="entryDate" />
  15. <result column="certificate_type_" property="certificateType" />
  16. <result column="certificate_num_" property="certificateNum" />
  17. <result column="update_time_" property="updateTime" />
  18. <result column="create_time_" property="createTime" />
  19. <result column="introduction_" property="introduction" />
  20. <result column="demission_date_" property="demissionDate" />
  21. <result column="contact_address_" property="contactAddress" />
  22. <result column="postal_code_" property="postalCode" />
  23. <result column="role_name_" property="roleName" />
  24. <result column="del_flag_" property="delFlag" />
  25. <result column="tenant_id_" property="tenantId" />
  26. <result column="organ_id_" property="organId" />
  27. <association property="sysUser" resultMap="com.keao.edu.user.dao.SysUserDao.SysUser"/>
  28. </resultMap>
  29. <!-- 根据主键查询一条记录 -->
  30. <select id="get" resultMap="Employee" >
  31. SELECT e.*,su.*,sur.role_id_ FROM employee e
  32. LEFT JOIN sys_user su ON e.user_id_ = su.id_
  33. LEFT JOIN sys_user_role sur ON e.user_id_ = sur.user_id_
  34. WHERE e.user_id_ = #{userId}
  35. </select>
  36. <!-- 全查询 -->
  37. <select id="findAll" resultMap="Employee">
  38. SELECT * FROM employee WHERE tenant_id_ = #{tenantId} ORDER BY user_id_
  39. </select>
  40. <!-- 向数据库增加一条记录 -->
  41. <insert id="insert" parameterType="com.keao.edu.user.entity.Employee" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  42. INSERT INTO employee (user_id_,job_nature_,education_background_,graduate_school_,technical_titles_,entry_date_,
  43. certificate_type_,certificate_num_,update_time_,create_time_,introduction_,demission_date_,contact_address_,postal_code_,tenant_id_,organ_id_)
  44. VALUES(#{userId},#{jobNature},#{educationBackground},#{graduateSchool},#{technicalTitles},#{entryDate},#{certificateType},
  45. #{certificateNum},NOW(),NOW(),#{introduction},#{demissionDate},#{contactAddress},#{postalCode},#{tenantId},#{organId})
  46. </insert>
  47. <!-- 根据主键查询一条记录 -->
  48. <update id="update" parameterType="com.keao.edu.user.entity.Employee">
  49. UPDATE employee
  50. <set>
  51. <if test="graduateSchool != null">
  52. graduate_school_ = #{graduateSchool},
  53. </if>
  54. <if test="introduction != null">
  55. introduction_ = #{introduction},
  56. </if>
  57. <if test="postalCode != null">
  58. postal_code_ = #{postalCode},
  59. </if>
  60. <if test="technicalTitles != null">
  61. technical_titles_ = #{technicalTitles},
  62. </if>
  63. <if test="entryDate != null">
  64. entry_date_ = #{entryDate},
  65. </if>
  66. <if test="contactAddress != null">
  67. contact_address_ = #{contactAddress},
  68. </if>
  69. <if test="jobNature != null">
  70. job_nature_ = #{jobNature},
  71. </if>
  72. <if test="userId != null">
  73. user_id_ = #{userId},
  74. </if>
  75. <if test="certificateType != null">
  76. certificate_type_ = #{certificateType},
  77. </if>
  78. <if test="educationBackground != null">
  79. education_background_ = #{educationBackground},
  80. </if>
  81. <if test="certificateNum != null">
  82. certificate_num_ = #{certificateNum},
  83. </if>
  84. <if test="demissionDate != null">
  85. demission_date_ = #{demissionDate},
  86. </if>
  87. <if test="tenantId != null">
  88. tenant_id_=#{tenantId},
  89. </if>
  90. <if test="organId != null">
  91. organ_id_=#{organId},
  92. </if>
  93. update_time_ = NOW()
  94. </set> WHERE user_id_ = #{userId}
  95. </update>
  96. <!-- 根据主键删除一条记录 -->
  97. <update id="delete" >
  98. UPDATE employee SET del_flag_ = 1,update_time_ = NOW() WHERE user_id_ = #{userId}
  99. </update>
  100. <sql id="employeeQueryPage">
  101. <where>
  102. e.del_flag_ = 0 AND e.tenant_id_ = #{tenantId} AND e.user_id_ != #{userId}
  103. <if test="search != null and search != ''">
  104. AND (e.user_id_ = #{search} OR su.phone_ LIKE CONCAT('%',#{search},'%') OR su.real_name_ LIKE CONCAT('%',#{search},'%'))
  105. </if>
  106. <if test="roleId != null">
  107. AND sur.role_id_ = #{roleId}
  108. </if>
  109. </where>
  110. </sql>
  111. <!-- 分页查询 -->
  112. <select id="queryPage" resultMap="Employee" parameterType="map">
  113. SELECT su.*,e.*,GROUP_CONCAT(sr.role_name_) role_name_ FROM employee e
  114. LEFT JOIN sys_user su ON e.user_id_ = su.id_
  115. LEFT JOIN sys_user_role sur ON sur.user_id_ = su.id_
  116. LEFT JOIN sys_role sr ON sr.id_ = sur.role_id_
  117. <include refid="employeeQueryPage"/>
  118. GROUP BY e.user_id_
  119. ORDER BY e.user_id_ <include refid="global.limit"/>
  120. </select>
  121. <!-- 查询当前表的总记录数 -->
  122. <select id="queryCount" resultType="int">
  123. SELECT COUNT(DISTINCT e.user_id_) FROM employee e
  124. LEFT JOIN sys_user su ON e.user_id_ = su.id_
  125. LEFT JOIN sys_user_role sur ON sur.user_id_ = su.id_
  126. <include refid="employeeQueryPage"/>
  127. </select>
  128. </mapper>