TbCollectionMapperCust.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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.fdage.dao.cust.TbCollectionMapperCust">
  4. <select id="timeList" resultType="com.fdage.pojo.TbCollectionTime">
  5. select id, name
  6. from tb_collection_time
  7. order by order_num
  8. </select>
  9. <select id="typeList" resultType="com.fdage.pojo.TbCollectionType">
  10. select id, name
  11. from tb_collection_type
  12. WHERE 1 = 1
  13. <if test="state != null">
  14. and state = #{state}
  15. </if>
  16. </select>
  17. <select id="findList" parameterType="com.fdage.request.RequestCollection" resultType="com.fdage.respon.ResponCollection">
  18. select a.id, a.name, a.type_id as typeId, a.time_id as timeId, a.discovery_time as discoveryTime,
  19. a.repair_time as repairTime, a.venue, a.model_url as modelUrl, a.content_url as contentUrl, a.state,
  20. a.create_time as createTime, a.description, b.name as timeName, c.name as typeName, a.pic, a.num,
  21. a.like_num as likeNum, a.open_num as openNum, a.search_num as searchNum, download_num as downloadNum,
  22. a.unity_pic as unityPic, a.unity_url as unityUrl, a.icon, a.dir_code as dirCode, a.type, a.url_list, a.qr_code
  23. from tb_collection a LEFT JOIN tb_collection_time b on a.time_id = b.id
  24. LEFT JOIN tb_collection_type c ON a.type_id = c.id
  25. WHERE 1 = 1
  26. <if test="typeId != null">
  27. and a.type_id = #{typeId}
  28. </if>
  29. <if test="timeId != null">
  30. and a.time_id = #{timeId}
  31. </if>
  32. <if test="name != null and name != ''">
  33. and a.name LIKE CONCAT('%', #{name}, '%')
  34. </if>
  35. <if test="state != null">
  36. and a.state = #{state}
  37. </if>
  38. </select>
  39. <select id="findListByExhibitionId" parameterType="java.lang.Long" resultType="com.fdage.respon.ResponCollection">
  40. select a.id, a.name, a.type_id as typeId, a.time_id as timeId, a.discovery_time as discoveryTime,
  41. a.repair_time as repairTime, a.venue, a.model_url as modelUrl, a.content_url as contentUrl, a.state,
  42. a.create_time as createTime, a.description, b.name as timeName, c.name as typeName, a.pic, a.num,
  43. a.like_num as likeNum, a.open_num as openNum, a.search_num as searchNum, download_num as downloadNum,
  44. a.unity_pic as unityPic, a.unity_url as unityUrl, a.type, a.url_list, a.qr_code
  45. from tb_collection a LEFT JOIN tb_collection_time b on a.time_id = b.id
  46. LEFT JOIN tb_collection_type c ON a.type_id = c.id
  47. LEFT JOIN tb_exhibition_collection d ON a.id = d.collection_id
  48. WHERE d.exhibition_id = #{id}
  49. </select>
  50. <select id="searchListByName" parameterType="com.fdage.request.RequestCollection" resultType="com.fdage.respon.ResponCollection">
  51. select a.id, a.name, a.type_id as typeId, a.time_id as timeId, a.discovery_time as discoveryTime,
  52. a.repair_time as repairTime, a.venue, a.model_url as modelUrl, a.content_url as contentUrl, a.state,
  53. a.create_time as createTime, a.description, b.name as timeName, c.name as typeName, a.pic, a.num,
  54. a.like_num as likeNum, a.open_num as openNum, a.search_num as searchNum, download_num as downloadNum,
  55. a.unity_pic as unityPic, a.unity_url as unityUrl, a.type, a.url_list, a.qr_code
  56. from tb_collection a LEFT JOIN tb_collection_time b on a.time_id = b.id
  57. LEFT JOIN tb_collection_type c ON a.type_id = c.id
  58. WHERE 1 = 1
  59. <if test="name != null and name != ''">
  60. and a.name LIKE CONCAT('%', #{name}, '%')
  61. </if>
  62. <if test="typeId != null and typeId != ''">
  63. and a.type_id = #{typeId}
  64. </if>
  65. </select>
  66. <update id="addLikeNumById" parameterType="java.lang.Long">
  67. UPDATE tb_collection SET like_num = like_num + 1 WHERE id = #{id}
  68. </update>
  69. <update id="addOpenNumById" parameterType="java.lang.Long">
  70. UPDATE tb_collection SET open_num = open_num + 1 WHERE id = #{id}
  71. </update>
  72. <update id="addSearchNumById" parameterType="java.lang.Long">
  73. UPDATE tb_collection SET search_num = search_num + 1 WHERE id = #{id}
  74. </update>
  75. <update id="addDownloadNumById" parameterType="java.lang.Long">
  76. UPDATE tb_collection SET download_num = download_num + 1 WHERE id = #{id}
  77. </update>
  78. <select id="findByName" parameterType="java.lang.String" resultMap="com.fdage.dao.base.TbCollectionMapper.BaseResultMap">
  79. select
  80. <include refid="com.fdage.dao.base.TbCollectionMapper.Base_Column_List" />
  81. ,
  82. <include refid="com.fdage.dao.base.TbCollectionMapper.Blob_Column_List" />
  83. from tb_collection
  84. where name = #{name}
  85. </select>
  86. <select id="collectionTotal" resultType="com.fdage.respon.ResponStatistics">
  87. SELECT COUNT(*) AS total, SUM(like_num) AS likeTotal, SUM(download_num) AS downloadNum
  88. FROM `tb_collection`
  89. </select>
  90. <select id="findListOrderBy" parameterType="List" resultType="com.fdage.respon.ResponCollection">
  91. select a.id, a.name, a.type_id as typeId, a.time_id as timeId, a.discovery_time as discoveryTime,
  92. a.repair_time as repairTime, a.venue, a.model_url as modelUrl, a.content_url as contentUrl, a.state,
  93. a.create_time as createTime, a.description, b.name as timeName, c.name as typeName, a.pic, a.num,
  94. a.like_num as likeNum, a.open_num as openNum, a.search_num as searchNum, download_num as downloadNum,
  95. a.unity_pic as unityPic, a.unity_url as unityUrl, a.type, a.url_list, a.qr_code
  96. from tb_collection a LEFT JOIN tb_collection_time b on a.time_id = b.id
  97. LEFT JOIN tb_collection_type c ON a.type_id = c.id
  98. WHERE 1 = 1
  99. <choose>
  100. <when test="sidx != null and sidx.trim() != ''">
  101. order by ${sidx} ${order}
  102. </when>
  103. <otherwise>
  104. order by a.id desc
  105. </otherwise>
  106. </choose>
  107. </select>
  108. <select id="typeTotal" resultType="Map">
  109. SELECT SUM(a.type_id) AS typeNum, b.name AS typeName
  110. FROM `tb_collection` a LEFT JOIN `tb_collection_type` b ON a.type_id = b.id
  111. GROUP BY a.type_id
  112. </select>
  113. </mapper>