| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?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.cslg.ppa.mapper.ArticleInfoMapper">
- <select id="selectArticleInfoList" resultType="com.cslg.ppa.vo.SelectArticleInfoVO">
- SELECT
- ai.id as articleId,
- ai.title,
- CASE
- WHEN ai.old_content IS NOT NULL AND ai.old_content != '' THEN ai.old_content
- ELSE ai.digest
- END AS digest,
- ai.source_id,
- ai.public_time,
- ai.create_time,
- ai.article_url,
- ai.wx_article_icon,
- si.source_name,
- si.source_type,
- GROUP_CONCAT(acr.category_id) as categoryIdsStr,
- GROUP_CONCAT(ca.name) as categoryNamesStr
- FROM article_info ai
- LEFT JOIN article_category_relation acr ON acr.article_id = ai.id
- LEFT JOIN category ca ON ca.id = acr.category_id
- LEFT JOIN source_info si ON si.id = ai.source_id
- <where>
- <if test="vo.key != null and vo.key != ''">
- ai.title like concat('%',#{vo.key},'%')
- </if>
- <if test="vo.categoryId != null">
- and acr.category_id = #{vo.categoryId}
- </if>
- <if test="vo.sourceName != null and vo.sourceName != ''">
- and si.source_name like concat('%',#{vo.sourceName},'%')
- </if>
- <if test="vo.beginTime != null">
- and ai.public_time >= #{vo.beginTime}
- </if>
- <if test="vo.endTime != null">
- and ai.public_time <= #{vo.endTime}
- </if>
- </where>
- GROUP BY ai.id
- ORDER BY ai.public_time DESC, ai.id DESC
- <if test="vo.pageNum != null and vo.pageSize != null">
- LIMIT ${(vo.pageNum -1) * vo.pageSize},${vo.pageSize}
- </if>
- </select>
- <select id="selectArticleInfoCount" resultType="java.lang.Long">
- SELECT COUNT(DISTINCT ai.id)
- FROM article_info ai
- LEFT JOIN article_category_relation acr ON acr.article_id = ai.id
- LEFT JOIN category ca ON ca.id = acr.category_id
- LEFT JOIN source_info si ON si.id = ai.source_id
- <where>
- <if test="vo.key != null and vo.key != ''">
- ai.title like concat('%',#{vo.key},'%')
- </if>
- <if test="vo.categoryId != null">
- and acr.category_id = #{vo.categoryId}
- </if>
- <if test="vo.sourceName != null and vo.sourceName != ''">
- and si.source_name like concat('%',#{vo.sourceName},'%')
- </if>
- <if test="vo.beginTime != null">
- and ai.public_time >= #{vo.beginTime}
- </if>
- <if test="vo.endTime != null">
- and ai.public_time <= #{vo.endTime}
- </if>
- </where>
- </select>
- <select id="selectArticleList" resultType="com.cslg.ppa.vo.OneClickExportVO">
- select ai.id as articleId,
- ai.title,
- ai.digest,
- ai.old_content,
- ai.category_id,
- ai.public_time,
- ai.article_url,
- ai.if_export_from_local,
- ca.name as categoryName,
- ai.source_id,
- si.source_name,
- si.source_type
- from article_info ai
- left join category ca on ca.id = ai.category_id
- left join source_info si on si.id = ai.source_id
- <where>
- <if test="vo.type == 1">
- ai.category_id in (1,2,3,4,5)
- </if>
- <if test="vo.type == 2">
- ai.category_id in (16,17,18,19,20,21,22)
- </if>
- <if test="vo.beginTime != null">
- and ai.public_time >= #{vo.beginTime}
- </if>
- <if test="vo.endTime != null">
- and ai.public_time <= #{vo.endTime}
- </if>
- </where>
- order by ai.public_time asc,ai.id asc
- </select>
- </mapper>
|