123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.gqy.document.mapper.DcProductMapper">
- <resultMap type="DcProduct" id="DcProductResult">
- <id property="dcp_id" column="dcp_id" />
- <result property="dcp_name" column="dcp_name" />
- <result property="dcp_model" column="dcp_model" />
- <result property="dcp_diff" column="dcp_diff" />
- <result property="dcp_p_no" column="dcp_p_no" />
- <result property="dcp_status" column="dcp_status" />
- <result property="dcp_price1" column="dcp_price1" />
- <result property="dcp_price2" column="dcp_price2" />
- <result property="dcp_price3" column="dcp_price3" />
- <result property="dcp_price4" column="dcp_price4" />
- <result property="dcp_cost_price" column="dcp_cost_price" />
- <result property="dcm_id" column="dcm_id" />
- <result property="dcp_oa_code" column="dcp_oa_code" />
- </resultMap>
- <sql id="selectDcProductVo">
- 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
- from dc_product
- </sql>
- <!-- 先查询所有规格参数名称 -->
- <select id="selectAllParamNames" resultType="string">
- SELECT DISTINCT psp_name
- FROM dc_ps_param
- ORDER BY psp_name
- </select>
- <!-- 动态构建SQL的查询 -->
- <select id="selectProductBaseList" parameterType="map" resultType="java.util.Map">
- SELECT
- p.dcp_oa_code,
- p.dcp_p_no,
- p.dcp_name,
- p.dcp_model,
- p.dcp_id
- <!-- <if test="paramNames != null and paramNames.size() > 0">-->
- <!-- ,<foreach item="paramName" collection="paramNames" separator=",">-->
- <!-- COALESCE(MAX(CASE WHEN param.psp_name = #{paramName}-->
- <!-- THEN param.psp_input_value END), '') as "${paramName}"-->
- <!-- </foreach>-->
- <!-- </if>-->
- FROM
- dc_product p
- LEFT JOIN dc_p_spec spec ON p.dcp_id = spec.ps_p_id
- LEFT JOIN dc_ps_param param ON spec.ps_no = param.psp_mode
- <where>
- <if test="dcp_oa_code != null and dcp_oa_code != ''">
- AND p.dcp_oa_code like concat('%', #{dcp_oa_code}, '%')
- </if>
- <if test="dcp_p_no != null and dcp_p_no != ''">
- AND p.dcp_p_no like concat('%', #{dcp_p_no}, '%')
- </if>
- <if test="dcp_name != null and dcp_name != ''">
- AND p.dcp_name like concat('%', #{dcp_name}, '%')
- </if>
- <if test="dcp_model != null and dcp_model != ''">
- AND p.dcp_model like concat('%', #{dcp_model}, '%')
- </if>
- </where>
- 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
- </select>
- <select id="selectDcProductList" parameterType="DcProduct" resultMap="DcProductResult">
- <include refid="selectDcProductVo"/>
- <where>
- <if test="dcp_name != null and dcp_name != ''">
- AND dcp_name like concat('%', #{dcp_name}, '%')
- </if>
- <if test="dcp_model != null and dcp_model != ''">
- AND dcp_model = #{dcp_model}
- </if>
- <if test="dcp_diff != null and dcp_diff != ''">
- AND dcp_diff = #{dcp_diff}
- </if>
- <if test="dcp_p_no != null and dcp_p_no != ''">
- AND dcp_p_no = #{dcp_p_no}
- </if>
- <if test="dcp_status != null ">
- AND dcp_status = #{dcp_status}
- </if>
- <if test="dcp_oa_code != null and dcp_oa_code != ''">
- AND dcp_oa_code = #{dcp_oa_code}
- </if>
- </where>
- </select>
- <select id="selectDcProductById" parameterType="Long" resultMap="DcProductResult">
- <include refid="selectDcProductVo"/>
- where dcp_id = #{dcp_id}
- </select>
- <insert id="insertDcProduct" parameterType="DcProduct" useGeneratedKeys="true" keyProperty="dcp_id">
- insert into dc_product
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="dcp_name != null">dcp_name,</if>
- <if test="dcp_model != null">dcp_model,</if>
- <if test="dcp_diff != null">dcp_diff,</if>
- <if test="dcp_p_no != null">dcp_p_no,</if>
- <if test="dcp_status != null">dcp_status,</if>
- <if test="dcp_price1 != null">dcp_price1,</if>
- <if test="dcp_price2 != null">dcp_price2,</if>
- <if test="dcp_price3 != null">dcp_price3,</if>
- <if test="dcp_price4 != null">dcp_price4,</if>
- <if test="dcp_cost_price != null">dcp_cost_price,</if>
- <if test="dcm_id != null">dcm_id,</if>
- <if test="dcp_oa_code != null">dcp_oa_code,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="dcp_name != null">#{dcp_name},</if>
- <if test="dcp_model != null">#{dcp_model},</if>
- <if test="dcp_diff != null">#{dcp_diff},</if>
- <if test="dcp_p_no != null">#{dcp_p_no},</if>
- <if test="dcp_status != null">#{dcp_status},</if>
- <if test="dcp_price1 != null">#{dcp_price1},</if>
- <if test="dcp_price2 != null">#{dcp_price2},</if>
- <if test="dcp_price3 != null">#{dcp_price3},</if>
- <if test="dcp_price4 != null">#{dcp_price4},</if>
- <if test="dcp_cost_price != null">#{dcp_cost_price},</if>
- <if test="dcm_id != null">#{dcm_id},</if>
- <if test="dcp_oa_code != null">#{dcp_oa_code},</if>
- </trim>
- </insert>
- <update id="updateDcProduct" parameterType="DcProduct">
- update dc_product
- <trim prefix="SET" suffixOverrides=",">
- <if test="dcp_name != null and dcp_name != ''">dcp_name = #{dcp_name},</if>
- <if test="dcp_model != null and dcp_model != ''">dcp_model = #{dcp_model},</if>
- <if test="dcp_diff != null and dcp_diff != ''">dcp_diff = #{dcp_diff},</if>
- <if test="dcp_p_no != null and dcp_p_no != ''">dcp_p_no = #{dcp_p_no},</if>
- <if test="dcp_status != null">dcp_status = #{dcp_status},</if>
- <if test="dcp_price1 != null">dcp_price1 = #{dcp_price1},</if>
- <if test="dcp_price2 != null">dcp_price2 = #{dcp_price2},</if>
- <if test="dcp_price3 != null">dcp_price3 = #{dcp_price3},</if>
- <if test="dcp_price4 != null">dcp_price4 = #{dcp_price4},</if>
- <if test="dcp_cost_price != null">dcp_cost_price = #{dcp_cost_price},</if>
- <if test="dcm_id != null">dcm_id = #{dcm_id},</if>
- <if test="dcp_oa_code != null and dcp_oa_code != ''">dcp_oa_code = #{dcp_oa_code},</if>
- </trim>
- where dcp_id = #{dcp_id}
- </update>
- <delete id="deleteDcProductById" parameterType="Integer">
- delete from dc_product where dcp_id = #{dcp_id}
- </delete>
- <delete id="deleteDcProductByIds" parameterType="String">
- delete from dc_product where dcp_id in
- <foreach item="dcp_id" collection="array" open="(" separator="," close=")">
- #{dcp_id}
- </foreach>
- </delete>
- </mapper>
|