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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?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.log.dao.LogActionDao">
 
    <!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="com.landtool.lanbase.modules.log.entity.LogAction" id="actionMap">
        <result property="actionid" column="ACTIONID"/>
        <result property="userid" column="USERID"/>
        <result property="appid" column="APPID"/>
        <result property="dodate" column="DODATE"/>
        <result property="largemodel" column="LARGEMODEL"/>
        <result property="smallmodel" column="SMALLMODEL"/>
        <result property="requesturl" column="REQUESTURL"/>
        <result property="requestip" column="REQUESTIP"/>
        <result property="remark" column="REMARK"/>
        <result property="actiontype" column="ACTIONTYPE"/>
        <result property="resourceid" column="RESOURCEID"/>
        <result property="title" column="TITLE"/>
    </resultMap>
 
 
    <select id="queryObject" resultType="com.landtool.lanbase.modules.log.entity.LogAction">
        select * from LOG_ACTION where ACTIONID = #{value}
    </select>
 
 
    <select id="queryList" resultType="com.landtool.lanbase.modules.log.entity.LogAction">
        select * from (
        SELECT *
        FROM(
            SELECT ROW_NUMBER() OVER(
            ORDER BY B.dodate DESC) AS rownumber,B.*
                FROM (
                    SELECT la.*,ssi.APPFULLNAME,os.CHINESENAME FROM LOG_ACTION la
                    LEFT JOIN SYS_SYSTEMINFO ssi ON la.appid=ssi.appid
                    LEFT JOIN ORG_USER os ON os.USERID=la.USERID
                where 1= 1
                    <if test="UserName != null and UserName!=''">
                        AND (os.CHINESENAME LIKE ('%' || #{UserName} || '%') or loginname like ('%' || #{UserName} || '%') or LOWER(os.spellfirst) like ('%' || LOWER(#{UserName}) || '%'))
                    </if>
                    <if test="appid != null and appid!=''">
                    /** modified by qufangxu **/
                        AND concat(la.appid) LIKE concat('%',#{appid},'%')
                    </if>
                    <if test="actiontype != null and actiontype!=''">
                        AND la.actiontype = #{actiontype}
                    </if>
                    <if test="beginDate != null and beginDate !=''">
                        and DODATE &gt;= to_timestamp(#{beginDate,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss')
                    </if>
                    <if test="endDate != null and endDate !=''">
                        <![CDATA[ AND DODATE <=to_timestamp(#{endDate,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss') ]]>
                    </if>
                    <if test="requestip != null and requestip != ''">
                        AND la.REQUESTIP LIKE ('%' || #{requestip} || '%')
                    </if>
            ) B
        ) A
        WHERE rownumber > #{lowerOffset} AND  <![CDATA[ rownumber <= ${upperOffset} ]]>
        )a order by  
        <choose>
            <when test="sidx != null and sidx != ''">
                ${sidx} ${order}
            </when>
            <otherwise>
                dodate DESC
            </otherwise>
        </choose>
    </select>
 
     <select id="queryTotal" resultType="int">
        select count(*) from LOG_ACTION la
        LEFT join SYS_SYSTEMINFO ssi on la.appid=ssi.appid
        LEFT join ORG_USER os on os.USERID=la.USERID  where 1=1
        <if test="UserName != null and UserName!=''">
            AND (os.CHINESENAME LIKE ('%' || #{UserName} || '%') or loginname LIKE ('%' || #{UserName} || '%') or LOWER(os.spellfirst) like  ('%' || LOWER(#{UserName}) || '%'))
        </if>
        <if test="appid != null and appid!=''">
            AND concat(la.appid) LIKE concat('%',#{appid},'%')
        </if>
        <if test="actiontype != null and actiontype!=''">
            AND la.actiontype = #{actiontype}
        </if>
        <if test="beginDate != null and beginDate !=''">
            AND DODATE &gt;= to_timestamp(#{beginDate,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss')
        </if>
        <if test="endDate != null and endDate !=''">
            <![CDATA[ AND DODATE <= to_timestamp(#{endDate,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss') ]]>
        </if>
        <if test="requestip != null and requestip != ''">
            AND la.REQUESTIP LIKE ('%' || #{requestip} || '%')
        </if>
    </select>
     
    <insert id="save" parameterType="com.landtool.lanbase.modules.log.entity.LogAction">
        insert into LOG_ACTION
        (
            USERID, 
            APPID, 
            DODATE, 
            LARGEMODEL, 
            SMALLMODEL, 
            REQUESTURL, 
            REQUESTIP, 
            REMARK,
            ACTIONTYPE,
            RESOURCEID,
            TITLE
        )
        values
        (
            #{userid,jdbcType=BIGINT}, 
            #{appid,jdbcType=BIGINT},
            now(),
            #{largemodel,jdbcType=VARCHAR}, 
            #{smallmodel,jdbcType=VARCHAR}, 
            #{requesturl,jdbcType=VARCHAR}, 
            #{requestip,jdbcType=VARCHAR}, 
            #{remark,jdbcType=VARCHAR},
            #{actiontype,jdbcType=VARCHAR},
            #{resourceid,jdbcType=BIGINT},
            #{title,jdbcType=VARCHAR}
        )
    </insert>
     
    <update id="update" parameterType="com.landtool.lanbase.modules.log.entity.LogAction">
        update LOG_ACTION
        <set>
            <if test="userid != null">USERID = #{userid}, </if>
            <if test="appid != null">APPID = #{appid}, </if>
            <if test="dodate != null">DODATE = #{dodate}, </if>
            <if test="largemodel != null">LARGEMODEL = #{largemodel}, </if>
            <if test="smallmodel != null">SMALLMODEL = #{smallmodel}, </if>
            <if test="requesturl != null">REQUESTURL = #{requesturl}, </if>
            <if test="requestip != null">REQUESTIP = #{requestip}, </if>
            <if test="remark != null">REMARK = #{remark},</if>
            <if test="resourceid != null">RESOURCEID = #{resourceid},</if>
            <if test="title != null">TITLE = #{title}</if>
        </set>
        where ACTIONID = #{actionid}
    </update>
    
    <delete id="delete">
        delete from LOG_ACTION where ACTIqueryListONID = #{value}
    </delete>
    
    <delete id="deleteBatch">
        delete from LOG_ACTION where ACTIONID in
        <foreach item="actionid" collection="array" open="(" separator="," close=")">
            #{actionid}
        </foreach>
    </delete>
    
    <select id="queryUserId" resultType="long">
        select userid from ORG_USER where loginname=#{UserName}
    </select>
    
    <select id="queryActionType" resultType="String">
        select actiontype from  LOG_ACTION where actiontype is not null group by actiontype
    </select>
 
 
    <select id="queryAnalyseResourceAction"  resultType="map" >
        SELECT * from (
                          select count(1) as count,title,l.USERID,CHINESENAME from LOG_ACTION  l
                                                                                   left JOIN ORG_USER o on l.USERID=o.USERID
                          where RESOURCEID is not null AND TITLE IS NOT NULL GROUP BY RESOURCEid,title,l.USERID,o.CHINESENAME
                      ) tmp
        where count>=#{count}
    </select>
</mapper>