ProjectUserMapper.xml 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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="cn.com.ty.lift.business.project.dao.mapper.ProjectUserMapper" >
  4. <resultMap id="BaseResultMap" type="cn.com.ty.lift.business.project.dao.entity.ProjectUser" >
  5. <id column="project_id" property="projectId" jdbcType="BIGINT" />
  6. <id column="user_id" property="userId" jdbcType="BIGINT" />
  7. <id column="user_role" property="userRole" jdbcType="VARCHAR" />
  8. <result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
  9. <result column="is_monitor" property="isMonitor" jdbcType="VARCHAR" />
  10. </resultMap>
  11. <sql id="Base_Column_List" >
  12. project_id, user_id, user_role, mt_company_id, is_monitor
  13. </sql>
  14. <select id="findUserListById" resultType="cn.com.ty.lift.business.project.dao.entity.model.response.ProjectUserResponse" parameterType="java.lang.Long">
  15. SELECT pu.project_id AS projectId,
  16. pu.user_id AS userId,
  17. pu.user_role AS userRole,
  18. pu.mt_company_id AS mtCompanyId,
  19. pu.is_monitor AS isMonitor,
  20. ui.name AS userName
  21. FROM project_user pu
  22. LEFT JOIN user_info ui ON pu.user_id = ui.user_id
  23. WHERE 1=1
  24. <if test="projectId!=null and projectId!=''">
  25. AND project_id = #{projectId,jdbcType=BIGINT}
  26. </if>
  27. <if test="mtCompanyId!=null and mtCompanyId!=''">
  28. AND mt_company_id = #{mtCompanyId,jdbcType=BIGINT}
  29. </if>
  30. </select>
  31. <!--app端 根据项目id获取项目人员名称和头像地址 -->
  32. <select id="findProjectUserListById" resultType="cn.com.ty.lift.business.project.dao.entity.model.ProjectAppUser"
  33. parameterType="cn.com.ty.lift.business.project.dao.entity.model.request.ProjectRequest">
  34. SELECT
  35. ui.name,
  36. pu.user_role AS userRole,
  37. pu.user_id AS userId,
  38. ui.avatar_url AS avatarUrl
  39. FROM project_user pu
  40. LEFT JOIN user_info ui ON pu.user_id = ui.user_id
  41. WHERE 1=1
  42. <if test="request.id!=null and request.id!=''">
  43. AND project_id = #{request.id,jdbcType=BIGINT}
  44. </if>
  45. <if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
  46. AND mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
  47. </if>
  48. </select>
  49. <!--根据项目id、用户id、用户角色删除项目组成员 -->
  50. <delete id="batchRemoveWithParams" parameterType="cn.com.ty.lift.business.project.dao.entity.model.request.ProjectRequest">
  51. DELETE
  52. FROM
  53. project_user
  54. WHERE
  55. <foreach collection="userList" item="item" index="index" separator="or">
  56. ( project_id = #{item.projectId}
  57. AND user_id = #{item.userId}
  58. AND user_role = #{item.userRole} )
  59. </foreach>
  60. </delete>
  61. <!-- 获取用户关联的项目 -->
  62. <select id="findProjectListByUserId"
  63. parameterType="cn.com.ty.lift.business.project.dao.entity.model.request.ProjectRequest"
  64. resultType="cn.com.ty.lift.business.project.dao.entity.model.response.ProjectRelevanceResponse">
  65. select
  66. pu.project_id as projectId,
  67. p.project_name as projectName,
  68. p.project_code as projectCode
  69. from
  70. project_user pu
  71. left join
  72. project p
  73. on
  74. pu.project_id = p.id
  75. where
  76. pu.mt_company_id = #{mtCompanyId}
  77. and
  78. pu.user_id = #{workerId}
  79. </select>
  80. </mapper>