<?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="org.springblade.modules.article.mapper.ArticleMapper">
|
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="noticeResultMap" type="org.springblade.modules.article.vo.ArticleVO">
|
<result column="id" property="id"/>
|
<result column="title" property="title"/>
|
<result column="type" property="type"/>
|
<result column="content" property="content"/>
|
<result column="url" property="url"/>
|
<result column="video_url" property="videoUrl"/>
|
<result column="source_id" property="sourceId"/>
|
<result column="source_name" property="sourceName"/>
|
<result column="article_type" property="articleType"/>
|
<result column="recommend" property="recommend"/>
|
<result column="publish" property="publish"/>
|
<result column="iscomment" property="iscomment"/>
|
<result column="view_number" property="viewNumber"/>
|
<result column="create_time" property="createTime"/>
|
<result column="update_time" property="updateTime"/>
|
<result column="update_user" property="updateUser"/>
|
<result column="create_user" property="createUser"/>
|
<result column="is_deleted" property="isDeleted"/>
|
|
<!-- <collection property="lickFlag" javaType="int"-->
|
<!-- column="id" select="selectStlLick">-->
|
<!-- </collection>-->
|
|
<collection property="countNumber" column="id" javaType="int" select="selectStlCount">
|
</collection>
|
|
</resultMap>
|
|
<!-- <select id="selectStlLick" parameterType="Long" resultType="int">-->
|
<!-- select IFNULL(jnl.id, 0) lickFlag-->
|
<!-- FROM jczz_notice jn-->
|
<!-- LEFT JOIN jczz_notice_like jnl ON jn.id = jnl.notice_id-->
|
<!-- WHERE jnl.notice_user_id = #{notice.userId}-->
|
<!-- and jn.is_deleted = 0-->
|
<!-- and jn.id = #{id}-->
|
<!-- </select>-->
|
|
<select id="selectStlCount" resultType="int">
|
select count(1) countNumber
|
FROM jczz_article jn
|
LEFT JOIN jczz_article_like jnl ON jn.id = jnl.article_id
|
where jn.is_deleted = 0
|
and jnl.delete_flag = 0
|
and jn.id = #{id}
|
</select>
|
|
<select id="selectArticlePageByApp" resultMap="noticeResultMap">
|
select ja.id,
|
ja.title,
|
ja.type,
|
ja.url,
|
ja.video_url,
|
ja.source_id,
|
ja.source_name,
|
ja.article_type,
|
ja.recommend,
|
ja.publish,
|
ja.iscomment,
|
ja.view_number,
|
ja.create_time,
|
ja.update_time,
|
ja.update_user,
|
ja.create_user,
|
ja.is_deleted,
|
bdb.dict_value dictValue
|
from jczz_article ja LEFT JOIN blade_dict_biz bdb on ja.article_type = bdb.dict_key
|
where ja.is_deleted = 0
|
and ja.publish = 1
|
and bdb.parent_id = '1722966265111248897'
|
<if test="article.articleType != null and article.articleType != ''">
|
and ja.article_type = #{article.articleType}
|
</if>
|
order by ja.create_time desc
|
</select>
|
|
<!--查询资讯分页列表信息-->
|
<select id="selectArticlePage" resultType="org.springblade.modules.article.entity.Article">
|
select * from jczz_article
|
where 1=1
|
<if test="article.title!=null and article.title!=''">
|
and title like concat('%',#{article.title},'%')
|
</if>
|
<if test="article.sourceName!=null and article.sourceName!=''">
|
and source_name like concat('%',#{article.sourceName},'%')
|
</if>
|
<if test="article.startTime!=null and article.startTime!=''">
|
and create_time>=#{article.startTime}
|
</if>
|
<if test="article.endTime!=null and article.endTime!=''">
|
and create_time<=#{article.endTime}
|
</if>
|
<if test="article.publish!=null and article.publish!=''">
|
and publish = #{article.publish}
|
</if>
|
<if test="article.articleType!=null and article.articleType!=''">
|
and article_type like concat('%',#{article.articleType},'%')
|
</if>
|
<if test="article.keyword!=null and article.keyword!=''">
|
AND CONCAT(title,source_name)
|
LIKE CONCAT ('%', #{article.keyword},'%')
|
</if>
|
order by id desc
|
</select>
|
|
<!--查询资讯敏感词预警-->
|
<select id="pageWords" resultType="org.springblade.modules.article.entity.Article">
|
select * from jczz_article
|
where 1=1
|
<if test="article.title!=null and article.title!=''">
|
and title like concat('%',#{article.title},'%')
|
</if>
|
<if test="article.sourceName!=null and article.sourceName!=''">
|
and source_name like concat('%',#{article.sourceName},'%')
|
</if>
|
<if test="article.startTime!=null and article.startTime!=''">
|
and create_time>=#{article.startTime}
|
</if>
|
<if test="article.endTime!=null and article.endTime!=''">
|
and create_time<=#{article.endTime}
|
</if>
|
<if test="article.articleType!=null and article.articleType!=''">
|
and article_type = #{article.articleType}
|
</if>
|
<if test="article.keyword!=null and article.keyword!=''">
|
AND CONCAT(title,source_name)
|
LIKE CONCAT ('%', #{article.keyword},'%')
|
</if>
|
and iswords = "1"
|
order by id desc
|
</select>
|
|
<!--查询资讯分页列表信息-->
|
<select id="pageDate" resultType="org.springblade.modules.article.entity.Article">
|
select * from jczz_article
|
where 1=1
|
<if test="article.articleType!=null and article.articleType!=''">
|
and article_type LIKE CONCAT ('%', #{article.articleType},'%')
|
</if>
|
<if test="article.keyword!=null and article.keyword!=''">
|
AND CONCAT(title,source_name)
|
LIKE CONCAT ('%', #{article.keyword},'%')
|
</if>
|
<if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
|
AND publish = 1
|
</if>
|
and iswords = "0"
|
order by id desc
|
</select>
|
|
<!--查询收藏资讯分页列表信息-->
|
<select id="pageCollectList" resultType="org.springblade.modules.article.entity.Article">
|
SELECT
|
art.*
|
FROM
|
sys_collect col
|
LEFT JOIN jczz_article art on art.id = col.collect_article
|
WHERE
|
1 = 1 AND collect_user = #{article.userid}
|
<if test="article.articleType!=null and article.articleType!=''">
|
and article_type LIKE CONCAT ('%', #{article.articleType},'%')
|
</if>
|
<if test="article.keyword!=null and article.keyword!=''">
|
AND CONCAT(title,source_name)
|
LIKE CONCAT ('%', #{article.keyword},'%')
|
</if>
|
<if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
|
AND publish = 1
|
</if>
|
and iswords = "0"
|
order by id desc
|
</select>
|
|
<!--查询资讯分页列表信息-->
|
<select id="pageLikes" resultType="org.springblade.modules.article.vo.ArticleVO">
|
SELECT
|
*
|
FROM
|
jczz_article art
|
LEFT JOIN (
|
SELECT
|
a.likes_article,
|
COUNT( * ) AS count,
|
b.islikes
|
FROM
|
sys_likes a
|
LEFT JOIN ( SELECT likes_article, COUNT( * ) AS islikes FROM sys_likes WHERE 1 = 1
|
<if test="article.userid!=null and article.userid!=''">
|
and likes_user = #{article.userid}
|
</if>
|
GROUP BY likes_article ) b ON a.likes_article = b.likes_article
|
GROUP BY
|
likes_article,
|
b.islikes
|
) likes ON art.id = likes.likes_article
|
|
LEFT JOIN (
|
SELECT
|
a.collect_article,
|
COUNT( * ) AS collectcount,
|
b.iscollect
|
FROM
|
sys_collect a
|
LEFT JOIN ( SELECT collect_article, COUNT( * ) AS iscollect FROM sys_collect WHERE 1 = 1
|
<if test="article.userid!=null and article.userid!=''">
|
and collect_user = #{article.userid}
|
</if>
|
GROUP BY collect_article ) b ON a.collect_article = b.collect_article
|
GROUP BY
|
collect_article,
|
b.iscollect
|
) collect ON art.id = collect.collect_article
|
|
LEFT JOIN (
|
SELECT
|
article,
|
COUNT(*) as comments
|
FROM
|
sys_comment
|
GROUP BY article
|
) com on com.article = art.id
|
WHERE
|
1 = 1
|
<if test="article.articleType!=null and article.articleType!=''">
|
and article_type LIKE CONCAT ('%', #{article.articleType},'%')
|
</if>
|
<if test="article.keyword!=null and article.keyword!=''">
|
AND CONCAT(title,source_name)
|
LIKE CONCAT ('%', #{article.keyword},'%')
|
</if>
|
<if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
|
AND publish = 1
|
</if>
|
and iswords = "0"
|
order by id desc
|
</select>
|
|
<!--查询资讯分页列表信息-->
|
<select id="pageCollect" resultType="org.springblade.modules.article.vo.ArticleVO">
|
SELECT
|
*
|
FROM
|
jczz_article art
|
LEFT JOIN (
|
SELECT
|
a.likes_article,
|
COUNT( * ) AS count,
|
b.islikes
|
FROM
|
sys_likes a
|
LEFT JOIN ( SELECT likes_article, COUNT( * ) AS islikes FROM sys_likes WHERE 1 = 1
|
<if test="article.userid!=null and article.userid!=''">
|
and likes_user = #{article.userid}
|
</if>
|
GROUP BY likes_article ) b ON a.likes_article = b.likes_article
|
GROUP BY
|
likes_article,
|
b.islikes
|
) likes ON art.id = likes.likes_article
|
|
LEFT JOIN (
|
SELECT
|
a.collect_article,
|
COUNT( * ) AS collectcount,
|
b.iscollect
|
FROM
|
sys_collect a
|
LEFT JOIN ( SELECT collect_article, COUNT( * ) AS iscollect FROM sys_collect WHERE 1 = 1
|
<if test="article.userid!=null and article.userid!=''">
|
and collect_user = #{article.userid}
|
</if>
|
GROUP BY collect_article ) b ON a.collect_article = b.collect_article
|
GROUP BY
|
collect_article,
|
b.iscollect
|
) collect ON art.id = collect.collect_article
|
|
LEFT JOIN (
|
SELECT
|
article,
|
COUNT(*) as comments
|
FROM
|
sys_comment
|
GROUP BY article
|
) com on com.article = art.id
|
WHERE
|
1 = 1
|
AND iscollect = 1
|
<if test="article.articleType!=null and article.articleType!=''">
|
and article_type LIKE CONCAT ('%', #{article.articleType},'%')
|
</if>
|
<if test="article.keyword!=null and article.keyword!=''">
|
AND CONCAT(title,source_name)
|
LIKE CONCAT ('%', #{article.keyword},'%')
|
</if>
|
<if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
|
AND publish = 1
|
</if>
|
and iswords = "0"
|
order by id desc
|
</select>
|
|
<update id="upcomment">
|
update jczz_article set iscomment = #{type}
|
where id in(${ids})
|
</update>
|
|
<!--个人资讯-->
|
<select id="selectArticleG" resultType="org.springblade.modules.article.entity.Article">
|
select * from jczz_article
|
where 1=1
|
<if test="article.title!=null and article.title!=''">
|
and title like concat('%',#{article.title},'%')
|
</if>
|
<if test="article.sourceName!=null and article.sourceName!=''">
|
and source_name like concat('%',#{article.sourceName},'%')
|
</if>
|
<if test="article.startTime!=null and article.startTime!=''">
|
and create_time>=#{article.startTime}
|
</if>
|
<if test="article.endTime!=null and article.endTime!=''">
|
and create_time<=#{article.endTime}
|
</if>
|
<if test="article.articleType!=null and article.articleType!=''">
|
and article_type = #{article.articleType}
|
</if>
|
<if test="article.keyword!=null and article.keyword!=''">
|
AND CONCAT(title,source_name)
|
LIKE CONCAT ('%', #{article.keyword},'%')
|
</if>
|
<if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
|
AND publish = 1
|
</if>
|
and iswords = "0" and type!=1
|
order by id desc
|
</select>
|
</mapper>
|