123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- <?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.cmme.modules.product.dao.CmmeProductDao">
-
- <sql id="cmmeProductColumns">
- a.productID AS "id",
- a.productID AS "productID",
- a.brandID AS "brandID",
- a.bigTypeID AS "bigTypeID",
- a.smallTypeID AS "smallTypeID",
- a.feedbackType AS "feedbackType",
- a.shopCode AS "shopCode",
- a.shopID AS "shopID",
- a.name AS "name",
- a.searchKey AS "searchKey",
- a.normalPrice AS "normalPrice",
- a.price0 AS "price0",
- a.price0Text AS "price0Text",
- a.price0TextFlag AS "price0TextFlag",
- a.price1 AS "price1",
- a.price1Text AS "price1Text",
- a.priceFlag AS "priceFlag",
- a.stock AS "stock",
- a.mainImage AS "mainImage",
- a.addTime AS "addTime",
- a.updateTime AS "updateTime",
- a.beforeValidFlag AS "beforeValidFlag",
- a.validFlag AS "validFlag",
- a.favoriteTimes AS "favoriteTimes",
- a.commentScore AS "commentScore",
- a.commentTimes AS "commentTimes",
- a.sortIndex AS "sortIndex",
- a.productCode AS "productCode",
- a.unit AS "unit",
- a.serviceNumber AS "serviceNumber",
- a.maxBuyNumber AS "maxBuyNumber",
- a.minBuyNumber AS "minBuyNumber",
- a.packageCount AS "packageCount",
- a.byFlag AS "byFlag",
- a.step AS "step",
- a.freePostFlag AS "freePostFlag",
- a.precisehKey AS "precisehKey",
- a.docBoost AS "docBoost",
- cs.name AS "shopName",
- cpd.detailInfo AS "detailInfo",
- cpd.detailInfoTxt AS "detailInfoTxt",
- cpd.seoTitle AS "seoTitle",
- cpd.seoKeyword AS "seoKeyword",
- cpd.seoDes AS "seoDes",
- cpd.technicalParameter AS "technicalParameter",
- cpd.expertOpinion AS "expertOpinion",
- cpd.clinicalResult AS "clinicalResult",
- cpd.video AS "video"
- </sql>
-
- <sql id="cmmeProductJoins">
- LEFT JOIN cmme_shop cs ON cs.shopID = a.shopID
- LEFT JOIN cmme_productdetailinfo cpd ON cpd.productID = a.productID
- </sql>
-
- <select id="get" resultType="CmmeProduct">
- SELECT
- <include refid="cmmeProductColumns"/>
- FROM cmme_product a
- <include refid="cmmeProductJoins"/>
- WHERE a.productID = #{id}
- </select>
-
- <select id="findList" resultType="CmmeProduct">
- SELECT
- <include refid="cmmeProductColumns"/>
- FROM cmme_product a
- <include refid="cmmeProductJoins"/>
- <where>
- <if test="shopName != null and shopName != ''">
- AND cs.name LIKE concat('%',#{shopName},'%')
- </if>
- <if test="productID != null and productID != ''">
- AND a.productID = #{productID}
- </if>
- <if test="bigTypeID != null and bigTypeID != ''">
- AND a.bigTypeID = #{bigTypeID}
- </if>
- <if test="smallTypeID != null and smallTypeID != ''">
- AND a.smallTypeID = #{smallTypeID}
- </if>
- <if test="shopCode != null and shopCode != ''">
- AND a.shopCode = #{shopCode}
- </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="validFlag != null and validFlag != ''">
- AND a.validFlag = #{validFlag}
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.validFlag ASC ,a.addTime DESC
- </otherwise>
- </choose>
- </select>
-
- <select id="findAllList" resultType="CmmeProduct">
- SELECT
- <include refid="cmmeProductColumns"/>
- FROM cmme_product a
- <include refid="cmmeProductJoins"/>
- <where>
-
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
-
- <insert id="insert" parameterType="CmmeProduct" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cmme_product(
- brandID,
- bigTypeID,
- smallTypeID,
- feedbackType,
- shopCode,
- shopID,
- name,
- searchKey,
- normalPrice,
- price0,
- price0Text,
- price0TextFlag,
- price1,
- price1Text,
- priceFlag,
- stock,
- mainImage,
- addTime,
- updateTime,
- beforeValidFlag,
- validFlag,
- favoriteTimes,
- commentScore,
- commentTimes,
- sortIndex,
- productCode,
- unit,
- serviceNumber,
- maxBuyNumber,
- minBuyNumber,
- packageCount,
- byFlag,
- step,
- freePostFlag,
- precisehKey,
- docBoost
- ) VALUES (
- #{brandID},
- #{bigTypeID},
- #{smallTypeID},
- #{feedbackType},
- #{shopCode},
- #{shopID},
- #{name},
- #{searchKey},
- #{normalPrice},
- #{price0},
- #{price0Text},
- #{price0TextFlag},
- #{price1},
- #{price1Text},
- #{priceFlag},
- #{stock},
- #{mainImage},
- #{addTime},
- #{updateTime},
- #{beforeValidFlag},
- #{validFlag},
- #{favoriteTimes},
- #{commentScore},
- #{commentTimes},
- #{sortIndex},
- #{productCode},
- #{unit},
- #{serviceNumber},
- #{maxBuyNumber},
- #{minBuyNumber},
- #{packageCount},
- #{byFlag},
- #{step},
- #{freePostFlag},
- #{precisehKey},
- #{docBoost}
- )
- </insert>
-
- <update id="update">
- UPDATE cmme_product SET
- <if test="brandID != null and brandID != ''">
- brandID = #{brandID},
- </if>
- <if test="bigTypeID != null and bigTypeID != ''">
- bigTypeID = #{bigTypeID},
- </if>
- <if test="smallTypeID != null and smallTypeID != ''">
- smallTypeID = #{smallTypeID},
- </if>
- <if test="feedbackType != null and feedbackType != ''">
- feedbackType = #{feedbackType},
- </if>
- <if test="shopCode != null and shopCode != ''">
- shopCode = #{shopCode},
- </if>
- <if test="shopID != null and shopID != ''">
- shopID = #{shopID},
- </if>
- <if test="name != null and name != ''">
- name = #{name},
- </if>
- <if test="searchKey != null and searchKey != ''">
- searchKey = #{searchKey},
- </if>
- <if test="normalPrice != null and normalPrice != ''">
- normalPrice = #{normalPrice},
- </if>
- <if test="price0 != null and price0 != ''">
- price0 = #{price0},
- </if>
- <if test="price0Text != null and price0Text != ''">
- price0Text = #{price0Text},
- </if>
- <if test="price0TextFlag != null and price0TextFlag != ''">
- price0TextFlag = #{price0TextFlag},
- </if>
- <if test="price1 != null and price1 != ''">
- price1 = #{price1},
- </if>
- <if test="price1Text != null and price1Text != ''">
- price1Text = #{price1Text},
- </if>
- <if test="priceFlag != null and priceFlag != ''">
- priceFlag = #{priceFlag},
- </if>
- <if test="stock != null and stock != ''">
- stock = #{stock},
- </if>
- <if test="mainImage != null and mainImage != ''">
- mainImage = #{mainImage},
- </if>
- <if test="addTime != null and addTime != ''">
- addTime = #{addTime},
- </if>
- <if test="updateTime != null and updateTime != ''">
- updateTime = #{updateTime},
- </if>
- <if test="beforeValidFlag != null and beforeValidFlag != ''">
- beforeValidFlag = #{beforeValidFlag},
- </if>
- <if test="validFlag != null and validFlag != ''">
- validFlag = #{validFlag},
- </if>
- <if test="favoriteTimes != null and favoriteTimes != ''">
- favoriteTimes = #{favoriteTimes},
- </if>
- <if test="commentScore != null and commentScore != ''">
- commentScore = #{commentScore},
- </if>
- <if test="commentTimes != null and commentTimes != ''">
- commentTimes = #{commentTimes},
- </if>
- <if test="sortIndex != null and sortIndex != ''">
- sortIndex = #{sortIndex},
- </if>
- <if test="productCode != null and productCode != ''">
- productCode = #{productCode},
- </if>
- <if test="unit != null and unit != ''">
- unit = #{unit},
- </if>
- <if test="serviceNumber != null and serviceNumber != ''">
- serviceNumber = #{serviceNumber},
- </if>
- <if test="maxBuyNumber != null and maxBuyNumber != ''">
- maxBuyNumber = #{maxBuyNumber},
- </if>
- <if test="minBuyNumber != null and minBuyNumber != ''">
- minBuyNumber = #{minBuyNumber},
- </if>
- <if test="packageCount != null and packageCount != ''">
- packageCount = #{packageCount},
- </if>
- <if test="byFlag != null and byFlag != ''">
- byFlag = #{byFlag},
- </if>
- <if test="step != null and step != ''">
- step = #{step},
- </if>
- <if test="freePostFlag != null and freePostFlag != ''">
- freePostFlag = #{freePostFlag},
- </if>
- <if test="precisehKey != null and precisehKey != ''">
- precisehKey = #{precisehKey},
- </if>
- <if test="docBoost != null and docBoost != ''">
- docBoost = #{docBoost},
- </if>
- productID = #{productID}
- WHERE productID = #{productID}
- </update>
-
- <delete id="delete">
- DELETE FROM cmme_product
- WHERE productID = #{productID}
- </delete>
- <select id="getProductImage" parameterType="com.cmme.modules.product.entity.CmmeProductImage" resultType="com.cmme.modules.product.entity.CmmeProductImage">
- SELECT *
- FROM cmme_productimage cp
- <where>
- <if test="shopID != null and shopID != ''">
- AND cp.shopID = #{shopID}
- </if>
- <if test="productID != null and productID != ''">
- AND cp.productID = #{productID}
- </if>
- </where>
- </select>
- <update id="updateProductDetail">
- UPDATE cmme_productdetailinfo SET
- <if test="detailInfo != null and detailInfo != ''">
- detailInfo = #{detailInfo},
- </if>
- <if test="detailInfoTxt != null and detailInfoTxt != ''">
- detailInfoTxt = #{detailInfoTxt},
- </if>
- <if test="seoTitle != null and seoTitle != ''">
- seoTitle = #{seoTitle},
- </if>
- <if test="seoKeyword != null and seoKeyword != ''">
- seoKeyword = #{seoKeyword},
- </if>
- <if test="seoDes != null and seoDes != ''">
- seoDes = #{seoDes},
- </if>
- <if test="technicalParameter != null and technicalParameter != ''">
- technicalParameter = #{technicalParameter},
- </if>
- <if test="expertOpinion != null and expertOpinion != ''">
- expertOpinion = #{expertOpinion},
- </if>
- <if test="clinicalResult != null and clinicalResult != ''">
- clinicalResult = #{clinicalResult},
- </if>
- <if test="video != null and video != ''">
- video = #{video},
- </if>
- productID = #{productID}
- WHERE productID = #{productID}
- </update>
- <update id="updataProductImage">
- UPDATE cmme_productimage SET
- <if test="shopID != null and shopID != ''">
- shopID = #{shopID},
- </if>
- <if test="addTime != null and addTime != ''">
- addTime = #{addTime},
- </if>
- <if test="image != null and image != ''">
- image = #{image},
- </if>
- <if test="mainFlag != null and mainFlag != ''">
- mainFlag = #{mainFlag},
- </if>
- <if test="sortIndex != null and sortIndex != ''">
- sortIndex = #{sortIndex},
- </if>
- productImageID = #{productImageID}
- WHERE productImageID = #{productImageID}
- </update>
- <insert id="saveProductImage" parameterType="com.cmme.modules.product.entity.CmmeProductImage" keyProperty="productDetailInfoID" useGeneratedKeys="true">
- INSERT INTO cmme_productimage(
- productID,
- shopID,
- addTime,
- image,
- mainFlag,
- sortIndex
- ) VALUES (
- #{productID},
- #{shopID},
- #{addTime},
- #{image},
- #{mainFlag},
- #{sortIndex}
- )
- </insert>
- <!--由于商品商家编码必须不唯一则重复编辑的时候查看不等于自己ID的shopCode是否重复-->
- <select id="getByShopCode" resultType="CmmeProduct">
- SELECT
- *
- FROM cmme_product a
- WHERE
- a.shopCode = #{shopCode}
- <if test="productID != null and productID != ''">
- AND a.productID != #{productID}
- </if>
- </select>
- </mapper>
|