<?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>
|