123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- <?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.info.dao.InfoDao">
- <sql id="infoColumns">
- a.id AS "id",
- a.typeId AS "infoType.id",
- a.title AS "title",
- a.label AS "label",
- a.publisher AS "publisher",
- a.source AS "source",
- a.publishSource,
- s.name as "shopName",
- a.recommendContent AS "recommendContent",
- a.infoContent AS "infoContent",
- a.guidanceImage AS "guidanceImage",
- a.homePageImage AS "homePageImage",
- a.pubdate AS "pubdate",
- a.keyword AS "keyword",
- a.recommendStatus AS "recommendStatus",
- a.enabledStatus AS "enabledStatus",
- a.basePraise AS "basePraise",
- a.basePv AS "basePv",
- a.priorityIndex AS "priorityIndex",
- a.auditStatus,
- a.onlineStatus,
- a.failReason,
- c.num AS "realPraise",
- c.pv AS "pv",
- a.createBy AS "createBy.id",
- a.createDate AS "createDate",
- a.updateBy AS "updateBy.id",
- a.updateDate AS "updateDate",
- a.topPosition AS "topPosition",
- b.name AS "infoType.name"
- </sql>
- <sql id="infoJoins">
- LEFT JOIN info_type b ON a.typeId=b.id
- LEFT JOIN info_praise c ON a.id=c.infoId
- left join shop s on a.shopId = s.shopID
- </sql>
- <select id="get" resultType="Info">
- SELECT
- <include refid="infoColumns"/>
- FROM info a
- <include refid="infoJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="findByProjectId" resultType="Info">
- SELECT
- <include refid="infoColumns"/>
- FROM info a
- LEFT JOIN info_type b ON a.typeId=b.id
- LEFT JOIN info_praise c ON a.id=c.infoId
- LEFT JOIN project_info d ON a.id=d.infoId
- WHERE d.projectId = #{param1}
- </select>
- <select id="findList" resultType="Info">
- SELECT
- <include refid="infoColumns"/>
- FROM info a
- <include refid="infoJoins"/>
- <where>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- <if test="null !=infoType">
- <if test="infoType.id != null and infoType.id != ''">
- AND a.typeId = #{infoType.id}
- </if>
- </if>
- <if test="title != null and title != ''">
- AND a.title LIKE concat('%',#{title},'%')
- </if>
- <if test="label != null and label != ''">
- AND concat(',',a.label,',') LIKE concat('%,',#{label},',%')
- </if>
- <if test="publisher != null and publisher != ''">
- AND a.publisher LIKE concat('%',#{publisher},'%')
- </if>
- <if test="recommendStatus != null and recommendStatus != ''">
- AND a.recommendStatus = #{recommendStatus}
- </if>
- <if test="enabledStatus != null and enabledStatus != ''">
- AND a.enabledStatus = #{enabledStatus}
- </if>
- <if test="topFlag != null and topFlag != ''">
- <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="topPosition != null and topPosition != ''">
- and topPosition = #{topPosition}
- </if>
- <if test="publishSource == null">
- and publishSource = 1
- </if>
- <if test="publishSource != null">
- and publishSource = #{publishSource}
- </if>
- <if test="auditStatus != null">
- and a.auditStatus = #{auditStatus}
- </if>
- <if test="onlineStatus != null">
- and a.onlineStatus = #{onlineStatus}
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name LIKE concat('%',#{shopName},'%')
- </if>
- <if test="startPubDate != null and startPubDate != ''">
- AND a.pubdate <![CDATA[ >= ]]> #{startPubDate}
- </if>
- <if test="endPubDate != null and endPubDate != ''">
- AND a.pubdate <![CDATA[ <= ]]> #{endPubDate}
- </if>
- <!-- AND b.enabledStatus='1' -->
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.pubdate DESC
- </otherwise>
- </choose>
- </select>
- <select id="findAllList" resultType="Info">
- SELECT
- <include refid="infoColumns"/>
- FROM info a
- <include refid="infoJoins"/>
- <where>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.updateDate DESC
- </otherwise>
- </choose>
- </select>
- <select id="getSensitiveWords" resultType="java.lang.String">
- select words
- from cm_sensitive_words
- where id = 1 and status = 1
- <if test="checkPoint != null">
- and checkPoints like concat('%',#{checkPoint},'%')
- </if>
- </select>
- <insert id="insert" parameterType="Info" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO info(
- typeId,
- title,
- label,
- publisher,
- source,
- recommendContent,
- infoContent,
- guidanceImage,
- homePageImage,
- pubdate,
- keyword,
- recommendStatus,
- enabledStatus,
- basePraise,
- basePv,
- createBy,
- createDate,
- updateBy,
- updateDate,
- topPosition
- ) VALUES (
- #{infoType.id},
- #{title},
- #{label},
- #{publisher},
- #{source},
- #{recommendContent},
- #{infoContent},
- #{guidanceImage},
- #{homePageImage},
- #{pubdate},
- #{keyword},
- #{recommendStatus},
- #{enabledStatus},
- #{basePraise},
- #{basePv},
- #{createBy.id},
- #{createDate},
- #{updateBy.id},
- #{updateDate},
- #{topPosition}
- )
- </insert>
- <update id="update">
- UPDATE info SET
- typeId = #{infoType.id},
- title = #{title},
- label = #{label},
- publisher = #{publisher},
- source = #{source},
- recommendContent = #{recommendContent},
- infoContent = #{infoContent},
- guidanceImage = #{guidanceImage},
- homePageImage = #{homePageImage},
- pubdate = #{pubdate},
- keyword = #{keyword},
- recommendStatus = #{recommendStatus},
- enabledStatus = #{enabledStatus},
- basePraise = #{basePraise},
- basePv = #{basePv},
- updateBy = #{updateBy.id},
- updateDate = #{updateDate},
- <if test="auditFlag != null and auditFlag == 1">
- <if test="auditStatus != null">
- auditStatus = #{auditStatus},
- </if>
- <if test="onlineStatus != null">
- onlineStatus = #{onlineStatus},
- </if>
- <if test="failReason != null and failReason != ''">
- failReason = #{failReason},
- </if>
- </if>
- topPosition = #{topPosition}
- WHERE id = #{id}
- </update>
- <delete id="delete">
- DELETE FROM info
- WHERE id = #{id}
- </delete>
- <delete id="deleteInfoPraise">
- DELETE FROM info_praise
- WHERE infoId = #{param1}
- </delete>
- <delete id="deleteByTypeId">
- DELETE FROM info
- WHERE typeId = #{param1}
- </delete>
- <delete id="deleteInfoPageByInfoId">
- DELETE FROM info_page
- WHERE infoId = #{param1}
- </delete>
- <update id="updateEnabledStatusByIds">
- UPDATE info a SET a.enabledStatus = #{param1}
- WHERE a.id IN
- <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
- #{id}
- </foreach>
- </update>
- <update id="updateRecommendStatusByIds">
- UPDATE info a SET a.recommendStatus = #{param1}
- WHERE a.id IN
- <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
- #{id}
- </foreach>
- </update>
- <insert id="insertInfoPraise">
- INSERT INTO info_praise VALUES(#{param1},0,0)
- </insert>
- <insert id="insertInfoPage">
- INSERT INTO info_page(infoId,page,infoContent)
- <foreach collection="param2" item="infoContent" index="index" separator=" union all ">
- SELECT #{param1},#{index}+1,#{infoContent}
- </foreach>
- </insert>
- <update id="updateReplaceByLabel">
- UPDATE info a SET a.label=REPLACE(a.label,#{param1},#{param2}) WHERE CONCAT(',',a.label,',') LIKE CONCAT('%,',#{param1},',%')
- </update>
- <update id="auditInfo">
- update info
- set auditStatus = #{auditStatus},
- failReason = #{failReason}
- <if test="pubdate != null">
- ,pubdate = #{pubdate}
- </if>
- where id = #{id}
- </update>
- <update id="offlineInfo">
- update info set onlineStatus = 3 where id = #{id}
- </update>
- </mapper>
|