<?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.scm.contract.dao.common.TOperatingLogDao">

	<sql id="tOperatingLogColumns">
		a.id AS "id",
		a.oper_time AS "operTime",
		a.oper_per_account AS "operPerAccount",
		a.oper_module AS "operModule",
		a.oper_action AS "operAction",
		a.oper_mainten_per AS "operMaintenPer",
		a.oper_url AS "operUrl",
		a.oper_contract_code AS "operContractCode",
		a.oper_purchase_apply_code AS "operPurchaseApplyCode",
		a.oper_order_code AS "operOrderCode",
		a.oper_submit_count AS "operSubmitCount",
		a.oper_remark AS "operRemark"
	</sql>

	<sql id="tOperatingLogJoins">
	</sql>
	
	<select id="get" resultType="com.scm.api.contract.entity.common.TOperatingLog">
		SELECT 
			<include refid="tOperatingLogColumns"/>
		FROM t_operating_log a
		<include refid="tOperatingLogJoins"/>
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultType="com.scm.api.contract.entity.common.TOperatingLog">
		SELECT 
			<include refid="tOperatingLogColumns"/>
		FROM t_operating_log a
		<include refid="tOperatingLogJoins"/>
		<where>
			<if test="id != null and id != ''">
				AND a.id = #{id}
			</if>
			<if test="beginOperTime != null and endOperTime != null ">
				AND a.oper_time BETWEEN #{beginOperTime} AND #{endOperTime}
			</if>
			<if test="operPerAccount != null and operPerAccount != ''">
				AND a.oper_per_account LIKE '%'||#{operPerAccount}||'%'
									
			</if>
			<if test="operModule != null and operModule != ''">
				AND a.oper_module LIKE '%'||#{operModule}||'%'
									
			</if>
			<if test="operAction != null and operAction != ''">
				AND a.oper_action LIKE '%'||#{operAction}||'%'
									
			</if>
			<if test="operUrl != null and operUrl != ''">
				AND a.oper_url LIKE '%'||#{operUrl}||'%'
									
			</if>
			<if test="operContractCode != null and operContractCode != ''">
				AND a.oper_contract_code LIKE '%'||#{operContractCode}||'%'
									
			</if>
			<if test="operPurchaseApplyCode != null and operPurchaseApplyCode != ''">
				AND a.oper_purchase_apply_code LIKE '%'||#{operPurchaseApplyCode}||'%'
									
			</if>
			<if test="operOrderCode != null and operOrderCode != ''">
				AND a.oper_order_code LIKE '%'||#{operOrderCode}||'%'
									
			</if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
		</choose>
	</select>
	
	<select id="findAllList" resultType="com.scm.api.contract.entity.common.TOperatingLog">
		SELECT 
			<include refid="tOperatingLogColumns"/>
		FROM t_operating_log a
		<include refid="tOperatingLogJoins"/>
		<where>
		</where>		
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
		</choose>
	</select>
	
	<insert id="insert">
		INSERT INTO t_operating_log(
			id,
			oper_time,
			oper_per_account,
			oper_module,
			oper_action,
			oper_mainten_per,
			oper_url,
			oper_contract_code,
			oper_purchase_apply_code,
			oper_order_code,
			oper_submit_count,
			oper_remark
		) VALUES (
			#{id},
			#{operTime},
			#{operPerAccount},
			#{operModule},
			#{operAction},
			#{operMaintenPer},
			#{operUrl},
			#{operContractCode},
			#{operPurchaseApplyCode},
			#{operOrderCode},
			#{operSubmitCount},
			#{operRemark}
		)
	</insert>
	
	<update id="update">
		UPDATE t_operating_log SET 	
			oper_time = #{operTime},
			oper_per_account = #{operPerAccount},
			oper_module = #{operModule},
			oper_action = #{operAction},
			oper_mainten_per = #{operMaintenPer},
			oper_url = #{operUrl},
			oper_contract_code = #{operContractCode},
			oper_purchase_apply_code = #{operPurchaseApplyCode},
			oper_order_code = #{operOrderCode},
			oper_submit_count = #{operSubmitCount},
			oper_remark = #{operRemark}
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<delete id="delete">
		DELETE FROM t_operating_log
		WHERE id = #{id}
	</delete>

	<!--批量删除物理删除-->
	<delete id="deleteBatch">
		DELETE FROM t_operating_log	
		WHERE id in
        <trim suffixOverrides=" OR id IN ()">
            <foreach item="item" index="index" collection="list"
                     open="(" close=")">
                <if test="index != 0">
                    <choose>
                        <when test="index % 1000 == 999">) OR id IN (</when>
                        <otherwise>,</otherwise>
                    </choose>
                </if>
                #{item}
            </foreach>
        </trim>
	</delete>
	
	
</mapper>