Files
jshERP/jshERP-boot/src/main/resources/mapper_xml/LogMapperEx.xml
2021-08-22 19:11:17 +08:00

77 lines
3.0 KiB
XML

<?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.jsh.erp.datasource.mappers.LogMapperEx">
<resultMap extends="com.jsh.erp.datasource.mappers.LogMapper.BaseResultMap" id="ResultExMap" type="com.jsh.erp.datasource.vo.LogVo4List">
<result column="userName" jdbcType="VARCHAR" property="userName" />
</resultMap>
<select id="selectByConditionLog" parameterType="com.jsh.erp.datasource.entities.LogExample" resultMap="ResultExMap">
select l.*,u.username userName
FROM jsh_log l
left join jsh_user u on l.user_id = u.id and ifnull(u.status,'0') not in('1','2')
where 1=1
<if test="operation != null">
<bind name="bindOperation" value="'%'+operation+'%'"/>
and l.operation like #{bindOperation}
</if>
<if test="userId != null">
and l.user_id=#{userId}
</if>
<if test="clientIp != null">
<bind name="bindClientIp" value="'%'+clientIp+'%'"/>
and l.client_ip like #{bindClientIp}
</if>
<if test="status != null">
and l.status=#{status}
</if>
<if test="beginTime != null">
and l.create_time &gt;= #{beginTime}
</if>
<if test="endTime != null">
and l.create_time &lt;= #{endTime}
</if>
<if test="content != null">
<bind name="bindContent" value="'%'+content+'%'"/>
and l.content like #{bindContent}
</if>
order by l.create_time desc
<if test="offset != null and rows != null">
limit #{offset},#{rows}
</if>
</select>
<select id="countsByLog" resultType="java.lang.Long">
SELECT
COUNT(1)
FROM jsh_log l
left join jsh_user u on l.user_id = u.id and ifnull(u.status,'0') not in('1','2')
WHERE 1=1
<if test="operation != null">
<bind name="bindOperation" value="'%'+operation+'%'"/>
and l.operation like #{bindOperation}
</if>
<if test="userId != null">
and l.user_id=#{userId}
</if>
<if test="clientIp != null">
<bind name="bindClientIp" value="'%'+clientIp+'%'"/>
and l.client_ip like #{bindClientIp}
</if>
<if test="status != null">
and l.status = #{status}
</if>
<if test="beginTime != null">
and l.create_time &gt;= #{beginTime}
</if>
<if test="endTime != null">
and l.create_time &lt;= #{endTime}
</if>
<if test="content != null">
<bind name="bindContent" value="'%'+content+'%'"/>
and l.content like #{bindContent}
</if>
</select>
<select id="getCountByIpAndDate" resultType="java.lang.Long">
select count(1) from jsh_log where operation=#{moduleName} and client_ip=#{clientIp} and create_time=#{createTime}
</select>
</mapper>