Files
guoxue-java/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleMapper.xml
T
2026-03-25 15:56:42 +08:00

89 lines
3.2 KiB
XML

<?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.gxwebsoft.cms.mapper.ArticleMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*,
b.nickname,
b.user_id,
b.avatar userAvatar
FROM cms_article a
LEFT JOIN sys_user b ON a.user_id = b.user_id
<where>
<if test="param.articleId != null">
AND a.article_id = #{param.articleId}
</if>
<if test="param.title != null">
AND a.title LIKE CONCAT('%', #{param.title}, '%')
</if>
<if test="param.showType != null">
AND a.show_type = #{param.showType}
</if>
<if test="param.categoryId != null">
AND a.category_id = #{param.categoryId}
</if>
<if test="param.image != null">
AND a.image LIKE CONCAT('%', #{param.image}, '%')
</if>
<if test="param.source != null">
AND a.source LIKE CONCAT('%', #{param.source}, '%')
</if>
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if>
<if test="param.virtualViews != null">
AND a.virtual_views = #{param.virtualViews}
</if>
<if test="param.actualViews != null">
AND a.actual_views = #{param.actualViews}
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.shopId != null">
AND a.shop_id = #{param.shopId}
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.userId != null">
AND b.user_id = #{param.userId}
</if>
<if test="param.nickname != null">
AND b.nickname LIKE CONCAT('%', #{param.nickname}, '%')
</if>
</where>
ORDER BY a.sort_number ASC, a.create_time DESC
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.cms.entity.Article">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.cms.entity.Article">
<include refid="selectSql"></include>
</select>
</mapper>