1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
<?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.landtool.lanbase.modules.sys.dao.PubNewsDao">
 
    <!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="com.landtool.lanbase.modules.sys.entity.PubNews" id="pubNewsMap">
        <result property="newsid" column="NEWSID"/>
        <result property="title" column="TITLE"/>
        <result property="contents" column="CONTENTS"/>
        <result property="type" column="TYPE"/>
        <result property="createuser" column="CREATEUSER"/>
        <result property="createdate" column="CREATEDATE"/>
        <result property="lasteditdate" column="LASTEDITDATE"/>
    </resultMap>
 
    <select id="queryObject" resultType="com.landtool.lanbase.modules.sys.entity.PubNews">
        select PUB_NEWS.*,org_user.chinesename as createusername from PUB_NEWS
        left join ORG_USER on PUB_NEWS.createuser = ORG_USER.userid where NEWSID = #{value}
    </select>
 
    <select id="queryList" resultType="com.landtool.lanbase.modules.sys.entity.PubNews">
        select * from (
            SELECT *
            FROM(
                SELECT ROW_NUMBER() OVER(ORDER BY B.createdate desc) AS rownumber,B.*
                FROM (
    
                    SELECT PUB_NEWS.*,ORG_USER.chinesename as createusername FROM PUB_NEWS
                    left join ORG_USER on PUB_NEWS.createuser = ORG_USER.userid
                    <where>
                      <if test="title!=null and title != '' ">
                        and TITLE like ('%' || #{title} || '%')
                      </if>
                      <if test="type != null and type != '' ">
                        and type = #{type}
                      </if>
                      <if test="createimeBeg != null and createimeBeg != '' ">
                        <![CDATA[ and CREATEDATE >= to_timestamp(#{createimeBeg},'yyyy-mm-dd hh24:mi:ss') ]]>
 
                      </if>
                      <if test="createtimeEnd != null and createtimeEnd != '' ">
                        <![CDATA[ and CREATEDATE <= to_timestamp(#{createtimeEnd},'yyyy-mm-dd hh24:mi:ss') ]]>
                      </if>
                    </where>
                ) B
            ) A
            WHERE rownumber > #{lowerOffset} AND  <![CDATA[ rownumber <= ${upperOffset} ]]>
        )a order by  
        <choose>
            <when test="sidx != null and sidx != ''">
                ${sidx} ${order}
            </when>
            <otherwise>
                createdate desc
            </otherwise>
        </choose>
    </select>
    
     <select id="queryTotal" resultType="int">
        SELECT count(*) FROM PUB_NEWS
        <where>
          <if test="title!=null and title != '' ">
            and TITLE like ('%' || #{title} || '%')
          </if>
          <if test="type != null and type != '' ">
            and type = #{type}
          </if>
          <if test="createimeBeg != null and createimeBeg != '' ">
            <![CDATA[ and CREATEDATE >= to_timestamp(#{createimeBeg} ,'yyyy-mm-dd hh24:mi:ss') ]]>
          </if>
          <if test="createtimeEnd != null and createtimeEnd != '' ">
            <![CDATA[ and CREATEDATE <= to_timestamp(#{createtimeEnd} ,'yyyy-mm-dd hh24:mi:ss') ]]>
          </if>
        </where>
    </select>
     
    <insert id="save" parameterType="com.landtool.lanbase.modules.sys.entity.PubNews">
        insert into PUB_NEWS
        (
            TITLE, 
            CONTENTS, 
            TYPE, 
            CREATEUSER, 
            CREATEDATE, 
            LASTEDITDATE
        )
        values
        ( 
            #{title}, 
            #{contents,jdbcType=LONGNVARCHAR}, 
            #{type}, 
            #{createuser,jdbcType=INTEGER}, 
            #{createdate}, 
            #{lasteditdate}
        )
    </insert>
     
    <update id="update" parameterType="com.landtool.lanbase.modules.sys.entity.PubNews">
        update PUB_NEWS
        <set>
            <if test="title != null">TITLE = #{title}, </if>
            <if test="contents != null">CONTENTS = #{contents}, </if>
            <if test="type != null">TYPE = #{type}, </if>
            <if test="createuser != null">CREATEUSER = #{createuser}, </if>
            <if test="createdate != null">CREATEDATE = #{createdate}, </if>
            <if test="lasteditdate != null">LASTEDITDATE = #{lasteditdate}</if>
        </set>
        where NEWSID = #{newsid}
    </update>
    
    <delete id="delete">
        delete from PUB_NEWS where NEWSID = #{value}
    </delete>
    
    <delete id="deleteBatch">
        delete from PUB_NEWS where NEWSID in
        <foreach item="newsid" collection="array" open="(" separator="," close=")">
            #{newsid}
        </foreach>
    </delete>
    
    <select id="queryPubNewsWithSEQ" resultType="int">
        SELECT currval('PUB_NEWS_SEQ') FROM DUAL
    </select>
    
    <select id="queryTopList" resultType="com.landtool.lanbase.modules.sys.entity.PubNewsApi">
        SELECT tmp.*,row_number() over() as rownumber from (select * from PUB_NEWS order by CREATEDATE desc) tmp WHERE  <![CDATA[ rownumber <= ${num} ]]>
    </select>
 
    <select id="queryAllList" resultType="com.landtool.lanbase.modules.sys.entity.PubNews">
        SELECT PUB_NEWS.*,ORG_USER.chinesename as createusername FROM PUB_NEWS
        left join ORG_USER on PUB_NEWS.createuser = org_user.userid
        <where>
            <if test="title!=null and title != '' ">
                and TITLE like ('%' || #{title} || '%')
            </if>
            <if test="type != null and type != '' ">
                and type = #{type}
            </if>
        </where>
        order by CREATEDATE desc
    </select>
</mapper>