CompanyWxClientMapper.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.company.mapper.CompanyWxClientMapper">
  6. <resultMap type="CompanyWxClient" id="CompanyWxClientResult">
  7. <result property="id" column="id" />
  8. <result property="roboticWxId" column="robotic_wx_id" />
  9. <result property="nickName" column="nick_name" />
  10. <result property="avatar" column="avatar" />
  11. <result property="phone" column="phone" />
  12. <result property="wxNo" column="wx_no" />
  13. <result property="isAdd" column="is_add" />
  14. <result property="addTime" column="add_time" />
  15. <result property="remark" column="remark" />
  16. <result property="createTime" column="create_time" />
  17. </resultMap>
  18. <sql id="selectCompanyWxClientVo">
  19. select a.* from company_wx_client a
  20. </sql>
  21. <select id="selectCompanyWxClientList" resultType="com.fs.company.domain.CompanyWxClient">
  22. select a.*,b.wx_nick_name,c.name as dialogName,robotic.name roboticName from company_wx_client a
  23. inner join company_voice_robotic_wx wx on a.robotic_wx_id = wx.id
  24. inner join company_wx_account b on wx.account_id = b.id
  25. inner join company_wx_dialog c on a.dialog_id = c.id
  26. inner join company_voice_robotic robotic on a.robotic_id = robotic.id
  27. <where>
  28. <if test="roboticId != null "> and a.robotic_id = #{roboticId}</if>
  29. <if test="roboticWxId != null "> and b.id = #{roboticWxId}</if>
  30. <if test="customerId != null "> and a.customer_id = #{customerId}</if>
  31. <if test="dialogId != null "> and a.dialog_id = #{dialogId}</if>
  32. <if test="nickName != null and nickName != ''"> and a.nick_name = #{nickName}</if>
  33. <if test="avatar != null and avatar != ''"> and a.avatar = #{avatar}</if>
  34. <if test="phone != null and phone != ''"> and a.phone = #{phone}</if>
  35. <if test="wxNo != null and wxNo != ''"> and a.wx_no = #{wxNo}</if>
  36. <if test="isAdd != null "> and a.is_add = #{isAdd}</if>
  37. <if test="addTime != null "> and a.add_time = #{addTime}</if>
  38. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  39. and date_format(a.add_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  40. </if>
  41. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  42. AND date_format(a.add_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  43. </if>
  44. </where>
  45. </select>
  46. <select id="selectCompanyWxClientListCompany" resultType="com.fs.company.domain.CompanyWxClient">
  47. select a.*,b.wx_nick_name,c.name as dialogName,robotic.name roboticName from company_wx_client a
  48. inner join company_voice_robotic_wx wx on a.robotic_wx_id = wx.id
  49. inner join company_wx_account b on wx.account_id = b.id
  50. inner join company_user u on b.company_user_id = u.user_id
  51. inner join company_dept d on u.dept_id = d.dept_id
  52. inner join company_wx_dialog c on a.dialog_id = c.id
  53. inner join company_voice_robotic robotic on a.robotic_id = robotic.id
  54. <where>
  55. <if test="roboticId != null "> and a.robotic_id = #{roboticId}</if>
  56. <if test="roboticWxId != null "> and b.id = #{roboticWxId}</if>
  57. <if test="customerId != null "> and a.customer_id = #{customerId}</if>
  58. <if test="dialogId != null "> and a.dialog_id = #{dialogId}</if>
  59. <if test="nickName != null and nickName != ''"> and a.nick_name = #{nickName}</if>
  60. <if test="avatar != null and avatar != ''"> and a.avatar = #{avatar}</if>
  61. <if test="phone != null and phone != ''"> and a.phone = #{phone}</if>
  62. <if test="wxNo != null and wxNo != ''"> and a.wx_no = #{wxNo}</if>
  63. <if test="isAdd != null "> and a.is_add = #{isAdd}</if>
  64. <if test="addTime != null "> and a.add_time = #{addTime}</if>
  65. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  66. and date_format(a.add_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  67. </if>
  68. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  69. AND date_format(a.add_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  70. </if>
  71. ${params.dataScope}
  72. </where>
  73. </select>
  74. <select id="selectCompanyWxClientById" parameterType="Long" resultMap="CompanyWxClientResult">
  75. <include refid="selectCompanyWxClientVo"/>
  76. where id = #{id}
  77. </select>
  78. <insert id="insertCompanyWxClient" parameterType="CompanyWxClient" useGeneratedKeys="true" keyProperty="id">
  79. insert into company_wx_client
  80. <trim prefix="(" suffix=")" suffixOverrides=",">
  81. <if test="roboticWxId != null">robotic_wx_id,</if>
  82. <if test="nickName != null">nick_name,</if>
  83. <if test="avatar != null">avatar,</if>
  84. <if test="phone != null">phone,</if>
  85. <if test="wxNo != null">wx_no,</if>
  86. <if test="isAdd != null">is_add,</if>
  87. <if test="addTime != null">add_time,</if>
  88. <if test="remark != null">remark,</if>
  89. <if test="createTime != null">create_time,</if>
  90. </trim>
  91. <trim prefix="values (" suffix=")" suffixOverrides=",">
  92. <if test="roboticWxId != null">#{roboticWxId},</if>
  93. <if test="nickName != null">#{nickName},</if>
  94. <if test="avatar != null">#{avatar},</if>
  95. <if test="phone != null">#{phone},</if>
  96. <if test="wxNo != null">#{wxNo},</if>
  97. <if test="isAdd != null">#{isAdd},</if>
  98. <if test="addTime != null">#{addTime},</if>
  99. <if test="remark != null">#{remark},</if>
  100. <if test="createTime != null">#{createTime},</if>
  101. </trim>
  102. </insert>
  103. <update id="updateCompanyWxClient" parameterType="CompanyWxClient">
  104. update company_wx_client
  105. <trim prefix="SET" suffixOverrides=",">
  106. <if test="roboticWxId != null">robotic_wx_id = #{roboticWxId},</if>
  107. <if test="nickName != null">nick_name = #{nickName},</if>
  108. <if test="avatar != null">avatar = #{avatar},</if>
  109. <if test="phone != null">phone = #{phone},</if>
  110. <if test="wxNo != null">wx_no = #{wxNo},</if>
  111. <if test="isAdd != null">is_add = #{isAdd},</if>
  112. <if test="addTime != null">add_time = #{addTime},</if>
  113. <if test="remark != null">remark = #{remark},</if>
  114. <if test="createTime != null">create_time = #{createTime},</if>
  115. </trim>
  116. where id = #{id}
  117. </update>
  118. <delete id="deleteCompanyWxClientById" parameterType="Long">
  119. delete from company_wx_client where id = #{id}
  120. </delete>
  121. <delete id="deleteCompanyWxClientByIds" parameterType="String">
  122. delete from company_wx_client where id in
  123. <foreach item="id" collection="array" open="(" separator="," close=")">
  124. #{id}
  125. </foreach>
  126. </delete>
  127. <select id="toDayAddWxAccountList" resultType="com.fs.company.domain.CompanyWxClient">
  128. select a.*,b.wx_nick_name,c.name as dialogName,c.template_details,d.name roboticName from company_wx_client a
  129. inner join company_voice_robotic_wx wx on a.robotic_wx_id = wx.id
  130. inner join company_wx_account b on wx.account_id = b.id
  131. inner join company_wx_dialog c on a.dialog_id = c.id
  132. inner join company_voice_robotic d on a.robotic_id = d.id
  133. where b.id = #{accountId} and b.company_user_id = #{companyId} and a.is_add = #{addType}
  134. </select>
  135. <select id="selectCompanyByAccountId" resultType="com.fs.company.domain.CompanyUser">
  136. select c.* from company_voice_robotic_wx a
  137. inner join company_wx_account b on a.account_id = b.id
  138. inner join company_user c on b.company_user_id = c.user_id
  139. where a.id = #{wxId}
  140. </select>
  141. <select id="listCompanyIds" resultType="com.fs.company.domain.CompanyWxClient">
  142. select a.*,b.company_user_id from
  143. company_wx_client a
  144. inner join company_wx_account b on a.account_id = b.id
  145. where b.company_user_id in <foreach collection="ids" open="(" separator="," close=")" item="item">#{item}</foreach>
  146. </select>
  147. <select id="getAddWxList" resultType="com.fs.company.domain.CompanyWxClient">
  148. SELECT * FROM company_wx_client where is_add = 0 and account_id is not null
  149. <if test="accountIdList != null and !accountIdList.isEmpty()">
  150. and account_id in <foreach collection="accountIdList" open="(" separator="," close=")" item="item">#{item}</foreach>
  151. </if>
  152. group by account_id
  153. </select>
  154. <select id="selectWx" resultType="com.fs.company.domain.CompanyWxClient">
  155. select * from company_wx_client where account_id = #{accountId} and wx_v3 = #{v3}
  156. </select>
  157. <select id="selectListByRoboticId" resultType="com.fs.company.domain.CompanyWxClient">
  158. select * from company_wx_client where robotic_id = #{roboticId}
  159. </select>
  160. <select id="selectOneByRoboticIdAndUserId" resultType="com.fs.company.domain.CompanyWxClient">
  161. select * from company_wx_client where robotic_id = #{roboticId} and customer_id = #{customerId}
  162. </select>
  163. </mapper>