<?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.res.dao.Res_ActionRecordMapper" >
|
<resultMap id="BaseResultMap" type="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" >
|
<id column="ACTIONID" property="actionid" jdbcType="DECIMAL" />
|
<result column="RESOURCEID" property="resourceid" jdbcType="DECIMAL" />
|
<result column="USERID" property="userid" jdbcType="DECIMAL" />
|
<result column="APPID" property="appid" jdbcType="DECIMAL" />
|
<result column="ACTIONTIME" property="actiontime" jdbcType="TIMESTAMP" />
|
<result column="ACTIONTYPE" property="actiontype" jdbcType="OTHER" />
|
<result column="IP" property="ip" jdbcType="OTHER"/>
|
</resultMap>
|
<sql id="Base_Column_List" >
|
ACTIONID, RESOURCEID, USERID, APPID, ACTIONTIME, ACTIONTYPE,IP
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
|
select
|
<include refid="Base_Column_List" />
|
from RES_ACTIONRECORD
|
where ACTIONID = #{actionid,jdbcType=DECIMAL}
|
</select>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
|
delete from RES_ACTIONRECORD
|
where ACTIONID = #{actionid,jdbcType=DECIMAL}
|
</delete>
|
<insert id="insert" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" >
|
insert into RES_ACTIONRECORD (ACTIONID, RESOURCEID, USERID, APPID, ACTIONTIME, ACTIONTYPE,IP)
|
values (#{actionid,jdbcType=DECIMAL}, #{resourceid,jdbcType=DECIMAL}, #{userid,jdbcType=DECIMAL},
|
#{appid,jdbcType=DECIMAL}, #{actiontime,jdbcType=TIMESTAMP}, #{actiontype,jdbcType=OTHER}, #{ip,jdbcType=OTHER}
|
)
|
</insert>
|
<insert id="insertSelective" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" >
|
insert into RES_ACTIONRECORD
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="resourceid != null" >
|
RESOURCEID,
|
</if>
|
<if test="userid != null" >
|
USERID,
|
</if>
|
<if test="appid != null" >
|
APPID,
|
</if>
|
<if test="actiontime != null" >
|
ACTIONTIME,
|
</if>
|
<if test="actiontype != null" >
|
ACTIONTYPE,
|
</if>
|
<if test="ip != null" >
|
IP,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="resourceid != null" >
|
#{resourceid,jdbcType=DECIMAL},
|
</if>
|
<if test="userid != null" >
|
#{userid,jdbcType=DECIMAL},
|
</if>
|
<if test="appid != null" >
|
#{appid,jdbcType=DECIMAL},
|
</if>
|
<if test="actiontime != null" >
|
#{actiontime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="actiontype != null" >
|
#{actiontype,jdbcType=OTHER},
|
</if>
|
<if test="ip != null" >
|
#{ip,jdbcType=OTHER},
|
</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKeySelective" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" >
|
update RES_ACTIONRECORD
|
<set >
|
<if test="resourceid != null" >
|
RESOURCEID = #{resourceid,jdbcType=DECIMAL},
|
</if>
|
<if test="userid != null" >
|
USERID = #{userid,jdbcType=DECIMAL},
|
</if>
|
<if test="appid != null" >
|
APPID = #{appid,jdbcType=DECIMAL},
|
</if>
|
<if test="actiontime != null" >
|
ACTIONTIME = #{actiontime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="actiontype != null" >
|
ACTIONTYPE = #{actiontype,jdbcType=OTHER},
|
</if>
|
<if test="ip != null" >
|
IP = #{ip,jdbcType=OTHER},
|
</if>
|
</set>
|
where ACTIONID = #{actionid,jdbcType=DECIMAL}
|
</update>
|
<update id="updateByPrimaryKey" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" >
|
update RES_ACTIONRECORD
|
set RESOURCEID = #{resourceid,jdbcType=DECIMAL},
|
USERID = #{userid,jdbcType=DECIMAL},
|
APPID = #{appid,jdbcType=DECIMAL},
|
ACTIONTIME = #{actiontime,jdbcType=TIMESTAMP},
|
ACTIONTYPE = #{actiontype,jdbcType=OTHER},
|
IP = #{ip,jdbcType=OTHER}
|
where ACTIONID = #{actionid,jdbcType=DECIMAL}
|
</update>
|
|
<select id="selectByActiontype" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord" >
|
|
WITH tab as(
|
SELECT row_number() over(ORDER BY b.ACTIONTIME DESC) rn, a.RESOURCEID, a.TITLE, a.ABBREVIATION, a.RESOURCECLASS, a.PUBUNITID, a.PUBDATE, b.USERID, b.ACTIONTIME, b.ACTIONTYPE,b.IP from RES_MAININFO a left join RES_ACTIONRECORD b on(a.resourceid=b.resourceid)
|
where USERID = #{userid,jdbcType=DECIMAL} and ACTIONTYPE = #{actiontype,jdbcType=VARCHAR} and RESOURCESTATUS=0 and AUDITSTATUS=2
|
<if test="isDiTuFuwu != null and isDiTuFuwu != ''">
|
and a.RESOURCECLASS in ( ${isDiTuFuwu} )
|
</if>
|
)
|
|
SELECT * from tab WHERE <![CDATA[ rn <= 10 ]]>
|
</select>
|
<select id="getUserActionRecord" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" resultType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord">
|
SELECT
|
<include refid="Base_Column_List" />
|
FROM RES_ACTIONRECORD
|
WHERE USERID = #{userid,jdbcType=DECIMAL} and ACTIONTYPE = #{actiontype,jdbcType=OTHER} and RESOURCEID = #{resourceid,jdbcType=DECIMAL}
|
</select>
|
|
<select id="selectResourceCount" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" resultType="java.lang.Integer">
|
SELECT COUNT(*) from RES_ACTIONRECORD where RESOURCEID = #{resourceid,jdbcType=DECIMAL} AND ACTIONTYPE = #{actiontype,jdbcType=OTHER}
|
<if test="appid != null and appid != '' ">
|
and appid = #{appid}
|
</if>
|
</select>
|
|
<select id="selectFangWenPaiHang" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
|
|
WITH tab as(
|
select row_number() over(ORDER BY t desc) rn, v.* from (
|
SELECT COUNT(*) AS t, a.TITLE,a.RESOURCEID FROM RES_MAININFO a INNER JOIN RES_ACTIONRECORD b ON a.RESOURCEID = b.RESOURCEID where RESOURCESTATUS=0 and AUDITSTATUS=2 and b.ACTIONTYPE = '浏览' GROUP BY a.TITLE, a.RESOURCEID
|
) v
|
)
|
|
SELECT * from tab where <![CDATA[ rn <= 10 ]]>
|
</select>
|
|
<select id="selectResMainInfoWodeShouCang" parameterType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord"
|
resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord">
|
select a.RESOURCEID, a.TITLE, a.ABBREVIATION, a.RESOURCECLASS, a.PUBUNITID, a.PUBDATE, b.USERID, b.ACTIONTIME, b.ACTIONTYPE,b.IP
|
from RES_MAININFO a inner join RES_ACTIONRECORD b on(a.resourceid=b.resourceid)
|
<where>
|
and USERID = #{userid,jdbcType=DECIMAL} and ACTIONTYPE = #{actiontype,jdbcType=OTHER} and RESOURCESTATUS=0 and AUDITSTATUS=2
|
<if test="title!=null and title != '' ">
|
and (TITLE like '%'||#{title}||'%' OR replace(KEYWORDS,',','') like '%'||#{title}||'%' OR ABBREVIATION like '%'||#{title}||'%')
|
</if>
|
<if test="resourceclass !=null and resourceclass != '' ">
|
<!--and resourceclass=#{resourceclass,jdbcType=OTHER}-->
|
and (resourceclass like #{resourceclass} || '%' )
|
</if>
|
<if test="pubdateBegin!=null and pubdateBegin != '' ">
|
and ACTIONTIME >= to_timestamp(#{pubdateBegin} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss')
|
</if>
|
<if test="pubdatefinish!=null and pubdatefinish != '' ">
|
<![CDATA[ and ACTIONTIME <= to_timestamp(#{pubdatefinish} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
|
</if>
|
|
</where>
|
order by b.ACTIONTIME desc
|
</select>
|
|
<select id="selectResMainInfoZuiXinZiYuan" parameterType="com.landtool.lanbase.modules.res.entity.Res_MainInfo" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
|
select a.RESOURCEID, a.TITLE, a.ABBREVIATION, a.RESOURCECLASS, a.PUBUNITID, a.PUBDATE
|
from RES_MAININFO a
|
<where>
|
and 1=1 and RESOURCESTATUS=0 and AUDITSTATUS=2
|
<if test="title!=null and title != '' ">
|
and (TITLE like '%'||#{title}||'%' OR replace(KEYWORDS,',','') like '%'||#{title}||'%' OR ABBREVIATION like '%'||#{title}||'%')
|
</if>
|
<if test="resourceclass !=null and resourceclass != '' ">
|
<!--and resourceclass=#{resourceclass,jdbcType=OTHER}-->
|
and (resourceclass like #{resourceclass} || '%' )
|
</if>
|
<if test="pubdateBegin!=null and pubdateBegin != '' ">
|
and PUBDATE >= to_timestamp(#{pubdateBegin} || ' 00:00:00' ,'yyyy-mm-dd hh24:mi:ss')
|
</if>
|
<if test="pubdatefinish!=null and pubdatefinish != '' ">
|
<![CDATA[ and PUBDATE <= to_timestamp(#{pubdatefinish} || ' 23:59:59' ,'yyyy-mm-dd hh24:mi:ss') ]]>
|
</if>
|
|
</where>
|
order by pubdate desc
|
</select>
|
|
<!--获取 N 条记录-->
|
<select id="getTopList" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
|
WITH tab as(
|
select row_number() over(order by ActionTotal desc) rn, v.* from (
|
select m.TITLE, m.RESOURCEID, count(*) as ActionTotal from RES_ACTIONRECORD a
|
inner join RES_MAININFO m on a.RESOURCEID = m.RESOURCEID
|
where RESOURCESTATUS = 0 and AUDITSTATUS = 2 and a.ACTIONTYPE = #{actionType, jdbcType = OTHER}
|
<if test="userId != -1">and userId = #{userId, jdbcType = OTHER}
|
and m.RESOURCECLASS in ( ${isDiTuFuwu} )</if>
|
<if test="isDiTuFuwu != ''">
|
and m.RESOURCECLASS in ( ${isDiTuFuwu} )
|
</if>
|
group by m.TITLE, m.RESOURCEID
|
) v
|
)
|
SELECT * from tab WHERE <![CDATA[ rn <= ${num} ]]>
|
</select>
|
|
<select id="getListFWPH" parameterType="com.landtool.lanbase.modules.res.entity.Res_MainInfo" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
|
select * from(select COUNT(*) AS t,a.title,a.resourceid,a.resourceclass,a.pubdate,a.pubunitid
|
from RES_MAININFO a inner join RES_ACTIONRECORD b on(a.resourceid=b.resourceid)
|
<where>
|
AUDITSTATUS = 2 and RESOURCESTATUS = 0 AND RESOURCECLASS in ( ${isDiTuFuwu} ) and b.ACTIONTYPE = '浏览'
|
<if test="title!=null and title != '' ">
|
and (TITLE like '%'||#{title}||'%' OR replace(KEYWORDS,',','') like '%'||#{title}||'%' OR ABBREVIATION like '%'||#{title}||'%')
|
</if>
|
<if test="resourceclass !=null and resourceclass != '' ">
|
and (resourceclass like #{resourceclass} || '%' )
|
</if>
|
<if test="createuserid!=null and createuserid != '' ">
|
and createuserid = #{createuserid,dbcType=OTHERj}
|
</if>
|
<if test="catlogid!=null and catlogid != '' ">
|
and catlogid = #{catlogid,jdbcType=OTHER}
|
</if>
|
<if test="pubdateBegin!=null and pubdateBegin != '' ">
|
and PUBDATE >= to_timestamp(#{pubdateBegin} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss')
|
</if>
|
<if test="pubdatefinish!=null and pubdatefinish != '' ">
|
<![CDATA[ and PUBDATE <= to_timestamp(#{pubdatefinish} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
|
</if>
|
group by a.title,a.resourceid,a.resourceclass,a.pubdate,a.pubunitid
|
</where>) v order by t desc
|
</select>
|
<select id="getListWDSC" parameterType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord" resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord">
|
select a.RESOURCEID, a.TITLE, a.ABBREVIATION, a.RESOURCECLASS, a.PUBUNITID, a.PUBDATE, b.USERID, b.ACTIONTIME, b.ACTIONTYPE
|
from RES_MAININFO a inner join RES_ACTIONRECORD b on(a.resourceid = b.resourceid)
|
<where>
|
RESOURCESTATUS = 0 and AUDITSTATUS = 2 AND RESOURCECLASS in ( ${isDiTuFuwu} )
|
and USERID = #{userid, jdbcType = DECIMAL} and ACTIONTYPE = #{actiontype, jdbcType = OTHER}
|
<if test = "title != null and title != '' ">
|
and (TITLE like '%'||#{title}||'%' OR replace(KEYWORDS,',','') like '%'||#{title}||'%' OR ABBREVIATION like '%'||#{title}||'%')
|
</if>
|
<if test="resourceclass !=null and resourceclass != '' ">
|
and (resourceclass like #{resourceclass} || '%' )
|
</if>
|
<if test="pubdateBegin!=null and pubdateBegin != '' ">
|
and ACTIONTIME >= to_timestamp(#{pubdateBegin} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss')
|
</if>
|
<if test="pubdatefinish!=null and pubdatefinish != '' ">
|
<![CDATA[ and ACTIONTIME <= to_timestamp(#{pubdatefinish} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
|
</if>
|
</where>
|
order by b.ACTIONTIME desc
|
</select>
|
|
<select id="selectActionRecordJoinMainInfo" parameterType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord"
|
resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord">
|
select RES_ACTIONRECORD.*,CREATEUSERID,TITLE,ABBREVIATION,KEYWORDS from RES_ACTIONRECORD left join RES_MAININFO on RES_ACTIONRECORD.RESOURCEID = RES_MAININFO.RESOURCEID
|
<where>
|
<if test="title!=null and title != '' ">
|
and (TITLE like '%'||#{title}||'%' OR replace(KEYWORDS,',','') like '%'||#{title}||'%' OR ABBREVIATION like '%'||#{title}||'%')
|
</if>
|
<if test="actiontimebegin!=null and actiontimebegin != '' ">
|
and actiontime >= to_timestamp(#{actiontimebegin} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss')
|
</if>
|
<if test="actiontimefinish!=null and actiontimefinish != '' ">
|
<![CDATA[ and actiontime <= to_timestamp(#{actiontimefinish} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
|
</if>
|
<if test="actiontype != null and actiontype != '' ">
|
and actiontype = #{actiontype}
|
</if>
|
<if test="existpermission !=null">
|
and CREATEUSERID=#{existpermission}
|
</if>
|
</where>
|
<if test="sort!=null and sort != '' ">
|
order by ${sort} ${dir}
|
</if>
|
<if test="sort==null">
|
order by ACTIONTIME DESC
|
</if>
|
</select>
|
|
<select id="selectCountByResourceid" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
|
select count(*) from RES_ACTIONRECORD
|
where resourceid = #{resourceid,jdbcType=DECIMAL}
|
</select>
|
|
<delete id="deleteByResourceid" parameterType="java.lang.Integer" >
|
delete from RES_ACTIONRECORD
|
where resourceid = #{resourceid,jdbcType=DECIMAL}
|
</delete>
|
|
<select id="selectKeyWordsByUserid" resultType="java.lang.String" parameterType="java.lang.Integer">
|
select distinct(KEYWORDS) from RES_MAININFO where RESOURCEID in (select distinct(RESOURCEID) from RES_ACTIONRECORD where
|
userid = #{userid}) and KEYWORDS is not null order by KEYWORDS
|
</select>
|
|
<select id="selectMainInfoRecommends" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
|
with tab as (
|
select KEYWORDS from RES_MAININFO a where exists (
|
select RESOURCEID from RES_ACTIONRECORD b where a.resourceid = b.resourceid and userid = #{userid} group by resourceid
|
) and KEYWORDS is not null group by KEYWORDS order by KEYWORDS
|
)
|
select * from RES_MAININFO a where exists(select KEYWORDS from tab b where a.keywords = b.keywords ) and RESOURCESTATUS=0
|
and AUDITSTATUS=2 and not
|
exists (select RESOURCEID from RES_ACTIONRECORD r where a.resourceid = r.resourceid and ACTIONTYPE = '收藏' and userid = #{userid})
|
<if test="isDiTuFuwu != null">
|
and RESOURCECLASS in ( ${isDiTuFuwu} )
|
</if>
|
order by CREATEDATE desc
|
</select>
|
|
<select id="queryAppByResourceid" resultType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord">
|
SELECT *
|
FROM(
|
SELECT DISTINCT la.appid,la.resourceid,actiontype FROM RES_ACTIONRECORD la
|
<where>
|
<if test="appid != null and appid!=''">
|
AND la.appid LIKE ('%' || #{appid} || '%')
|
</if>
|
<if test="actiontype != null and actiontype!=''">
|
AND la.actiontype = #{actiontype}
|
</if>
|
<if test="resourceid != null and resourceid!=''">
|
AND la.resourceid = #{resourceid}
|
</if>
|
<if test="ids != null and ids!=''">
|
AND appid in( ${ids} )
|
</if>
|
</where>
|
) B
|
</select>
|
|
<select id="queryAppActionCount" resultType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord">
|
SELECT COUNT(appid) as actioncount, appid FROM RES_ACTIONRECORD where ACTIONTYPE = '调用' and APPID is not null
|
<if test="ids != null and ids!=''">
|
AND appid in( ${ids} )
|
</if>
|
GROUP BY appid
|
</select>
|
|
<select id="queryResourceByAppid" resultType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord">
|
SELECT DISTINCT(a.RESOURCEID),b.title as resourcename,count(a.appid) as actioncount from RES_ACTIONRECORD a LEFT JOIN RES_MAININFO b on a.RESOURCEID = b.RESOURCEID where ACTIONTYPE = '调用' and APPID is not null
|
<if test="appid != null and appid!=''">
|
AND appid = #{appid}
|
</if>
|
GROUP BY title,a.RESOURCEID
|
</select>
|
</mapper>
|