UserInterestMapper.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.goafanti.common.dao.UserInterestMapper" >
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.UserInterest" >
  5. <id column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="from_uid" property="fromUid" jdbcType="VARCHAR" />
  7. <result column="to_uid" property="toUid" jdbcType="VARCHAR" />
  8. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  9. </resultMap>
  10. <sql id="Base_Column_List" >
  11. id, from_uid, to_uid, create_time
  12. </sql>
  13. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  14. select
  15. <include refid="Base_Column_List" />
  16. from user_interest
  17. where id = #{id,jdbcType=VARCHAR}
  18. </select>
  19. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  20. delete from user_interest
  21. where id = #{id,jdbcType=VARCHAR}
  22. </delete>
  23. <insert id="insert" parameterType="com.goafanti.common.model.UserInterest" >
  24. insert into user_interest (id, from_uid, to_uid,
  25. create_time)
  26. values (#{id,jdbcType=VARCHAR}, #{fromUid,jdbcType=VARCHAR}, #{toUid,jdbcType=VARCHAR},
  27. #{createTime,jdbcType=TIMESTAMP})
  28. </insert>
  29. <insert id="insertSelective" parameterType="com.goafanti.common.model.UserInterest" >
  30. insert into user_interest
  31. <trim prefix="(" suffix=")" suffixOverrides="," >
  32. <if test="id != null" >
  33. id,
  34. </if>
  35. <if test="fromUid != null" >
  36. from_uid,
  37. </if>
  38. <if test="toUid != null" >
  39. to_uid,
  40. </if>
  41. <if test="createTime != null" >
  42. create_time,
  43. </if>
  44. </trim>
  45. <trim prefix="values (" suffix=")" suffixOverrides="," >
  46. <if test="id != null" >
  47. #{id,jdbcType=VARCHAR},
  48. </if>
  49. <if test="fromUid != null" >
  50. #{fromUid,jdbcType=VARCHAR},
  51. </if>
  52. <if test="toUid != null" >
  53. #{toUid,jdbcType=VARCHAR},
  54. </if>
  55. <if test="createTime != null" >
  56. #{createTime,jdbcType=TIMESTAMP},
  57. </if>
  58. </trim>
  59. </insert>
  60. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.UserInterest" >
  61. update user_interest
  62. <set >
  63. <if test="fromUid != null" >
  64. from_uid = #{fromUid,jdbcType=VARCHAR},
  65. </if>
  66. <if test="toUid != null" >
  67. to_uid = #{toUid,jdbcType=VARCHAR},
  68. </if>
  69. <if test="createTime != null" >
  70. create_time = #{createTime,jdbcType=TIMESTAMP},
  71. </if>
  72. </set>
  73. where id = #{id,jdbcType=VARCHAR}
  74. </update>
  75. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.UserInterest" >
  76. update user_interest
  77. set from_uid = #{fromUid,jdbcType=VARCHAR},
  78. to_uid = #{toUid,jdbcType=VARCHAR},
  79. create_time = #{createTime,jdbcType=TIMESTAMP}
  80. where id = #{id,jdbcType=VARCHAR}
  81. </update>
  82. <select id="findByFromUidAndToUid" resultMap="BaseResultMap">
  83. select
  84. <include refid="Base_Column_List" />
  85. from user_interest
  86. where from_uid = #{fromUid,jdbcType=VARCHAR}
  87. and to_uid = #{toUid,jdbcType=VARCHAR}
  88. </select>
  89. <select id="findInterestUserListByPage" parameterType="java.lang.String" resultType="com.goafanti.user.bo.InterestUserListBo">
  90. SELECT
  91. uii.username,
  92. oi.unit_name AS unitName,
  93. u.number,
  94. u.type,
  95. u.id AS uid,
  96. ui.id AS interestId,
  97. ui.create_time AS createTime,
  98. uii.province AS userProvince,
  99. oi.licence_province AS orgProvince,
  100. u.head_portrait_url AS personPortraitUrl,
  101. oinfo.logo_url AS logoUrl,
  102. adc.achievement_count AS achievementNum,
  103. adc.demand_count AS demandNum
  104. FROM
  105. user_interest ui
  106. LEFT JOIN user_identity uii ON uii.uid = ui.to_uid
  107. LEFT JOIN organization_identity oi ON oi.uid = ui.to_uid
  108. LEFT JOIN `user` u ON u.id = ui.to_uid
  109. <!-- LEFT JOIN user_info uinfo ON uinfo.uid = ui.to_uid -->
  110. LEFT JOIN organization_info oinfo ON oinfo.uid = ui.to_uid
  111. LEFT JOIN achievement_demand_count adc ON adc.uid = ui.to_uid
  112. WHERE
  113. ui.from_uid = #{fromUid,jdbcType=VARCHAR}
  114. <if test="userType != null" >
  115. and u.type = #{userType}
  116. </if>
  117. ORDER BY
  118. ui.create_time DESC
  119. <if test="page_sql!=null">
  120. ${page_sql}
  121. </if>
  122. </select>
  123. <select id="findInterestUserCount" resultType="java.lang.Integer" parameterType="java.lang.String">
  124. SELECT
  125. count(1)
  126. FROM
  127. user_interest ui
  128. LEFT JOIN `user` u ON u.id = ui.to_uid
  129. WHERE
  130. ui.from_uid = #{fromUid,jdbcType=VARCHAR}
  131. <if test="userType != null" >
  132. and u.type = #{userType}
  133. </if>
  134. </select>
  135. <select id="countByToUid" parameterType="java.lang.String" resultType="java.lang.Integer">
  136. select
  137. count(1)
  138. from user_interest
  139. where to_uid = #{toUid,jdbcType=VARCHAR}
  140. </select>
  141. </mapper>