EmployeeMapper.xml 5.5 KB

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