Helius
2022-07-12 3a8d8b6de6daf6e7198a2b8d562dc2fbf49a4a2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?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.xcong.farmer.cms.modules.system.mapper.ArticleMapper">
 
    <select id="selectAdminArticleInPage" resultType="com.xcong.farmer.cms.modules.system.vo.AdminArticleVo">
        SELECT
        a.*,
        b.column_name columnName,
        c.web_address baseUrl,
        b.path path
        FROM
        t_article a
        left join t_column b on a.column_id = b.id
        inner join t_company c on a.company_id=c.id
        <where>
            and a.del_status = 1
            <if test="record != null" >
                <if test="record.columnList != null">
                    and a.column_id in
                    <foreach collection="record.columnList" separator="," close=")" open="(" item="item">
                        #{item}
                    </foreach>
                </if>
                <if test="record.companyId != null">
                    and a.company_id = #{record.companyId}
                </if>
                <if test="record.title!=null">
                    and a.title like concat ('%',#{record.title},'%')
                </if>
                <if test="record.columnIds != null">
                    and a.column_id in
                    <foreach collection="record.columnIds" separator="," close=")" open="(" item="item">
                        #{item}
                    </foreach>
                </if>
            </if>
        </where>
        order by a.is_top desc,a.create_time desc
    </select>
 
    <select id="selectAdminArticleByid" resultType="com.xcong.farmer.cms.modules.system.vo.AdminSeeArticleInfoVo">
        SELECT
        a.*
        FROM
        t_article a where id = #{id}
    </select>
 
    <select id="selectPrevOrNextArticle" resultType="com.xcong.farmer.cms.modules.system.entity.ArticleEntity">
        select *
        from t_article a, t_column b
        where (a.column_id=b.id or a.column_id=b.parent_id) and a.column_id=#{columnId} and release_status=1
        and del_status = 1
        <!--上一篇-->
        <if test="type == 1">
            and #{id} > a.id
            order by a.id desc
        </if>
        <!--下一篇-->
        <if test="type == 2">
            and a.id > #{id}
            order by a.id
        </if>
        limit 1
    </select>
 
    <select id="selectArticleById" resultType="com.xcong.farmer.cms.modules.system.entity.ArticleEntity">
        select a.*, b.column_code, b.column_name, b.path
        from t_article a, t_column b
        where a.column_id=b.id and a.id=#{id}
    </select>
 
    <select id="selectArticleInPage" resultType="com.xcong.farmer.cms.modules.system.entity.ArticleEntity">
        select
            a.*,
            b.column_code,
            b.column_name,
            b.path
        from t_article a
        inner join t_column b on a.column_id=b.id
        inner join t_column c on b.parent_id=c.id or c.id=b.id
        <where>
            a.company_id=#{record.companyId} and a.del_status = 1 and release_status = 1
            <if test="record.columnCode != null and record.columnCode != ''">
                and c.column_code=#{record.columnCode}
            </if>
            <if test="record.columnIds != null">
                and c.id in
                <foreach collection="record.columnIds" item="item" open="(" close=")" separator=",">
                    ${item}
                </foreach>
            </if>
            <if test="record.isTop != null and record.isTop != ''">
                and a.is_top=#{record.isTop}
            </if>
        </where>
        order by release_time desc
    </select>
 
    <select id="selectWebArticleInPage" resultType="com.xcong.farmer.cms.modules.system.vo.WebArticleVo">
        SELECT
        a.*,
        b.column_name columnName,
        c.web_address baseUrl,
        b.path path
        FROM
        t_article a
        left join t_column b on a.column_id = b.id
        inner join t_company c on a.company_id=c.id
        <where>
            and a.del_status = 1
            and a.release_status = 1
            and a.company_id = #{record.companyId}
            <if test="record != null" >
                <if test="record.columnId != null">
                    and a.column_id = #{record.columnId}
                </if>
                <if test="record.title!=null">
                    and a.title like concat ('%',#{record.title},'%')
                </if>
                <if test="record.author!=null">
                    and a.author like concat ('%',#{record.author},'%')
                </if>
                <if test="record.timeType!=null">
                    and a.release_time > #{record.timeType}
                </if>
            </if>
        </where>
        order by a.is_top desc,a.create_time desc
    </select>
 
    <select id="selectArticleIdsByColumnId" resultType="java.lang.Long">
        select a.id from t_article a
        where a.column_id=#{columnId} and a.company_id=#{companyId} and a.del_status = 1
        <if test="type != 4">
            <if test="type == 2">
                and release_status=1
            </if>
            <if test="type == 3">
                and release_status=0
            </if>
        </if>
    </select>
 
    <select id="selectArticleByColumnId" resultType="com.xcong.farmer.cms.modules.system.entity.ArticleEntity">
        select * from t_article a
        where a.column_id=#{columnId} and a.company_id=#{companyId} and a.del_status = 1
        <if test="type != 4">
            <if test="type == 2">
                and release_status=1
            </if>
            <if test="type == 3">
                and release_status=0
            </if>
        </if>
    </select>
</mapper>