FsUserCompanyBindMapper.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.course.mapper.FsUserCompanyBindMapper">
  6. <resultMap type="FsUserCompanyBind" id="FsUserCompanyBindResult">
  7. <result property="id" column="id" />
  8. <result property="fsUserId" column="fs_user_id" />
  9. <result property="companyUserId" column="company_user_id" />
  10. <result property="companyId" column="company_id" />
  11. <result property="projectId" column="project_id" />
  12. <result property="qwUserId" column="qw_user_id" />
  13. <result property="qwExternalContactId" column="qw_external_contact_id" />
  14. <result property="qwCompanyId" column="qw_company_id" />
  15. <result property="courseId" column="course_id" />
  16. <result property="videoId" column="video_id" />
  17. <result property="watchLogId" column="watch_log_id" />
  18. <result property="logType" column="log_type" />
  19. <result property="finishTime" column="finish_time" />
  20. <result property="createTime" column="create_time" />
  21. <result property="createBy" column="create_by" />
  22. <result property="updateBy" column="update_by" />
  23. <result property="updateTime" column="update_time" />
  24. <result property="remark" column="remark" />
  25. </resultMap>
  26. <sql id="selectFsUserCompanyBindVo">
  27. select id, fs_user_id, company_user_id, company_id, project_id, qw_user_id, qw_external_contact_id, qw_company_id, course_id, video_id, watch_log_id, log_type, finish_time, create_time, create_by, update_by, update_time, remark from fs_user_company_bind
  28. </sql>
  29. <select id="selectFsUserCompanyBindList" parameterType="FsUserCompanyBind" resultMap="FsUserCompanyBindResult">
  30. <include refid="selectFsUserCompanyBindVo"/>
  31. <where>
  32. <if test="fsUserId != null "> and fs_user_id = #{fsUserId}</if>
  33. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  34. <if test="companyId != null "> and company_id = #{companyId}</if>
  35. <if test="projectId != null "> and project_id = #{projectId}</if>
  36. <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
  37. <if test="qwExternalContactId != null "> and qw_external_contact_id = #{qwExternalContactId}</if>
  38. <if test="qwCompanyId != null "> and qw_company_id = #{qwCompanyId}</if>
  39. <if test="courseId != null "> and course_id = #{courseId}</if>
  40. <if test="videoId != null "> and video_id = #{videoId}</if>
  41. <if test="logType != null "> and log_type = #{logType}</if>
  42. <if test="finishTime != null "> and finish_time = #{finishTime}</if>
  43. </where>
  44. </select>
  45. <select id="selectFsUserCompanyBindById" parameterType="Long" resultMap="FsUserCompanyBindResult">
  46. <include refid="selectFsUserCompanyBindVo"/>
  47. where id = #{id}
  48. </select>
  49. <insert id="insertFsUserCompanyBind" parameterType="FsUserCompanyBind" useGeneratedKeys="true" keyProperty="id">
  50. insert into fs_user_company_bind
  51. <trim prefix="(" suffix=")" suffixOverrides=",">
  52. <if test="fsUserId != null">fs_user_id,</if>
  53. <if test="companyUserId != null">company_user_id,</if>
  54. <if test="companyId != null">company_id,</if>
  55. <if test="projectId != null">project_id,</if>
  56. <if test="qwUserId != null">qw_user_id,</if>
  57. <if test="qwExternalContactId != null">qw_external_contact_id,</if>
  58. <if test="qwCompanyId != null">qw_company_id,</if>
  59. <if test="courseId != null">course_id,</if>
  60. <if test="videoId != null">video_id,</if>
  61. <if test="watchLogId != null">watch_log_id,</if>
  62. <if test="logType != null">log_type,</if>
  63. <if test="finishTime != null">finish_time,</if>
  64. <if test="createTime != null">create_time,</if>
  65. <if test="createBy != null">create_by,</if>
  66. <if test="updateBy != null">update_by,</if>
  67. <if test="updateTime != null">update_time,</if>
  68. <if test="remark != null">remark,</if>
  69. </trim>
  70. <trim prefix="values (" suffix=")" suffixOverrides=",">
  71. <if test="fsUserId != null">#{fsUserId},</if>
  72. <if test="companyUserId != null">#{companyUserId},</if>
  73. <if test="companyId != null">#{companyId},</if>
  74. <if test="projectId != null">#{projectId},</if>
  75. <if test="qwUserId != null">#{qwUserId},</if>
  76. <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
  77. <if test="qwCompanyId != null">#{qwCompanyId},</if>
  78. <if test="courseId != null">#{courseId},</if>
  79. <if test="videoId != null">#{videoId},</if>
  80. <if test="watchLogId != null">#{watchLogId},</if>
  81. <if test="logType != null">#{logType},</if>
  82. <if test="finishTime != null">#{finishTime},</if>
  83. <if test="createTime != null">#{createTime},</if>
  84. <if test="createBy != null">#{createBy},</if>
  85. <if test="updateBy != null">#{updateBy},</if>
  86. <if test="updateTime != null">#{updateTime},</if>
  87. <if test="remark != null">#{remark},</if>
  88. </trim>
  89. </insert>
  90. <update id="updateFsUserCompanyBind" parameterType="FsUserCompanyBind">
  91. update fs_user_company_bind
  92. <trim prefix="SET" suffixOverrides=",">
  93. <if test="fsUserId != null">fs_user_id = #{fsUserId},</if>
  94. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  95. <if test="companyId != null">company_id = #{companyId},</if>
  96. <if test="projectId != null">project_id = #{projectId},</if>
  97. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  98. <if test="qwExternalContactId != null">qw_external_contact_id = #{qwExternalContactId},</if>
  99. <if test="qwCompanyId != null">qw_company_id = #{qwCompanyId},</if>
  100. <if test="courseId != null">course_id = #{courseId},</if>
  101. <if test="videoId != null">video_id = #{videoId},</if>
  102. <if test="watchLogId != null">watch_log_id = #{watchLogId},</if>
  103. <if test="logType != null">log_type = #{logType},</if>
  104. <if test="finishTime != null">finish_time = #{finishTime},</if>
  105. <if test="createTime != null">create_time = #{createTime},</if>
  106. <if test="createBy != null">create_by = #{createBy},</if>
  107. <if test="updateBy != null">update_by = #{updateBy},</if>
  108. <if test="updateTime != null">update_time = #{updateTime},</if>
  109. <if test="remark != null">remark = #{remark},</if>
  110. </trim>
  111. where id = #{id}
  112. </update>
  113. <delete id="deleteFsUserCompanyBindById" parameterType="Long">
  114. delete from fs_user_company_bind where id = #{id}
  115. </delete>
  116. <delete id="deleteFsUserCompanyBindByIds" parameterType="String">
  117. delete from fs_user_company_bind where id in
  118. <foreach item="id" collection="array" open="(" separator="," close=")">
  119. #{id}
  120. </foreach>
  121. </delete>
  122. <select id="getWatchLogList" resultType="com.fs.course.vo.UserWatchLogListVo">
  123. select
  124. a.*,
  125. b.nick_name fsUserName,
  126. c.dict_label projectName,
  127. e.course_name,
  128. IF(g.company_user_id = #{userId}, g.qw_user_name, '其他') qwUserName,
  129. f.title videoName
  130. from
  131. fs_user_company_bind a
  132. left join fs_user b on a.fs_user_id = b.user_id
  133. left join sys_dict_data c on c.dict_type = 'sys_course_project' and dict_value = a.project_id
  134. left join fs_user_course e on a.course_id = e.course_id
  135. left join fs_user_course_video f on a.video_id = f.video_id
  136. left join qw_user g on g.id = a.qw_user_id
  137. <where>
  138. <if test="externalUserId != null">
  139. and a.qw_external_contact_id = #{externalUserId}
  140. </if>
  141. <if test="fsUserId != null">
  142. and a.fs_user_id = #{fsUserId}
  143. </if>
  144. <if test="courseId != null">
  145. and a.course_id = #{courseId}
  146. </if>
  147. <if test="videoId != null">
  148. and a.video_id = #{videoId}
  149. </if>
  150. </where>
  151. order by create_time desc
  152. </select>
  153. </mapper>