SaveUserInfoByProjectMapper.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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="org.springblade.manager.mapper.SaveUserInfoByProjectMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="contractInfoResultMap" type="org.springblade.manager.dto.SaveUserInfoByProjectDTO">
  6. <result column="id" property="id"/>
  7. <result column="project_id" property="projectId"/>
  8. <result column="contract_id" property="contractId"/>
  9. <result column="role_id" property="roleId"/>
  10. <result column="post_id" property="postId"/>
  11. <result column="user_id" property="userId"/>
  12. <result column="create_time" property="createTime"/>
  13. <result column="create_user" property="createUser"/>
  14. <result column="create_dept" property="createDept"/>
  15. <result column="update_user" property="updateUser"/>
  16. <result column="update_time" property="updateTime"/>
  17. <result column="status" property="status"/>
  18. <result column="is_deleted" property="isDeleted"/>
  19. </resultMap>
  20. <resultMap id="queryUserMap" type="org.springblade.system.user.entity.User">
  21. <result column="id" property="id"/>
  22. <result column="name" property="name"/>
  23. <result column="real_name" property="realName"/>
  24. </resultMap>
  25. <update id="deleteByIds">
  26. UPDATE m_project_assignment_user SET is_deleted = 1
  27. WHERE id in
  28. <foreach collection="idsList" item="idsList" open="(" close=")" separator=",">
  29. #{idsList}
  30. </foreach>
  31. </update>
  32. <update id="updateUserRoleIdById">
  33. UPDATE blade_user
  34. SET role_id = #{roleIds}
  35. WHERE id = #{userId}
  36. </update>
  37. <delete id="deleteByCondition">
  38. DELETE
  39. FROM m_project_assignment_user
  40. WHERE project_id = #{projectId}
  41. AND user_id = #{userId}
  42. </delete>
  43. <delete id="deleteByIdsPhysical">
  44. DELETE FROM m_project_assignment_user
  45. WHERE id in
  46. <foreach collection="idsList" item="idsList" open="(" close=")" separator=",">
  47. #{idsList}
  48. </foreach>
  49. </delete>
  50. <select id="findMaintenanceUser" resultMap="queryUserMap">
  51. select bu.id,
  52. bu.name,
  53. bu.real_name
  54. from blade_user AS bu
  55. left join (
  56. select pau.user_id
  57. from m_project_assignment_user AS pau
  58. left join blade_role AS br on pau.role_id = br.id
  59. where pau.is_deleted = 0
  60. and br.id is null
  61. group by pau.user_id
  62. ) as pau on bu.id = pau.user_id
  63. </select>
  64. <select id="queryCurrentUserDownAllContractAndProjectId" resultMap="contractInfoResultMap">
  65. select project_id, contract_id
  66. from m_project_assignment_user
  67. where is_deleted = 0
  68. and user_id = #{userId}
  69. </select>
  70. <select id="queryProjectBusinessUser" resultMap="contractInfoResultMap">
  71. select
  72. pau.*
  73. from m_project_assignment_user AS pau
  74. LEFT JOIN blade_role AS br ON pau.role_id = br.id
  75. where
  76. pau.is_deleted = 0
  77. <if test="projectId != null">
  78. and pau.project_id = #{projectId}
  79. </if>
  80. <if test="contractId != null">
  81. and pau.contract_id = #{contractId}
  82. </if>
  83. <if test="projectId != null and contractId != null">
  84. AND br.id is null
  85. </if>
  86. </select>
  87. <select id="selectByIds" resultType="org.springblade.manager.dto.SaveUserInfoByProjectDTO">
  88. SELECT u.user_id,u.role_id FROM m_project_assignment_user u
  89. WHERE id in
  90. <foreach collection="idsList" item="idsList" open="(" close=")" separator=",">
  91. #{idsList}
  92. </foreach>
  93. </select>
  94. <select id="selectSGJL" resultType="java.lang.Integer">
  95. select count(*) from m_contract_relation_jlyz where contract_id_jlyz = #{ids}
  96. </select>
  97. </mapper>