CmBaikeProductMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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.caimei.modules.baike.dao.CmBaikeProductDao">
  4. <sql id="cmBaikeProductColumns">
  5. a.id AS "id",
  6. a.commodityType AS "commodityType",
  7. a.name AS "name",
  8. a.alias AS "alias",
  9. a.discription AS "discription",
  10. a.image AS "image",
  11. a.advantage AS "advantage",
  12. a.disadvantage AS "disadvantage",
  13. a.principle AS "principle",
  14. a.brand AS "brand",
  15. a.producePlace AS "producePlace",
  16. a.marketTime AS "marketTime",
  17. a.company AS "company",
  18. a.nmpaTime AS "nmpaTime",
  19. a.adaptiveMan AS "adaptiveMan",
  20. a.unAdaptiveMan AS "unAdaptiveMan",
  21. a.aroundOperation AS "aroundOperation",
  22. a.publishTime AS "publishTime",
  23. a.basePv AS "basePv",
  24. a.actualPv AS "actualPv",
  25. a.typeId AS "typeId",
  26. a.topPosition AS "topPosition",
  27. a.status AS "status",
  28. a.addTime AS "addTime",
  29. cbt.name as "typeName"
  30. </sql>
  31. <sql id="cmBaikeProductJoins">
  32. left join cm_baike_type cbt on a.typeId = cbt.id
  33. </sql>
  34. <select id="get" resultType="CmBaikeProduct">
  35. SELECT
  36. <include refid="cmBaikeProductColumns"/>
  37. FROM cm_baike_product a
  38. <include refid="cmBaikeProductJoins"/>
  39. WHERE a.id = #{id}
  40. </select>
  41. <select id="findList" resultType="CmBaikeProduct">
  42. SELECT
  43. <include refid="cmBaikeProductColumns"/>
  44. FROM cm_baike_product a
  45. <include refid="cmBaikeProductJoins"/>
  46. <where>
  47. <if test="id != null and id != ''">
  48. AND a.id = #{id}
  49. </if>
  50. <if test="name != null and name != ''">
  51. AND a.name LIKE
  52. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  53. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  54. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  55. </if>
  56. <if test="typeId != null and typeId != ''">
  57. AND a.typeId = #{typeId}
  58. </if>
  59. <if test="topFlag != null">
  60. <choose>
  61. <when test='topFlag == 1'>
  62. and topPosition is not null and topPosition != ''
  63. </when>
  64. <when test='topFlag == 0'>
  65. and (topPosition is null or topPosition = '')
  66. </when>
  67. </choose>
  68. </if>
  69. <if test="status != null">
  70. AND a.status = #{status}
  71. </if>
  72. <if test="commodityType != null">
  73. and a.commodityType = #{commodityType}
  74. </if>
  75. </where>
  76. <choose>
  77. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  78. ORDER BY ${page.orderBy}
  79. </when>
  80. <otherwise>
  81. </otherwise>
  82. </choose>
  83. </select>
  84. <select id="findAllList" resultType="CmBaikeProduct">
  85. SELECT
  86. <include refid="cmBaikeProductColumns"/>
  87. FROM cm_baike_product a
  88. <include refid="cmBaikeProductJoins"/>
  89. <where>
  90. </where>
  91. <choose>
  92. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  93. ORDER BY ${page.orderBy}
  94. </when>
  95. <otherwise>
  96. </otherwise>
  97. </choose>
  98. </select>
  99. <select id="findParamList" resultType="com.caimei.modules.baike.entity.CmBaikeProductParam">
  100. select productId, name, content from cm_baike_product_param where productId = #{id}
  101. </select>
  102. <select id="findImageList" resultType="java.lang.String">
  103. select image from cm_baike_product_image where productId = #{productId} and type = #{imageType}
  104. </select>
  105. <select id="findQuestionList" resultType="com.caimei.modules.baike.entity.CmBaikeProductQuestion">
  106. select productId, question, answer
  107. from cm_baike_product_question
  108. where productId = #{id}
  109. </select>
  110. <select id="findTopLength" resultType="java.lang.Integer">
  111. select count(*) from cm_baike_product where topPosition is not null and topPosition != ''
  112. </select>
  113. <insert id="insert" parameterType="CmBaikeProduct" keyProperty="id" useGeneratedKeys="true">
  114. INSERT INTO cm_baike_product(
  115. commodityType,
  116. name,
  117. alias,
  118. discription,
  119. image,
  120. advantage,
  121. disadvantage,
  122. principle,
  123. brand,
  124. producePlace,
  125. marketTime,
  126. company,
  127. nmpaTime,
  128. adaptiveMan,
  129. unAdaptiveMan,
  130. aroundOperation,
  131. publishTime,
  132. basePv,
  133. actualPv,
  134. typeId,
  135. status,
  136. addTime
  137. ) VALUES (
  138. #{commodityType},
  139. #{name},
  140. #{alias},
  141. #{discription},
  142. #{image},
  143. #{advantage},
  144. #{disadvantage},
  145. #{principle},
  146. #{brand},
  147. #{producePlace},
  148. #{marketTime},
  149. #{company},
  150. #{nmpaTime},
  151. #{adaptiveMan},
  152. #{unAdaptiveMan},
  153. #{aroundOperation},
  154. #{publishTime},
  155. #{basePv},
  156. 0,
  157. #{typeId},
  158. #{status},
  159. NOW()
  160. )
  161. </insert>
  162. <insert id="insertProductImage">
  163. insert into cm_baike_product_image (productId, type, image)
  164. values (#{produtId}, #{imageType}, #{authImage})
  165. </insert>
  166. <insert id="insertProductParam">
  167. insert into cm_baike_product_param (productId, name, content)
  168. values (#{productId}, #{name}, #{content})
  169. </insert>
  170. <insert id="insertProductQuestion">
  171. insert into cm_baike_product_question (productId, question, answer)
  172. values (#{productId}, #{question}, #{answer})
  173. </insert>
  174. <update id="update">
  175. UPDATE cm_baike_product SET
  176. name = #{name},
  177. alias = #{alias},
  178. discription = #{discription},
  179. image = #{image},
  180. advantage = #{advantage},
  181. disadvantage = #{disadvantage},
  182. principle = #{principle},
  183. brand = #{brand},
  184. producePlace = #{producePlace},
  185. marketTime = #{marketTime},
  186. company = #{company},
  187. nmpaTime = #{nmpaTime},
  188. adaptiveMan = #{adaptiveMan},
  189. unAdaptiveMan = #{unAdaptiveMan},
  190. aroundOperation = #{aroundOperation},
  191. publishTime = #{publishTime},
  192. basePv = #{basePv},
  193. typeId = #{typeId},
  194. status = #{status}
  195. WHERE id = #{id}
  196. </update>
  197. <update id="updateStatus">
  198. update cm_baike_product set status = #{status} where id = #{productId}
  199. </update>
  200. <update id="updateTopPosition">
  201. update cm_baike_product set topPosition = #{topPosition} where id = #{id}
  202. </update>
  203. <delete id="delete">
  204. DELETE FROM cm_baike_product
  205. WHERE id = #{id}
  206. </delete>
  207. <delete id="deleteParamsByProductId">
  208. delete from cm_baike_product_param where productId = #{id}
  209. </delete>
  210. <delete id="deleteImagesByProductId">
  211. delete from cm_baike_product_image where productId = #{id}
  212. </delete>
  213. <delete id="deleteQuestionsByProductId">
  214. delete from cm_baike_product_question where productId = #{id}
  215. </delete>
  216. </mapper>