<?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="cn.roadm.mapper.LogInfoMapper">

	<resultMap type="LogInfo" id="LogInfoResultMap">
		<id column="id" property="id" />
		<result column="username" property="username" />
		<result column="operate_type" property="operate_type" />
		<result column="opearte_result" property="opearte_result" />
		<result column="opearte_content" property="opearte_content" />
		<result column="createtime" property="createtime" />
		<result column="ip" property="ip" />
		<result column="sp_id" property="sp_id" />
		<result column="operate_module" property="operate_module" />
		<result column="operate_method" property="operate_method" />
	</resultMap>


	<select id="listPageSystemLog" parameterType="LogInfo"
		resultMap="LogInfoResultMap">
		select o.id,
		o.username,
		ot.operate_type,
		o.opearte_result,
		o.opearte_content,
		o.createtime,
		o.ip,
		o.sp_id
		from sms_operate_log o, sms_operate_type ot
		where ot.id = o.opearte_type
		<if test="role!=null and role!=''">
			and username != 'admin'
		</if>
		<if test="opearte_content!=null and opearte_content!=''">
			and o.opearte_content like CONCAT('%',#{opearte_content},'%')
		</if>
		<if test="username!=null and username!=''">
			and o.username =#{username}
		</if>
		<if test="operate_type!=null and operate_type!=''">
			and ot.id =#{operate_type}
		</if>
		<if test="starttime!=null and starttime!=''">
			and o.createtime&gt;=str_to_date(#{starttime},'%Y-%m-%d')
		</if>
		<if test="endtime!=null and endtime!=''">
			and
			o.createtime&lt;=DATE_ADD(str_to_date(#{endtime},'%Y-%m-%d'),INTERVAL
			1 DAY)
		</if>
		order by o.createtime desc
	</select>

	<select id="getOpearType" resultMap="LogInfoResultMap">
		select id, operate_type, operate_module, operate_method 
		from sms_operate_type 
		where operate_module is not null
		and operate_method is not null
		order by operate_type
	</select>

	<select id="getLogServiceConfig" resultType="cn.roadm.bo.LogServiceConfig">
		select id, service_name, service, ip,status,log_path,log_name,createtime
		from sms_log_service_config
		where status =0
		order by createtime
	</select>

	<select id="getLogServiceConfigByService" resultType="cn.roadm.bo.LogServiceConfig">
		select id, service_name, service, ip,status,log_path,log_name,createtime
		from sms_log_service_config
		where status =0 and service = #{service}
		order by createtime
	</select>
	
</mapper>