<?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.yunfeiyun.agmp.common.web.system.mapper.SysOperLogMapper">

	<resultMap type="SysOperLog" id="SysOperLogResult">
		<id     property="operId"         column="operId"        />
		<result property="operTitle"          column="operTitle"          />
		<result property="operBustype"   column="operBustype"  />
		<result property="operMethod"         column="operMethod"         />
		<result property="operReqmethod"   column="operReqmethod"  />
		<result property="operName"       column="operName"      />
		<result property="operDeptname"       column="operDeptname"      />
		<result property="operUrl"        column="operUrl"       />
		<result property="operIp"         column="operIp"        />
		<result property="operLocation"   column="operLocation"  />
		<result property="operParam"      column="operParam"     />
		<result property="operJsonresult"     column="operJsonresult"    />
		<result property="operStatus"         column="operStatus"         />
		<result property="operErrormsg"       column="operErrormsg"      />
		<result property="operTime"       column="operTime"      />
		<result property="operCosttime"       column="operCosttime"      />
	</resultMap>

	<sql id="selectOperLogVo">
        select operId, operTitle, operBustype, operMethod, operReqmethod, operType, operName, operDeptname, operUrl, operIp, operLocation, operParam, operJsonresult, operStatus, operErrormsg, operTime, operCosttime
        from SysOperLog
    </sql>
    
	<insert id="insertOperlog" parameterType="SysOperLog">
		insert into SysOperLog(operId, operTitle, operBustype, operMethod, operReqmethod, operType, operName, operDeptname, operUrl, operIp, operLocation, operParam, operJsonresult, operStatus, operErrormsg, operCosttime, operTime)
        values (#{operId},#{operTitle}, #{operBustype}, #{operMethod}, #{operReqmethod}, #{operType}, #{operName}, #{operDeptname}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{operJsonresult}, #{operStatus}, #{operErrormsg}, #{operCosttime}, date_format(sysdate(),'%Y-%m-%d %H:%i:%s') )
	</insert>
	
	<select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult">
		<include refid="selectOperLogVo"/>
		<where>
			<if test="operTitle != null and operTitle != ''">
				AND operTitle like concat('%', #{operTitle}, '%')
			</if>
			<if test="operBustype != null">
				AND operBustype = #{operBustype}
			</if>
			<if test="businessTypes != null and businessTypes.length > 0">
			    AND operBustype in
			    <foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
		 			#{operBustype}
		        </foreach> 
			</if>
			<if test="operStatus != null">
				AND operStatus = #{operStatus}
			</if>
			<if test="operName != null and operName != ''">
				AND operName like concat('%', #{operName}, '%')
			</if>
			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
				AND operTime &gt;= #{params.beginTime}
			</if>
			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
				AND operTime &lt;= #{params.endTime}
			</if>
		</where>
		order by operId desc
	</select>
	
	<delete id="deleteOperLogByIds" parameterType="String">
 		delete from SysOperLog where operId in
 		<foreach collection="array" item="operId" open="(" separator="," close=")">
 			#{operId}
        </foreach> 
 	</delete>
 	
 	<select id="selectOperLogById" parameterType="String" resultMap="SysOperLogResult">
		<include refid="selectOperLogVo"/>
		where operId = #{operId}
	</select>
	
	<update id="cleanOperLog">
        truncate table SysOperLog
    </update>

</mapper> 