<?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.fjs.scenic.mapper.system.LogsMapper">
	<resultMap id="BaseResultMap" type="com.fjs.scenic.entity.system.Logs">
		<id column="id" jdbcType="BIGINT" property="id" />
		<result column="user_id" jdbcType="BIGINT" property="userId" />
		<result column="manager_id" jdbcType="BIGINT" property="managerId" />
		<result column="type" jdbcType="TINYINT" property="type" />
		<result column="class_name" jdbcType="VARCHAR" property="className" />
		<result column="method_name" jdbcType="VARCHAR" property="methodName" />
		<result column="params" jdbcType="VARCHAR" property="params" />
		<result column="time" jdbcType="TIMESTAMP" property="time" />
		<result column="ip" jdbcType="VARCHAR" property="ip" />
	</resultMap>
	<sql id="Base_Column_List">
		id, user_id, manager_id, type, class_name, method_name,
		params, time, ip
	</sql>
	<select id="selectByPrimaryKey" parameterType="java.lang.Long"
		resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List" />
		from logs
		where id = #{id,jdbcType=BIGINT}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
		delete from logs
		where id = #{id,jdbcType=BIGINT}
	</delete>
	<insert id="insert" parameterType="com.fjs.scenic.entity.system.Logs">
		insert into logs (id, user_id,
		manager_id,
		type, class_name, method_name,
		params, time, ip,account,error_msg)
		values
		(#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
		#{managerId,jdbcType=BIGINT},
		#{type,jdbcType=TINYINT},
		#{className,jdbcType=VARCHAR}, #{methodName,jdbcType=VARCHAR},
		#{params,jdbcType=VARCHAR}, #{time,jdbcType=TIMESTAMP},
		#{ip,jdbcType=VARCHAR},#{account,jdbcType=VARCHAR},#{errorMsg,jdbcType=VARCHAR})
	</insert>
	<insert id="insertSelective" parameterType="com.fjs.scenic.entity.system.Logs">
		insert into logs
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="id != null">
				id,
			</if>
			<if test="userId != null">
				user_id,
			</if>
			<if test="managerId != null">
				manager_id,
			</if>
			<if test="type != null">
				type,
			</if>
			<if test="className != null">
				class_name,
			</if>
			<if test="methodName != null">
				method_name,
			</if>
			<if test="params != null">
				params,
			</if>
			<if test="time != null">
				time,
			</if>
			<if test="ip != null">
				ip,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="id != null">
				#{id,jdbcType=BIGINT},
			</if>
			<if test="userId != null">
				#{userId,jdbcType=BIGINT},
			</if>
			<if test="managerId != null">
				#{managerId,jdbcType=BIGINT},
			</if>
			<if test="type != null">
				#{type,jdbcType=TINYINT},
			</if>
			<if test="className != null">
				#{className,jdbcType=VARCHAR},
			</if>
			<if test="methodName != null">
				#{methodName,jdbcType=VARCHAR},
			</if>
			<if test="params != null">
				#{params,jdbcType=VARCHAR},
			</if>
			<if test="time != null">
				#{time,jdbcType=TIMESTAMP},
			</if>
			<if test="ip != null">
				#{ip,jdbcType=VARCHAR},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="com.fjs.scenic.entity.system.Logs">
		update logs
		<set>
			<if test="userId != null">
				user_id = #{userId,jdbcType=BIGINT},
			</if>
			<if test="managerId != null">
				manager_id = #{managerId,jdbcType=BIGINT},
			</if>
			<if test="type != null">
				type = #{type,jdbcType=TINYINT},
			</if>
			<if test="className != null">
				class_name = #{className,jdbcType=VARCHAR},
			</if>
			<if test="methodName != null">
				method_name = #{methodName,jdbcType=VARCHAR},
			</if>
			<if test="params != null">
				params = #{params,jdbcType=VARCHAR},
			</if>
			<if test="time != null">
				time = #{time,jdbcType=TIMESTAMP},
			</if>
			<if test="ip != null">
				ip = #{ip,jdbcType=VARCHAR},
			</if>
		</set>
		where id = #{id,jdbcType=BIGINT}
	</update>
	<update id="updateByPrimaryKey" parameterType="com.fjs.scenic.entity.system.Logs">
		update logs
		set
		user_id = #{userId,jdbcType=BIGINT},
		manager_id =
		#{managerId,jdbcType=BIGINT},
		type = #{type,jdbcType=TINYINT},
		class_name = #{className,jdbcType=VARCHAR},
		method_name =#{methodName,jdbcType=VARCHAR},
		params = #{params,jdbcType=VARCHAR},
		time = #{time,jdbcType=TIMESTAMP},
		ip = #{ip,jdbcType=VARCHAR}
		where id= #{id,jdbcType=BIGINT}
	</update>

	<select id="selectByCondition" parameterType="com.fjs.scenic.dto.LogsVo"
		resultType="map">
		SELECT * FROM `logs`
		<where>
			<if test="startTime != null ">
				and `time` &gt; #{startTime,jdbcType=TIMESTAMP}
			</if>
			<if test="endTime != null ">
				and `time` &lt; #{endTime,jdbcType=TIMESTAMP}
			</if>
			<if test="type != null ">
				and `type` = #{type,jdbcType=TIMESTAMP}
			</if>
		</where>
		ORDER BY id desc
	</select>
</mapper>