SchoolStaffMapper.xml 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.ym.mec.biz.dal.mapper.SchoolStaffMapper">
  4. <select id="selectPage" resultType="com.ym.mec.biz.dal.wrapper.SchoolStaffWrapper$SchoolStaff">
  5. SELECT t1.id_
  6. , t1.organ_id_list_ as organId
  7. , t1.school_id_
  8. , co.name_ as schoolName
  9. , t1.user_id_
  10. , t1.user_type_
  11. , t1.tenant_id_
  12. , t1.organ_id_list_
  13. , IFNULL(t2.real_name_, t2.username_) AS username
  14. , t2.avatar_
  15. , t2.phone_ AS mobile
  16. , t1.status_
  17. , t1.create_time_
  18. FROM school_staff t1
  19. JOIN sys_user t2 ON (t1.user_id_ = t2.id_)
  20. left join cooperation_organ co on t1.school_id_ = co.id_
  21. <where>
  22. t1.status_ != -1
  23. <if test="param.schoolId != null">
  24. AND t1.school_id_ = #{param.schoolId}
  25. </if>
  26. <if test="param.schoolIds != null and param.schoolIds.size() != 0">
  27. and t1.school_id_ in
  28. <foreach collection="param.schoolIds" item="schoolId" open="(" separator="," close=")">
  29. #{schoolId}
  30. </foreach>
  31. </if>
  32. <if test="param.keyword != null and param.keyword != ''">
  33. and (t2.id_ like concat('%', #{param.keyword}, '%')
  34. or t2.username_ like concat('%', #{param.keyword}, '%')
  35. or t2.phone_ like concat('%', #{param.keyword}, '%')
  36. )
  37. </if>
  38. <if test="param.tenantId != null">
  39. and t1.tenant_id_ = #{param.tenantId}
  40. </if>
  41. <if test="param.organId != null and param.organId != ''">
  42. and find_in_set(t1.organ_id_list_,#{param.organId})
  43. </if>
  44. <if test="param.coopStatus != null">
  45. and co.is_enable_ = #{param.coopStatus}
  46. </if>
  47. <if test="param.staffId != null">
  48. and t1.id_ = #{param.staffId}
  49. </if>
  50. </where>
  51. ORDER BY id_ DESC
  52. </select>
  53. <!--学校员工身份数统计-->
  54. <select id="selectUserTypeNumsStat" resultType="com.ym.mec.biz.dal.wrapper.StatGroupWrapper">
  55. SELECT t1.user_type_ AS gid, COUNT(t1.user_id_) AS total
  56. FROM school_staff t1 WHERE t1.school_id_ = #{schoolId} GROUP BY t1.user_type_
  57. </select>
  58. <update id="updateStatusAndRecoveryStatus">
  59. update school_staff ss left join sys_user su on su.id_ = ss.user_id_
  60. set ss.status_ = if(#{status},0,9),ss.recovery_status_ = if(#{status},0,1),su.lock_flag_ = if(#{status},0,9)
  61. where ss.school_id_ = #{cooperationOrganId} and ss.status_ in (0,9)
  62. <if test="status">
  63. and ss.recovery_status_ = 1
  64. </if>
  65. <if test="status == false ">
  66. and (ss.status_ = 0 or ss.status_ is null)
  67. </if>
  68. </update>
  69. <delete id="delUser">
  70. update sys_user set user_type_ = '' ,del_flag_ = 1 where id_ = #{userId}
  71. </delete>
  72. <select id="getByCoopIdAndType" resultType="com.ym.mec.biz.dal.entity.SchoolStaff">
  73. select * from school_staff
  74. <where>
  75. <if test="cooperationOrganId != null">
  76. school_id_ = #{cooperationOrganId}
  77. </if>
  78. <if test="staffType != null">
  79. and user_type_ = #{staffType}
  80. </if>
  81. and status_ != -1
  82. </where>
  83. </select>
  84. <!--学校员工身份数统计-->
  85. </mapper>