JtCommodityCommentMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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.JtCommodityCommentMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.JtCommodityComment">
  5. <!--
  6. WARNING - @mbg.generated
  7. This element is automatically generated by MyBatis Generator, do not modify.
  8. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  9. -->
  10. <id column="id" jdbcType="VARCHAR" property="id" />
  11. <result column="commodity_id" jdbcType="VARCHAR" property="commodityId" />
  12. <result column="uid" jdbcType="VARCHAR" property="uid" />
  13. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  14. <result column="content" jdbcType="VARCHAR" property="content" />
  15. <result column="star" jdbcType="INTEGER" property="star" />
  16. <result column="ip" jdbcType="VARCHAR" property="ip" />
  17. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  18. <result column="commodity_type" jdbcType="INTEGER" property="commodityType" />
  19. </resultMap>
  20. <sql id="Example_Where_Clause">
  21. <!--
  22. WARNING - @mbg.generated
  23. This element is automatically generated by MyBatis Generator, do not modify.
  24. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  25. -->
  26. <where>
  27. <foreach collection="oredCriteria" item="criteria" separator="or">
  28. <if test="criteria.valid">
  29. <trim prefix="(" prefixOverrides="and" suffix=")">
  30. <foreach collection="criteria.criteria" item="criterion">
  31. <choose>
  32. <when test="criterion.noValue">
  33. and ${criterion.condition}
  34. </when>
  35. <when test="criterion.singleValue">
  36. and ${criterion.condition} #{criterion.value}
  37. </when>
  38. <when test="criterion.betweenValue">
  39. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  40. </when>
  41. <when test="criterion.listValue">
  42. and ${criterion.condition}
  43. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  44. #{listItem}
  45. </foreach>
  46. </when>
  47. </choose>
  48. </foreach>
  49. </trim>
  50. </if>
  51. </foreach>
  52. </where>
  53. </sql>
  54. <sql id="Update_By_Example_Where_Clause">
  55. <!--
  56. WARNING - @mbg.generated
  57. This element is automatically generated by MyBatis Generator, do not modify.
  58. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  59. -->
  60. <where>
  61. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  62. <if test="criteria.valid">
  63. <trim prefix="(" prefixOverrides="and" suffix=")">
  64. <foreach collection="criteria.criteria" item="criterion">
  65. <choose>
  66. <when test="criterion.noValue">
  67. and ${criterion.condition}
  68. </when>
  69. <when test="criterion.singleValue">
  70. and ${criterion.condition} #{criterion.value}
  71. </when>
  72. <when test="criterion.betweenValue">
  73. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  74. </when>
  75. <when test="criterion.listValue">
  76. and ${criterion.condition}
  77. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  78. #{listItem}
  79. </foreach>
  80. </when>
  81. </choose>
  82. </foreach>
  83. </trim>
  84. </if>
  85. </foreach>
  86. </where>
  87. </sql>
  88. <sql id="Base_Column_List">
  89. <!--
  90. WARNING - @mbg.generated
  91. This element is automatically generated by MyBatis Generator, do not modify.
  92. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  93. -->
  94. id, commodity_id, uid, order_no, content, star, ip, create_time, commodity_type
  95. </sql>
  96. <select id="selectByExample" parameterType="com.goafanti.common.model.JtCommodityCommentExample" resultMap="BaseResultMap">
  97. <!--
  98. WARNING - @mbg.generated
  99. This element is automatically generated by MyBatis Generator, do not modify.
  100. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  101. -->
  102. select
  103. <if test="distinct">
  104. distinct
  105. </if>
  106. <include refid="Base_Column_List" />
  107. from jt_commodity_comment
  108. <if test="_parameter != null">
  109. <include refid="Example_Where_Clause" />
  110. </if>
  111. <if test="orderByClause != null">
  112. order by ${orderByClause}
  113. </if>
  114. </select>
  115. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  116. <!--
  117. WARNING - @mbg.generated
  118. This element is automatically generated by MyBatis Generator, do not modify.
  119. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  120. -->
  121. select
  122. <include refid="Base_Column_List" />
  123. from jt_commodity_comment
  124. where id = #{id,jdbcType=VARCHAR}
  125. </select>
  126. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  127. <!--
  128. WARNING - @mbg.generated
  129. This element is automatically generated by MyBatis Generator, do not modify.
  130. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  131. -->
  132. delete from jt_commodity_comment
  133. where id = #{id,jdbcType=VARCHAR}
  134. </delete>
  135. <delete id="deleteByExample" parameterType="com.goafanti.common.model.JtCommodityCommentExample">
  136. <!--
  137. WARNING - @mbg.generated
  138. This element is automatically generated by MyBatis Generator, do not modify.
  139. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  140. -->
  141. delete from jt_commodity_comment
  142. <if test="_parameter != null">
  143. <include refid="Example_Where_Clause" />
  144. </if>
  145. </delete>
  146. <insert id="insert" parameterType="com.goafanti.common.model.JtCommodityComment">
  147. <!--
  148. WARNING - @mbg.generated
  149. This element is automatically generated by MyBatis Generator, do not modify.
  150. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  151. -->
  152. insert into jt_commodity_comment (id, commodity_id, uid,
  153. order_no, content, star,
  154. ip, create_time, commodity_type)
  155. values (#{id,jdbcType=VARCHAR}, #{commodityId,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR},
  156. #{orderNo,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{star,jdbcType=INTEGER},
  157. #{ip,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{commodityType,jdbcType=INTEGER})
  158. </insert>
  159. <insert id="insertSelective" parameterType="com.goafanti.common.model.JtCommodityComment">
  160. <!--
  161. WARNING - @mbg.generated
  162. This element is automatically generated by MyBatis Generator, do not modify.
  163. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  164. -->
  165. insert into jt_commodity_comment
  166. <trim prefix="(" suffix=")" suffixOverrides=",">
  167. <if test="id != null">
  168. id,
  169. </if>
  170. <if test="commodityId != null">
  171. commodity_id,
  172. </if>
  173. <if test="uid != null">
  174. uid,
  175. </if>
  176. <if test="orderNo != null">
  177. order_no,
  178. </if>
  179. <if test="content != null">
  180. content,
  181. </if>
  182. <if test="star != null">
  183. star,
  184. </if>
  185. <if test="ip != null">
  186. ip,
  187. </if>
  188. <if test="createTime != null">
  189. create_time,
  190. </if>
  191. <if test="commodityType != null">
  192. commodity_type,
  193. </if>
  194. </trim>
  195. <trim prefix="values (" suffix=")" suffixOverrides=",">
  196. <if test="id != null">
  197. #{id,jdbcType=VARCHAR},
  198. </if>
  199. <if test="commodityId != null">
  200. #{commodityId,jdbcType=VARCHAR},
  201. </if>
  202. <if test="uid != null">
  203. #{uid,jdbcType=VARCHAR},
  204. </if>
  205. <if test="orderNo != null">
  206. #{orderNo,jdbcType=VARCHAR},
  207. </if>
  208. <if test="content != null">
  209. #{content,jdbcType=VARCHAR},
  210. </if>
  211. <if test="star != null">
  212. #{star,jdbcType=INTEGER},
  213. </if>
  214. <if test="ip != null">
  215. #{ip,jdbcType=VARCHAR},
  216. </if>
  217. <if test="createTime != null">
  218. #{createTime,jdbcType=TIMESTAMP},
  219. </if>
  220. <if test="commodityType != null">
  221. #{commodityType,jdbcType=INTEGER},
  222. </if>
  223. </trim>
  224. </insert>
  225. <select id="countByExample" parameterType="com.goafanti.common.model.JtCommodityCommentExample" resultType="java.lang.Long">
  226. <!--
  227. WARNING - @mbg.generated
  228. This element is automatically generated by MyBatis Generator, do not modify.
  229. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  230. -->
  231. select count(*) from jt_commodity_comment
  232. <if test="_parameter != null">
  233. <include refid="Example_Where_Clause" />
  234. </if>
  235. </select>
  236. <update id="updateByExampleSelective" parameterType="map">
  237. <!--
  238. WARNING - @mbg.generated
  239. This element is automatically generated by MyBatis Generator, do not modify.
  240. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  241. -->
  242. update jt_commodity_comment
  243. <set>
  244. <if test="record.id != null">
  245. id = #{record.id,jdbcType=VARCHAR},
  246. </if>
  247. <if test="record.commodityId != null">
  248. commodity_id = #{record.commodityId,jdbcType=VARCHAR},
  249. </if>
  250. <if test="record.uid != null">
  251. uid = #{record.uid,jdbcType=VARCHAR},
  252. </if>
  253. <if test="record.orderNo != null">
  254. order_no = #{record.orderNo,jdbcType=VARCHAR},
  255. </if>
  256. <if test="record.content != null">
  257. content = #{record.content,jdbcType=VARCHAR},
  258. </if>
  259. <if test="record.star != null">
  260. star = #{record.star,jdbcType=INTEGER},
  261. </if>
  262. <if test="record.ip != null">
  263. ip = #{record.ip,jdbcType=VARCHAR},
  264. </if>
  265. <if test="record.createTime != null">
  266. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  267. </if>
  268. <if test="record.commodityType != null">
  269. commodity_type = #{record.commodityType,jdbcType=INTEGER},
  270. </if>
  271. </set>
  272. <if test="_parameter != null">
  273. <include refid="Update_By_Example_Where_Clause" />
  274. </if>
  275. </update>
  276. <update id="updateByExample" parameterType="map">
  277. <!--
  278. WARNING - @mbg.generated
  279. This element is automatically generated by MyBatis Generator, do not modify.
  280. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  281. -->
  282. update jt_commodity_comment
  283. set id = #{record.id,jdbcType=VARCHAR},
  284. commodity_id = #{record.commodityId,jdbcType=VARCHAR},
  285. uid = #{record.uid,jdbcType=VARCHAR},
  286. order_no = #{record.orderNo,jdbcType=VARCHAR},
  287. content = #{record.content,jdbcType=VARCHAR},
  288. star = #{record.star,jdbcType=INTEGER},
  289. ip = #{record.ip,jdbcType=VARCHAR},
  290. create_time = #{record.createTime,jdbcType=TIMESTAMP},
  291. commodity_type = #{record.commodityType,jdbcType=INTEGER}
  292. <if test="_parameter != null">
  293. <include refid="Update_By_Example_Where_Clause" />
  294. </if>
  295. </update>
  296. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.JtCommodityComment">
  297. <!--
  298. WARNING - @mbg.generated
  299. This element is automatically generated by MyBatis Generator, do not modify.
  300. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  301. -->
  302. update jt_commodity_comment
  303. <set>
  304. <if test="commodityId != null">
  305. commodity_id = #{commodityId,jdbcType=VARCHAR},
  306. </if>
  307. <if test="uid != null">
  308. uid = #{uid,jdbcType=VARCHAR},
  309. </if>
  310. <if test="orderNo != null">
  311. order_no = #{orderNo,jdbcType=VARCHAR},
  312. </if>
  313. <if test="content != null">
  314. content = #{content,jdbcType=VARCHAR},
  315. </if>
  316. <if test="star != null">
  317. star = #{star,jdbcType=INTEGER},
  318. </if>
  319. <if test="ip != null">
  320. ip = #{ip,jdbcType=VARCHAR},
  321. </if>
  322. <if test="createTime != null">
  323. create_time = #{createTime,jdbcType=TIMESTAMP},
  324. </if>
  325. <if test="commodityType != null">
  326. commodity_type = #{commodityType,jdbcType=INTEGER},
  327. </if>
  328. </set>
  329. where id = #{id,jdbcType=VARCHAR}
  330. </update>
  331. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.JtCommodityComment">
  332. <!--
  333. WARNING - @mbg.generated
  334. This element is automatically generated by MyBatis Generator, do not modify.
  335. This element was generated on Thu Jul 19 10:59:39 CST 2018.
  336. -->
  337. update jt_commodity_comment
  338. set commodity_id = #{commodityId,jdbcType=VARCHAR},
  339. uid = #{uid,jdbcType=VARCHAR},
  340. order_no = #{orderNo,jdbcType=VARCHAR},
  341. content = #{content,jdbcType=VARCHAR},
  342. star = #{star,jdbcType=INTEGER},
  343. ip = #{ip,jdbcType=VARCHAR},
  344. create_time = #{createTime,jdbcType=TIMESTAMP},
  345. commodity_type = #{commodityType,jdbcType=INTEGER}
  346. where id = #{id,jdbcType=VARCHAR}
  347. </update>
  348. <select id="getCommentCount" resultType="java.lang.Integer">
  349. select count(0) from jt_commodity_comment
  350. where commodity_id=#{1}
  351. and ((#{0}=0 and (star =4 or star=5)) or (#{0}=1 and (star = 3)) or (#{0} =2 and (star=1 or star=2)) )
  352. </select>
  353. <select id="searchCommentByCommodityId" resultType="com.goafanti.comment.bo.CommentDetailResult">
  354. select jcc.create_time as createTime,
  355. date_format(jcc.create_time,'%Y-%m-%d') as createTimeFormat,
  356. jcc.content,jcc.star,u.identify_name as commenter
  357. from jt_commodity_comment jcc
  358. left join user u on jcc.uid=u.id
  359. where jcc.commodity_id=#{commodityId,jdbcType=VARCHAR}
  360. order by jcc.create_time desc
  361. <if test="page_sql!=null">
  362. ${page_sql}
  363. </if>
  364. </select>
  365. <select id="searchCommentCountByCommodityId" resultType="java.lang.Integer">
  366. select count(0)
  367. from jt_commodity_comment jcc
  368. left join user u on jcc.uid=u.id
  369. where jcc.commodity_id=#{commodityId,jdbcType=VARCHAR}
  370. </select>
  371. <select id="selectByProjectId" resultType="com.goafanti.comment.bo.CommentDetailResult">
  372. select jcc.create_time as createTime,
  373. date_format(jcc.create_time,'%Y-%m-%d') as createTimeFormat,
  374. jcc.commodity_id,
  375. jcc.content,jcc.star,u.identify_name as commenter
  376. from jt_commodity_comment jcc
  377. left join user u on jcc.uid=u.id
  378. where jcc.commodity_id=#{id,jdbcType=VARCHAR}
  379. order by jcc.create_time desc limit 1
  380. </select>
  381. <select id="selectExpertsCommentList" resultType="com.goafanti.comment.bo.CommentDetailResult">
  382. select a.create_time as createTime,
  383. date_format(a.create_time,'%Y-%m-%d') as createTimeFormat,
  384. a.commodity_id,
  385. a.content,a.star,u.identify_name as commenter
  386. from jt_commodity_comment a
  387. left join user u on a.uid=u.id
  388. left join jt_consult_order b on a.order_no=b.order_no
  389. where 1=1
  390. and b.seller_id= #{id,jdbcType=VARCHAR}
  391. order by a.create_time desc
  392. <if test="page_sql!=null">
  393. ${page_sql}
  394. </if>
  395. </select>
  396. <select id="selectExpertsCommentCount" resultType="java.lang.Integer">
  397. select count(*)
  398. from jt_commodity_comment a
  399. left join jt_consult_order b on a.order_no=b.order_no
  400. where 1=1
  401. and b.seller_id= #{id,jdbcType=VARCHAR}
  402. </select>
  403. <!-- 查看某ip的uid -->
  404. <select id="getUidByIp" resultType="java.lang.String">
  405. select distinct uid from jt_commodity_comment where ip = #{0} and uid like '游客%' limit 1
  406. </select>
  407. <!-- 获得以游客开头的最大uid -->
  408. <select id="getMaxNameUid" resultType="java.lang.String">
  409. select max(substring(uid,3)) from jt_commodity_comment where uid like '游客%'
  410. </select>
  411. <!-- 未登录用户获得评价 -->
  412. <select id="searchUnlandedCommentByCommodityId" resultType="com.goafanti.comment.bo.CommentDetailResult">
  413. select jcc.create_time as createTime,
  414. date_format(jcc.create_time,'%Y-%m-%d') as createTimeFormat,
  415. jcc.content,jcc.star,IFNULL(LPAD(right(u.identify_name,1),(CHAR_LENGTH(u.identify_name)),'*'), jcc.uid) as uname
  416. from jt_commodity_comment jcc
  417. left join user u on jcc.uid=u.id
  418. where jcc.commodity_id=#{commodityId,jdbcType=VARCHAR}
  419. order by jcc.create_time desc
  420. <if test="page_sql!=null">
  421. ${page_sql}
  422. </if>
  423. </select>
  424. </mapper>