123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <?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.caimei.modules.baike.dao.CmBaikeProductDao">
-
- <sql id="cmBaikeProductColumns">
- a.id AS "id",
- a.commodityType AS "commodityType",
- a.name AS "name",
- a.alias AS "alias",
- a.discription AS "discription",
- a.image AS "image",
- a.advantage AS "advantage",
- a.disadvantage AS "disadvantage",
- a.principle AS "principle",
- a.brand AS "brand",
- a.producePlace AS "producePlace",
- a.marketTime AS "marketTime",
- a.company AS "company",
- a.nmpaTime AS "nmpaTime",
- a.adaptiveMan AS "adaptiveMan",
- a.unAdaptiveMan AS "unAdaptiveMan",
- a.aroundOperation AS "aroundOperation",
- a.publishTime AS "publishTime",
- a.basePv AS "basePv",
- a.actualPv AS "actualPv",
- a.typeId AS "typeId",
- a.topPosition AS "topPosition",
- a.status AS "status",
- a.addTime AS "addTime",
- cbt.name as "typeName"
- </sql>
-
- <sql id="cmBaikeProductJoins">
- left join cm_baike_type cbt on a.typeId = cbt.id
- </sql>
-
- <select id="get" resultType="CmBaikeProduct">
- SELECT
- <include refid="cmBaikeProductColumns"/>
- FROM cm_baike_product a
- <include refid="cmBaikeProductJoins"/>
- WHERE a.id = #{id}
- </select>
-
- <select id="findList" resultType="CmBaikeProduct">
- SELECT
- <include refid="cmBaikeProductColumns"/>
- FROM cm_baike_product a
- <include refid="cmBaikeProductJoins"/>
- <where>
-
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE
- <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
- </if>
- <if test="typeId != null and typeId != ''">
- AND a.typeId = #{typeId}
- </if>
- <if test="topFlag != null">
- <choose>
- <when test='topFlag == 1'>
- and topPosition is not null and topPosition != ''
- </when>
- <when test='topFlag == 0'>
- and (topPosition is null or topPosition = '')
- </when>
- </choose>
- </if>
- <if test="status != null">
- AND a.status = #{status}
- </if>
- <if test="commodityType != null">
- and a.commodityType = #{commodityType}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
-
- <select id="findAllList" resultType="CmBaikeProduct">
- SELECT
- <include refid="cmBaikeProductColumns"/>
- FROM cm_baike_product a
- <include refid="cmBaikeProductJoins"/>
- <where>
-
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findParamList" resultType="com.caimei.modules.baike.entity.CmBaikeProductParam">
- select productId, name, content from cm_baike_product_param where productId = #{id}
- </select>
- <select id="findImageList" resultType="java.lang.String">
- select image from cm_baike_product_image where productId = #{productId} and type = #{imageType}
- </select>
- <select id="findQuestionList" resultType="com.caimei.modules.baike.entity.CmBaikeProductQuestion">
- select productId, question, answer
- from cm_baike_product_question
- where productId = #{id}
- </select>
- <select id="findTopLength" resultType="java.lang.Integer">
- select count(*) from cm_baike_product where topPosition is not null and topPosition != ''
- </select>
- <insert id="insert" parameterType="CmBaikeProduct" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_baike_product(
- commodityType,
- name,
- alias,
- discription,
- image,
- advantage,
- disadvantage,
- principle,
- brand,
- producePlace,
- marketTime,
- company,
- nmpaTime,
- adaptiveMan,
- unAdaptiveMan,
- aroundOperation,
- publishTime,
- basePv,
- actualPv,
- typeId,
- status,
- addTime
- ) VALUES (
- #{commodityType},
- #{name},
- #{alias},
- #{discription},
- #{image},
- #{advantage},
- #{disadvantage},
- #{principle},
- #{brand},
- #{producePlace},
- #{marketTime},
- #{company},
- #{nmpaTime},
- #{adaptiveMan},
- #{unAdaptiveMan},
- #{aroundOperation},
- #{publishTime},
- #{basePv},
- 0,
- #{typeId},
- #{status},
- NOW()
- )
- </insert>
- <insert id="insertProductImage">
- insert into cm_baike_product_image (productId, type, image)
- values (#{produtId}, #{imageType}, #{authImage})
- </insert>
- <insert id="insertProductParam">
- insert into cm_baike_product_param (productId, name, content)
- values (#{productId}, #{name}, #{content})
- </insert>
- <insert id="insertProductQuestion">
- insert into cm_baike_product_question (productId, question, answer)
- values (#{productId}, #{question}, #{answer})
- </insert>
- <update id="update">
- UPDATE cm_baike_product SET
- name = #{name},
- alias = #{alias},
- discription = #{discription},
- image = #{image},
- advantage = #{advantage},
- disadvantage = #{disadvantage},
- principle = #{principle},
- brand = #{brand},
- producePlace = #{producePlace},
- marketTime = #{marketTime},
- company = #{company},
- nmpaTime = #{nmpaTime},
- adaptiveMan = #{adaptiveMan},
- unAdaptiveMan = #{unAdaptiveMan},
- aroundOperation = #{aroundOperation},
- publishTime = #{publishTime},
- basePv = #{basePv},
- typeId = #{typeId},
- status = #{status}
- WHERE id = #{id}
- </update>
- <update id="updateStatus">
- update cm_baike_product set status = #{status} where id = #{productId}
- </update>
- <update id="updateTopPosition">
- update cm_baike_product set topPosition = #{topPosition} where id = #{id}
- </update>
- <delete id="delete">
- DELETE FROM cm_baike_product
- WHERE id = #{id}
- </delete>
- <delete id="deleteParamsByProductId">
- delete from cm_baike_product_param where productId = #{id}
- </delete>
- <delete id="deleteImagesByProductId">
- delete from cm_baike_product_image where productId = #{id}
- </delete>
- <delete id="deleteQuestionsByProductId">
- delete from cm_baike_product_question where productId = #{id}
- </delete>
- </mapper>
|