<?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.devplatform.admin.modules.sys.dao.SysCommandLogDao">
	<!-- Result Map -->
	<resultMap id="BaseResultMap" type="com.devplatform.admin.modules.sys.bean.SysCommandLog">
	    <result column="id" property="id"/>
	    <result column="com_source" property="comSource"/>
	    <result column="com_source_ip" property="comSourceIp"/>
	    <result column="com_source_port" property="comSourcePort"/>
	    <result column="com_type" property="comType"/>
	    <result column="com_mark" property="comMark"/>
	    <result column="resource_type" property="resourceType"/>
	    <result column="resource_id" property="resourceId"/>
	    <result column="result" property="result"/>
	    <result column="create_time" property="createTime"/>
	    <result column="create_user_id" property="createUserId"/>
	    <result column="create_user_name" property="createUserName"/>
	    <result column="deleted" property="deleted"/>
	    <result column="station_id" property="stationId"/>
	    <result column="byx1" property="byx1"/>
	    <result column="byx2" property="byx2"/>
	    <result column="byx3" property="byx3"/>
	</resultMap>

	<!-- sys_command_log table all fields -->
	<sql id="Base_Column_List">
		id,com_source,com_source_ip,com_source_port,com_type,com_mark,resource_type,resource_id,result,create_time,create_user_id,create_user_name,deleted,station_id,byx1,byx2,byx3
	</sql>

	<!-- 公共查询条件 -->
	<sql id="Example_Where_Clause">
		where t.deleted=0
		<if test="id!=null and id!=''">and t.id = #{id}</if>
		<if test="comSource!=null ">and t.com_source = #{comSource}</if>
		<if test="comSourceIp!=null and comSourceIp!=''">and t.com_source_ip = #{comSourceIp}</if>
		<if test="comSourcePort!=null and comSourcePort!=''">and t.com_source_port = #{comSourcePort}</if>
		<if test="comType!=null ">and t.com_type = #{comType}</if>
		<if test="comMark!=null and comMark!=''">and INSTR(t.com_mark, #{comMark})</if>
		<if test="resourceType!=null and resourceType!=''">and t.resource_type = #{resourceType}</if>
		<if test="resourceId!=null and resourceId!=''">and t.resource_id = #{resourceId}</if>
		<if test="result!=null ">and t.result = #{result}</if>
		<if test="createTime!=null ">and t.create_time = #{createTime}</if>
		<if test="createUserId!=null and createUserId!=''">and t.create_user_id = #{createUserId}</if>
		<if test="createUserName!=null and createUserName!=''">and t.create_user_name = #{createUserName}</if>
		<if test="deleted!=null ">and t.deleted = #{deleted}</if>
		<if test="stationId!=null and stationId!=''">and t.station_id = #{stationId}</if>
		<if test="byx1!=null and byx1!=''">and t.byx1 = #{byx1}</if>
		<if test="byx2!=null and byx2!=''">and t.byx2 = #{byx2}</if>
		<if test="byx3!=null and byx3!=''">and t.byx3 = #{byx3}</if>
		<if test="startTime != null and startTime != ''">
			and t.create_time &gt;= #{startTime}
		</if>
		<if test="endTime != null and endTime != ''">
			and t.create_time &lt;= #{endTime}
		</if>
	</sql>

	<select id="queryPageByCount" parameterType="Object" resultType="java.lang.Integer">
	select count(1) from sys_command_log t
	<include refid="Example_Where_Clause"/>
	</select>

	<select id="queryPageList" parameterType="Object" resultMap="BaseResultMap">
	select t.*,lr.name as resourceName from sys_command_log t
	left join li_resource lr on lr.id = t.resource_id
	<include refid="Example_Where_Clause"/>
	<if test="pager.orderCondition != null and pager.orderCondition != ''">
		${pager.orderCondition}
	</if>
	<if test="pager.mysqlQueryCondition != null and pager.mysqlQueryCondition != ''">
		${pager.mysqlQueryCondition}
	</if>
	</select>
	<select id="getBeanById" resultType="java.util.Map">
		select t.id,su.username as createUserName, t.create_time as createTime,t.result,t.com_type as comType,
		t.com_mark as comMark,t.com_source as comSource,
		lr.status,lr.code,lr.name as resourceName,sd.name as type from
		sys_command_log t
		left join li_resource lr on lr.id = t.resource_id
		left join sys_dictionary sd on sd.id = t.resource_type
		left join sys_user su on su.user_id = t.create_user_id
		where t.id = #{id}
	</select>

</mapper>


