DcProductMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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.gqy.document.mapper.DcProductMapper">
  6. <resultMap type="DcProduct" id="DcProductResult">
  7. <id property="dcp_id" column="dcp_id" />
  8. <result property="dcp_name" column="dcp_name" />
  9. <result property="dcp_model" column="dcp_model" />
  10. <result property="dcp_diff" column="dcp_diff" />
  11. <result property="dcp_p_no" column="dcp_p_no" />
  12. <result property="dcp_status" column="dcp_status" />
  13. <result property="dcp_price1" column="dcp_price1" />
  14. <result property="dcp_price2" column="dcp_price2" />
  15. <result property="dcp_price3" column="dcp_price3" />
  16. <result property="dcp_price4" column="dcp_price4" />
  17. <result property="dcp_cost_price" column="dcp_cost_price" />
  18. <result property="dcm_id" column="dcm_id" />
  19. <result property="dcp_oa_code" column="dcp_oa_code" />
  20. </resultMap>
  21. <sql id="selectDcProductVo">
  22. select dcp_id,dcp_name,dcp_model,dcp_diff,dcp_p_no,dcp_status,dcp_price1,dcp_price2,dcp_price3,dcp_price4,dcp_cost_price,dcm_id,dcp_oa_code
  23. from dc_product
  24. </sql>
  25. <!-- 先查询所有规格参数名称 -->
  26. <select id="selectAllParamNames" resultType="string">
  27. SELECT DISTINCT psp_name
  28. FROM dc_ps_param
  29. ORDER BY psp_name
  30. </select>
  31. <!-- 动态构建SQL的查询 -->
  32. <select id="selectProductBaseList" parameterType="map" resultType="java.util.Map">
  33. SELECT
  34. p.dcp_oa_code,
  35. p.dcp_p_no,
  36. p.dcp_name,
  37. p.dcp_model,
  38. p.dcp_id
  39. <!-- <if test="paramNames != null and paramNames.size() > 0">-->
  40. <!-- ,<foreach item="paramName" collection="paramNames" separator=",">-->
  41. <!-- COALESCE(MAX(CASE WHEN param.psp_name = #{paramName}-->
  42. <!-- THEN param.psp_input_value END), '') as "${paramName}"-->
  43. <!-- </foreach>-->
  44. <!-- </if>-->
  45. FROM
  46. dc_product p
  47. LEFT JOIN dc_p_spec spec ON p.dcp_id = spec.ps_p_id
  48. LEFT JOIN dc_ps_param param ON spec.ps_no = param.psp_mode
  49. <where>
  50. <if test="dcp_oa_code != null and dcp_oa_code != ''">
  51. AND p.dcp_oa_code like concat('%', #{dcp_oa_code}, '%')
  52. </if>
  53. <if test="dcp_p_no != null and dcp_p_no != ''">
  54. AND p.dcp_p_no like concat('%', #{dcp_p_no}, '%')
  55. </if>
  56. <if test="dcp_name != null and dcp_name != ''">
  57. AND p.dcp_name like concat('%', #{dcp_name}, '%')
  58. </if>
  59. <if test="dcp_model != null and dcp_model != ''">
  60. AND p.dcp_model like concat('%', #{dcp_model}, '%')
  61. </if>
  62. </where>
  63. GROUP BY p.dcp_id, p.dcp_oa_code, p.dcp_p_no, p.dcp_name, p.dcp_model ORDER BY p.dcp_id desc
  64. </select>
  65. <select id="selectDcProductList" parameterType="DcProduct" resultMap="DcProductResult">
  66. <include refid="selectDcProductVo"/>
  67. <where>
  68. <if test="dcp_name != null and dcp_name != ''">
  69. AND dcp_name like concat('%', #{dcp_name}, '%')
  70. </if>
  71. <if test="dcp_model != null and dcp_model != ''">
  72. AND dcp_model = #{dcp_model}
  73. </if>
  74. <if test="dcp_diff != null and dcp_diff != ''">
  75. AND dcp_diff = #{dcp_diff}
  76. </if>
  77. <if test="dcp_p_no != null and dcp_p_no != ''">
  78. AND dcp_p_no = #{dcp_p_no}
  79. </if>
  80. <if test="dcp_status != null ">
  81. AND dcp_status = #{dcp_status}
  82. </if>
  83. <if test="dcp_oa_code != null and dcp_oa_code != ''">
  84. AND dcp_oa_code = #{dcp_oa_code}
  85. </if>
  86. </where>
  87. </select>
  88. <select id="selectDcProductById" parameterType="Long" resultMap="DcProductResult">
  89. <include refid="selectDcProductVo"/>
  90. where dcp_id = #{dcp_id}
  91. </select>
  92. <insert id="insertDcProduct" parameterType="DcProduct" useGeneratedKeys="true" keyProperty="dcp_id">
  93. insert into dc_product
  94. <trim prefix="(" suffix=")" suffixOverrides=",">
  95. <if test="dcp_name != null">dcp_name,</if>
  96. <if test="dcp_model != null">dcp_model,</if>
  97. <if test="dcp_diff != null">dcp_diff,</if>
  98. <if test="dcp_p_no != null">dcp_p_no,</if>
  99. <if test="dcp_status != null">dcp_status,</if>
  100. <if test="dcp_price1 != null">dcp_price1,</if>
  101. <if test="dcp_price2 != null">dcp_price2,</if>
  102. <if test="dcp_price3 != null">dcp_price3,</if>
  103. <if test="dcp_price4 != null">dcp_price4,</if>
  104. <if test="dcp_cost_price != null">dcp_cost_price,</if>
  105. <if test="dcm_id != null">dcm_id,</if>
  106. <if test="dcp_oa_code != null">dcp_oa_code,</if>
  107. </trim>
  108. <trim prefix="values (" suffix=")" suffixOverrides=",">
  109. <if test="dcp_name != null">#{dcp_name},</if>
  110. <if test="dcp_model != null">#{dcp_model},</if>
  111. <if test="dcp_diff != null">#{dcp_diff},</if>
  112. <if test="dcp_p_no != null">#{dcp_p_no},</if>
  113. <if test="dcp_status != null">#{dcp_status},</if>
  114. <if test="dcp_price1 != null">#{dcp_price1},</if>
  115. <if test="dcp_price2 != null">#{dcp_price2},</if>
  116. <if test="dcp_price3 != null">#{dcp_price3},</if>
  117. <if test="dcp_price4 != null">#{dcp_price4},</if>
  118. <if test="dcp_cost_price != null">#{dcp_cost_price},</if>
  119. <if test="dcm_id != null">#{dcm_id},</if>
  120. <if test="dcp_oa_code != null">#{dcp_oa_code},</if>
  121. </trim>
  122. </insert>
  123. <update id="updateDcProduct" parameterType="DcProduct">
  124. update dc_product
  125. <trim prefix="SET" suffixOverrides=",">
  126. <if test="dcp_name != null and dcp_name != ''">dcp_name = #{dcp_name},</if>
  127. <if test="dcp_model != null and dcp_model != ''">dcp_model = #{dcp_model},</if>
  128. <if test="dcp_diff != null and dcp_diff != ''">dcp_diff = #{dcp_diff},</if>
  129. <if test="dcp_p_no != null and dcp_p_no != ''">dcp_p_no = #{dcp_p_no},</if>
  130. <if test="dcp_status != null">dcp_status = #{dcp_status},</if>
  131. <if test="dcp_price1 != null">dcp_price1 = #{dcp_price1},</if>
  132. <if test="dcp_price2 != null">dcp_price2 = #{dcp_price2},</if>
  133. <if test="dcp_price3 != null">dcp_price3 = #{dcp_price3},</if>
  134. <if test="dcp_price4 != null">dcp_price4 = #{dcp_price4},</if>
  135. <if test="dcp_cost_price != null">dcp_cost_price = #{dcp_cost_price},</if>
  136. <if test="dcm_id != null">dcm_id = #{dcm_id},</if>
  137. <if test="dcp_oa_code != null and dcp_oa_code != ''">dcp_oa_code = #{dcp_oa_code},</if>
  138. </trim>
  139. where dcp_id = #{dcp_id}
  140. </update>
  141. <delete id="deleteDcProductById" parameterType="Integer">
  142. delete from dc_product where dcp_id = #{dcp_id}
  143. </delete>
  144. <delete id="deleteDcProductByIds" parameterType="String">
  145. delete from dc_product where dcp_id in
  146. <foreach item="dcp_id" collection="array" open="(" separator="," close=")">
  147. #{dcp_id}
  148. </foreach>
  149. </delete>
  150. </mapper>