EmployeeMapper.xml 5.5 KB

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