系统管理-操作记录模块SQL 修改
This commit is contained in:
parent
5d38e04a88
commit
2e2de0ae3b
|
|
@ -9,17 +9,17 @@
|
||||||
</delete>
|
</delete>
|
||||||
<!--查询用户记录列表-->
|
<!--查询用户记录列表-->
|
||||||
<select id="getAppUserHistoryList" resultType="com.bonus.bmw.basic.entity.UserHistoryBean">
|
<select id="getAppUserHistoryList" resultType="com.bonus.bmw.basic.entity.UserHistoryBean">
|
||||||
select ala."id" as id,ala.USER_ID as userId,su.USERNAME as userName,su."phone",ala.DEVICE_ID as deviceId,ala.DEVICE_MODEL as deviceMode,
|
select ala."id" as id,ala."user_id" as userId,su."username" as userName,su."phone",ala."device_id" as deviceId,ala."device_model" as deviceMode,
|
||||||
ala.ANDROID_VERSION as androidVersion,ala.LOGIN_DATE as loginDate,ala.LOGIN_TIME as loginTime
|
ala."android_version" as androidVersion,ala."login_date" as loginDate,ala."login_time" as loginTime
|
||||||
from "ynrealname"."app_login_audit" ala
|
from "ynrealname"."app_login_audit" ala
|
||||||
left join "ynrealname"."sys_user" su on su."id" = ala.USER_ID
|
left join "ynrealname"."sys_user" su on su."id" = ala."user_id"
|
||||||
where ala."is_active" = '1'
|
where ala."is_active" = '1'
|
||||||
and ala.LOGIN_DATE BETWEEN #{params.startTime} and #{params.endTime}
|
and ala."login_date" BETWEEN #{params.startTime} and #{params.endTime}
|
||||||
<if test="params.keyWord != null and params.keyWord!='' ">
|
<if test="params.keyWord != null and params.keyWord!='' ">
|
||||||
and (
|
and (
|
||||||
su.USERNAME like concat ('%',#{params.keyWord},'%') or
|
su."username" like '%' || #{params.keyWord} || '%' or
|
||||||
ala.DEVICE_ID like concat ('%',#{params.keyWord},'%') or
|
ala."device_id" like '%' || #{params.keyWord} || '%' or
|
||||||
ala.DEVICE_MODEL like concat ('%',#{params.keyWord},'%')
|
ala."device_model" like '%' || #{params.keyWord} || '%'
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="offset != null and offset >= 0 and limit != null and limit >= 0">
|
<if test="offset != null and offset >= 0 and limit != null and limit >= 0">
|
||||||
|
|
@ -28,14 +28,14 @@
|
||||||
</select>
|
</select>
|
||||||
<select id="getAppUserHistoryCount" resultType="java.lang.Integer">
|
<select id="getAppUserHistoryCount" resultType="java.lang.Integer">
|
||||||
select COUNT(1) from "ynrealname"."app_login_audit" ala
|
select COUNT(1) from "ynrealname"."app_login_audit" ala
|
||||||
left join "ynrealname"."sys_user" su on su."id" = ala.USER_ID
|
left join "ynrealname"."sys_user" su on su."id" = ala."user_id"
|
||||||
where ala."is_active" = '1'
|
where ala."is_active" = '1'
|
||||||
and ala.LOGIN_DATE BETWEEN #{params.startTime} and #{params.endTime}
|
and ala."login_date" BETWEEN #{params.startTime} and #{params.endTime}
|
||||||
<if test="params.keyWord != null and params.keyWord!='' ">
|
<if test="params.keyWord != null and params.keyWord!='' ">
|
||||||
and (
|
and (
|
||||||
su.USERNAME like concat ('%',#{params.keyWord},'%') or
|
su."username" like '%' || #{params.keyWord} || '%' or
|
||||||
ala.DEVICE_ID like concat ('%',#{params.keyWord},'%') or
|
ala."device_id" like '%' || #{params.keyWord} || '%' or
|
||||||
ala.DEVICE_MODEL like concat ('%',#{params.keyWord},'%')
|
ala."device_model" like '%' || #{params.keyWord} || '%'
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
|
|
@ -5,29 +5,29 @@
|
||||||
<mapper namespace="com.bonus.system.logs.dao.SysOperLogMapper">
|
<mapper namespace="com.bonus.system.logs.dao.SysOperLogMapper">
|
||||||
|
|
||||||
<sql id="selectOperLogVo">
|
<sql id="selectOperLogVo">
|
||||||
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_param, json_result, status, error_msg, oper_time
|
select "oper_id", "title", "business_type", "method", "request_method", "operator_type", "oper_name", "dept_name", "oper_url", "oper_ip", "oper_param", "json_result", "status", "error_msg", "oper_time"
|
||||||
from sys_oper_log
|
from "ynrealname"."sys_oper_log"
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="where">
|
<sql id="where">
|
||||||
<where>
|
<where>
|
||||||
a.opersTime BETWEEN CONCAT(#{params.startTime},' 00:00:00') and CONCAT(#{params.endTime},' 23:59:59')
|
a."opersTime" BETWEEN #{params.startTime} || ' 00:00:00' and #{params.endTime} || ' 23:59:59'
|
||||||
<if test="params != null">
|
<if test="params != null">
|
||||||
<if test="params.type != null and params.type != ''">
|
<if test="params.type != null and params.type != ''">
|
||||||
and a.operatoType = #{params.type}
|
and a."operatoType" = #{params.type}
|
||||||
</if>
|
</if>
|
||||||
<if test="params.module != null and params.module != ''">
|
<if test="params.module != null and params.module != ''">
|
||||||
and locate(#{params.module},a.title) > 0
|
and INSTR(a."title", #{params.module}) > 0
|
||||||
</if>
|
</if>
|
||||||
<if test="params.result != null and params.result != ''">
|
<if test="params.result != null and params.result != ''">
|
||||||
and locate(#{params.result},a.jsonResult) > 0
|
and INSTR(a."jsonResult", #{params.result}) > 0
|
||||||
</if>
|
</if>
|
||||||
<if test="params.keyWord != null and params.keyWord != ''">
|
<if test="params.keyWord != null and params.keyWord != ''">
|
||||||
and (
|
and (
|
||||||
a.title like concat('%', #{params.keyWord}, '%') or
|
a."title" like '%' || #{params.keyWord} || '%' or
|
||||||
a.type like concat('%', #{params.keyWord}, '%') or
|
a."type" like '%' || #{params.keyWord} || '%' or
|
||||||
a.operName like concat('%', #{params.keyWord}, '%') or
|
a."operName" like '%' || #{params.keyWord} || '%' or
|
||||||
a.phone like concat('%', #{params.keyWord}, '%')
|
a."phone" like '%' || #{params.keyWord} || '%'
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -35,43 +35,43 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<insert id="insertOperlog">
|
<insert id="insertOperlog">
|
||||||
insert into "ynrealname"."sys_oper_log"("title", "user_id","business_type", "method", "request_method", "operator_type", "oper_url", "oper_ip", "oper_param", "json_result", "status", "error_msg")
|
insert into "ynrealname"."sys_oper_log"("title", "user_id","business_type", "method", "request_method", "operator_type", "oper_url", "oper_ip", "oper_param", "json_result", "status", "error_msg")
|
||||||
values (#{title}, #{userId}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operUrl}, #{operIp}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg})
|
values (#{title}, #{userId}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operUrl}, #{operIp}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="selectOperLogList" resultType="com.bonus.system.api.domain.SysOperLog">
|
<select id="selectOperLogList" resultType="com.bonus.system.api.domain.SysOperLog">
|
||||||
<include refid="selectOperLogVo"/>
|
<include refid="selectOperLogVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="title != null and title != ''">
|
<if test="title != null and title != ''">
|
||||||
AND title like concat('%', #{title}, '%')
|
AND "title" like '%' || #{title} || '%'
|
||||||
</if>
|
</if>
|
||||||
<if test="businessType != null">
|
<if test="businessType != null">
|
||||||
AND business_type = #{businessType}
|
AND "business_type" = #{businessType}
|
||||||
</if>
|
</if>
|
||||||
<if test="businessTypes != null and businessTypes.length > 0">
|
<if test="businessTypes != null and businessTypes.length > 0">
|
||||||
AND business_type in
|
AND "business_type" in
|
||||||
<foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
|
<foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
|
||||||
#{businessType}
|
#{businessType}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="status != null">
|
<if test="status != null">
|
||||||
AND status = #{status}
|
AND "status" = #{status}
|
||||||
</if>
|
</if>
|
||||||
<if test="operName != null and operName != ''">
|
<if test="operName != null and operName != ''">
|
||||||
AND oper_name like concat('%', #{operName}, '%')
|
AND "oper_name" like '%' || #{operName} || '%'
|
||||||
</if>
|
</if>
|
||||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
and date_format(oper_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
and to_char("oper_time", 'YYYYMMDD') >= to_char(to_date(#{params.beginTime}, 'YYYY-MM-DD'), 'YYYYMMDD')
|
||||||
</if>
|
</if>
|
||||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
and date_format(oper_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
and to_char("oper_time", 'YYYYMMDD') <= to_char(to_date(#{params.endTime}, 'YYYY-MM-DD'), 'YYYYMMDD')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by oper_id desc
|
order by "oper_id" desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<delete id="deleteOperLogByIds" parameterType="Long">
|
<delete id="deleteOperLogByIds" parameterType="Long">
|
||||||
delete from sys_oper_log where oper_id in
|
delete from "ynrealname"."sys_oper_log" where "oper_id" in
|
||||||
<foreach collection="array" item="operId" open="(" separator="," close=")">
|
<foreach collection="array" item="operId" open="(" separator="," close=")">
|
||||||
#{operId}
|
#{operId}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
@ -79,40 +79,40 @@
|
||||||
|
|
||||||
<select id="selectOperLogById" parameterType="Long" resultType="com.bonus.system.api.domain.SysOperLog">
|
<select id="selectOperLogById" parameterType="Long" resultType="com.bonus.system.api.domain.SysOperLog">
|
||||||
<include refid="selectOperLogVo"/>
|
<include refid="selectOperLogVo"/>
|
||||||
where oper_id = #{operId}
|
where "oper_id" = #{operId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="count" resultType="java.lang.Integer">
|
<select id="count" resultType="java.lang.Integer">
|
||||||
SELECT
|
SELECT
|
||||||
count(1)
|
count(1)
|
||||||
FROM
|
FROM
|
||||||
sys_oper_log sol
|
"ynrealname"."sys_oper_log" sol
|
||||||
where
|
where
|
||||||
create_time BETWEEN CONCAT(#{params.startTime},' 00:00:00') and CONCAT(#{params.endTime},' 23:59:59')
|
"create_time" BETWEEN #{params.startTime} || ' 00:00:00' and #{params.endTime} || ' 23:59:59'
|
||||||
<if test="params.type != null and params.type != ''">
|
<if test="params.type != null and params.type != ''">
|
||||||
and operator_type = #{params.type}
|
and "operator_type" = #{params.type}
|
||||||
</if>
|
</if>
|
||||||
<if test="params.module != null and params.module != ''">
|
<if test="params.module != null and params.module != ''">
|
||||||
and locate(#{params.module},title) > 0
|
and INSTR("title", #{params.module}) > 0
|
||||||
</if>
|
</if>
|
||||||
<if test="params.result != null and params.result != ''">
|
<if test="params.result != null and params.result != ''">
|
||||||
and locate(#{params.result},json_result) > 0
|
and INSTR("json_result", #{params.result}) > 0
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="list" resultType="com.bonus.system.api.domain.SysOperLog">
|
<select id="list" resultType="com.bonus.system.api.domain.SysOperLog">
|
||||||
select
|
select
|
||||||
su.username AS operName,
|
su."username" AS operName,
|
||||||
su.phone,
|
su."phone",
|
||||||
a.*
|
a.*
|
||||||
from(
|
from(
|
||||||
SELECT
|
SELECT
|
||||||
user_id,
|
"user_id",
|
||||||
oper_id AS operId,
|
"oper_id" AS operId,
|
||||||
title,
|
"title",
|
||||||
json_result as jsonResult,
|
"json_result" as jsonResult,
|
||||||
CASE
|
CASE
|
||||||
business_type
|
"business_type"
|
||||||
WHEN 1 THEN '查询'
|
WHEN 1 THEN '查询'
|
||||||
WHEN 2 THEN '新增'
|
WHEN 2 THEN '新增'
|
||||||
WHEN 3 THEN '修改'
|
WHEN 3 THEN '修改'
|
||||||
|
|
@ -126,35 +126,35 @@
|
||||||
ELSE '其他'
|
ELSE '其他'
|
||||||
END AS type,
|
END AS type,
|
||||||
CASE
|
CASE
|
||||||
operator_type
|
"operator_type"
|
||||||
WHEN 1 THEN '后台'
|
WHEN 1 THEN '后台'
|
||||||
WHEN 2 THEN 'APP'
|
WHEN 2 THEN 'APP'
|
||||||
ELSE '其他'
|
ELSE '其他'
|
||||||
END AS operatoType ,
|
END AS operatoType ,
|
||||||
create_time AS opersTime
|
"create_time" AS opersTime
|
||||||
FROM
|
FROM
|
||||||
sys_oper_log
|
"ynrealname"."sys_oper_log"
|
||||||
where
|
where
|
||||||
create_time BETWEEN CONCAT(#{params.startTime},' 00:00:00') and CONCAT(#{params.endTime},' 23:59:59')
|
"create_time" BETWEEN #{params.startTime} || ' 00:00:00' and #{params.endTime} || ' 23:59:59'
|
||||||
<if test="params.type != null and params.type != ''">
|
<if test="params.type != null and params.type != ''">
|
||||||
and operator_type = #{params.type}
|
and "operator_type" = #{params.type}
|
||||||
</if>
|
</if>
|
||||||
<if test="params.module != null and params.module != ''">
|
<if test="params.module != null and params.module != ''">
|
||||||
and locate(#{params.module},title) > 0
|
and INSTR("title", #{params.module}) > 0
|
||||||
</if>
|
</if>
|
||||||
<if test="params.result != null and params.result != ''">
|
<if test="params.result != null and params.result != ''">
|
||||||
and locate(#{params.result},json_result) > 0
|
and INSTR("json_result", #{params.result}) > 0
|
||||||
</if>
|
</if>
|
||||||
) a
|
) a
|
||||||
LEFT JOIN sys_user su ON su.id = a.user_id
|
LEFT JOIN "ynrealname"."sys_user" su ON su."id" = a."user_id"
|
||||||
order by a.opersTime DESC
|
order by a.opersTime DESC
|
||||||
<if test="offset != null and offset >= 0 and limit != null and limit >= 0">
|
<if test="offset != null and offset >= 0 and limit != null and limit >= 0">
|
||||||
limit #{offset}, #{limit}
|
OFFSET #{offset} ROWS FETCH NEXT #{limit} ROWS ONLY
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="cleanOperLog">
|
<update id="cleanOperLog">
|
||||||
truncate table sys_oper_log
|
truncate table "ynrealname"."sys_oper_log"
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue