<?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.gaowj.business.system.SystemBackDAO">

	<select id="getUserAllModule" parameterType="String" resultType="upperCaseKeyMap">
	 <![CDATA[
	    select m_id from c_t_sys_group_m where g_id in (select g_id from c_t_sys_group_u where u_id=#{uid}) 
	  ]]>
	</select>
	
	<select id="getTopMenu" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	select * from  c_t_sys_module_type where mt_id in(select distinct mt_id from c_t_sys_module where m_id in(${MIDS}) and m_state=0) order by mt_sort
     ]]>
	</select>
	
	<select id="getLeftMenu1" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	select distinct m_menu from c_t_sys_module where m_id in(${MIDS}) and mt_id=#{MTID} and m_state=0
     ]]>
	</select>
	
	<select id="getLeftMenu2" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select * from c_t_sys_module 
	   where 1=1 and m_state=0 
     ]]>
     <if test="MIDS != null and MIDS != ''">
      and m_id in (${MIDS})
     </if>
     <if test="MTID != null and MTID != ''">
      and mt_id = #{MTID}
     </if>
     <if test="MENU1 != null and MENU1 != ''">
      and m_menu = #{MENU1}
     </if>
     order by m_sort 
	</select>
	
	<insert id="insert_user" parameterType="map">
	      insert into c_t_sys_loginuser(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="CODE != null ">CODE, </if>
	         <if test="EMID != null ">EMID, </if>
             <if test="EMPASS != null ">EMPASS, </if>
             <if test="EMDEPART != null ">EMDEPART, </if>
             <if test="EMNAME != null ">EMNAME , </if>
             <if test="EMSEX != null ">EMSEX , </if>
             <if test="EMAIL != null ">EMAIL , </if>
             <if test="REGDATE != null ">REGDATE , </if>
             <if test="O_ENABLE != null ">O_ENABLE , </if>
             <if test="W_ENABLE != null ">W_ENABLE , </if>
             <if test="TYPE != null ">TYPE , </if>
             <if test="STATE != null ">STATE , </if>
             <if test="ID_CODE != null ">ID_CODE , </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="CODE != null ">#{CODE}, </if>
	         <if test="EMID != null ">#{EMID}, </if>
             <if test="EMPASS != null ">#{EMPASS}, </if>
             <if test="EMDEPART != null ">#{EMDEPART}, </if>
             <if test="EMNAME != null ">#{EMNAME} , </if>
             <if test="EMSEX != null ">#{EMSEX} , </if>
             <if test="EMAIL != null ">#{EMAIL} , </if>
             <if test="REGDATE != null ">#{REGDATE} , </if>
             <if test="O_ENABLE != null ">#{O_ENABLE} , </if>
             <if test="W_ENABLE != null ">#{W_ENABLE} , </if>
             <if test="TYPE != null ">#{TYPE} , </if>
             <if test="STATE != null ">#{STATE} , </if>
             <if test="ID_CODE != null ">#{ID_CODE} , </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 
 	<update id="update_user" parameterType="map">
	   update c_t_sys_loginuser  
	    <set> 
	         <if test="EMID != null ">EMID = #{EMID}, </if>
             <if test="EMPASS != null ">EMPASS = #{EMPASS}, </if>
             <if test="EMDEPART != null ">EMDEPART = #{EMDEPART}, </if>
             <if test="EMNAME != null ">EMNAME = #{EMNAME} , </if>
             <if test="EMSEX != null ">EMSEX = #{EMSEX} , </if>
             <if test="EMAIL != null ">EMAIL = #{EMAIL} , </if>
             <if test="REGDATE != null ">REGDATE = #{REGDATE} , </if>
             <if test="O_ENABLE != null ">O_ENABLE = #{O_ENABLE} , </if>
             <if test="W_ENABLE != null ">W_ENABLE = #{W_ENABLE} , </if>
             <if test="TYPE != null ">TYPE = #{TYPE} , </if>
             <if test="STATE != null ">STATE = #{STATE} , </if>
             <if test="ID_CODE != null ">ID_CODE = #{ID_CODE} , </if>
	    </set>
         where CODE = #{CODE} 
 	</update>
 	
 	<update id="delete_user" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_loginuser 
	  ]]>
	  <where>
	    <if test="CODE != null and CODE != ''">
	      and code = #{CODE} 
	    </if>
	    <if test="EMID != null and EMID != ''">
	      and emid = #{EMID}
	    </if>
	  </where> 
 	</update>
	
	<select id="listLoginUserInfo" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select u.*,d.dpt_name emdepartname,(select max(opetime) from c_t_sys_loginlog where code=u.code) beforetime,
	   (select count(1) from c_t_sys_group_u gu where gu.u_id=u.emid) ysy 
	   from c_t_sys_loginuser u left 
	   join c_t_sys_department d on d.dpt_no = u.emdepart 
	   where 1=1  
     ]]>
     <if test="EMID != null and EMID != ''">
      and u.emid = #{EMID}
     </if>
     <if test="EMPASS != null and EMPASS != ''">
      and u.empass = #{EMPASS}
     </if>
     <if test="CODE != null and CODE != ''">
      and u.code = #{CODE}
     </if>
	</select>
	
	<select id="listLoginUserInfoCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(*) c 
	   from c_t_sys_loginuser u left 
	   join c_t_sys_department d on d.dpt_no = u.emdepart 
	   where 1=1  
     ]]>
     <if test="EMID != null and EMID != ''">
      and u.emid = #{EMID}
     </if>
     <if test="EMPASS != null and EMPASS != ''">
      and u.empass = #{EMPASS}
     </if>
     <if test="CODE != null and CODE != ''">
      and u.code = #{CODE}
     </if>
	</select>
	
	<select id="getMaxLoginUserCode" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select max(code) maxcode from c_t_sys_loginuser where 1=1 and code like '${EMDEPART}%'
	  ]]>
	</select>
	
	<select id="getMaxLoginUserEmid" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select max(emid) maxemid from c_t_sys_loginuser where 1=1 and emid like '${EMDEPART}%'
	  ]]>
	</select>
	
	<select id="listDepartmentInfo" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select d.*,(select emname from c_t_sys_loginuser u where u.code = d.manager) managername,(select count(*) from c_t_sys_loginuser u where u.emdepart = d.dpt_no) ysy  
	   from c_t_sys_department d 
	   where 1=1 
     ]]>
     <if test="DPT_NO != null and DPT_NO != ''">
      and d.dpt_no = #{DPT_NO}
     </if>
      order by d.sort 
	</select>
	
	<select id="listDepartmentInfoCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(*) c 
	   from c_t_sys_department d 
	   where 1=1 
     ]]>
     <if test="DPT_NO != null and DPT_NO != ''">
      and d.dpt_no = #{DPT_NO}
     </if>
	</select>
	
	<insert id="insert_depart" parameterType="map">
	      insert into c_t_sys_department(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="DPT_NO != null ">DPT_NO, </if>
	         <if test="DPT_NAME != null ">DPT_NAME, </if>
             <if test="MANAGER != null ">MANAGER, </if>
             <if test="SORT != null ">SORT, </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="DPT_NO != null ">#{DPT_NO}, </if>
	         <if test="DPT_NAME != null ">#{DPT_NAME}, </if>
             <if test="MANAGER != null ">#{MANAGER}, </if>
             <if test="SORT != null ">#{SORT}, </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 
 	<update id="update_depart" parameterType="map">
	   update c_t_sys_department  
	    <set> 
	         <if test="DPT_NAME != null ">DPT_NAME = #{DPT_NAME}, </if>
             <if test="MANAGER != null ">MANAGER = #{MANAGER}, </if>
             <if test="SORT != null ">SORT = #{SORT}, </if>
	    </set>
         where DPT_NO = #{DPT_NO} 
 	</update>
 	
 	<update id="delete_depart" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_department 
	  ]]>
	  <where>
	    <if test="DPT_NO != null and DPT_NO != ''">
	      and dpt_no = #{DPT_NO} 
	    </if>
	  </where> 
 	</update>
	
	<update id="modifyPass" parameterType="map">
	 <![CDATA[
	     update c_t_sys_loginuser set empass=#{EMPASS} where code=#{CODE}
	  ]]> 
 	</update>
	
	
	
	<select id="listGroupAll" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	    select t.*,(select count(*) from c_t_sys_group_m t1 where t1.g_id=t.g_id) msy,
	    (select count(*) from c_t_sys_group_u t2 where t2.g_id=t.g_id) usy  from c_t_sys_group t  
		where 1=1
	  ]]> 
		<if test="G_ID != null and G_ID != ''">
	    and  t.g_id = #{G_ID}
		</if>
		<if test="G_STATE != null and G_STATE != ''">
	    and  t.g_state = #{G_STATE}
		</if>
		order by t.g_sort
	</select>
 
	<select id="listGroupAllCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(1) c from c_t_sys_group t 
		where 1=1
	  ]]> 
		<if test="G_ID != null and G_ID != ''">
	    and  t.g_id = #{G_ID}
		</if>
		<if test="G_STATE != null and G_STATE != ''">
	    and  t.g_state = #{G_STATE}
		</if>
	</select>
	
	<insert id="insert_group" parameterType="map">
	      insert into c_t_sys_group(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="G_ID != null ">G_ID, </if>
	         <if test="G_NAME != null ">G_NAME, </if>
             <if test="G_TITLE != null ">G_TITLE, </if>
             <if test="G_SORT != null ">G_SORT, </if>
             <if test="G_STATE != null ">G_STATE , </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="G_ID != null ">#{G_ID}, </if>
	         <if test="G_NAME != null ">#{G_NAME}, </if>
             <if test="G_TITLE != null ">#{G_TITLE}, </if>
             <if test="G_SORT != null ">#{G_SORT}, </if>
             <if test="G_STATE != null ">#{G_STATE}, </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 
 	<update id="update_group" parameterType="map">
	   update c_t_sys_group  
	    <set> 
	         <if test="G_NAME != null ">G_NAME = #{G_NAME}, </if>
             <if test="G_TITLE != null ">G_TITLE = #{G_TITLE}, </if>
             <if test="G_SORT != null ">G_SORT = #{G_SORT}, </if>
             <if test="G_STATE != null ">G_STATE = #{G_STATE}, </if>
	    </set>
         where G_ID = #{G_ID} 
 	</update>
 	
 	<update id="delete_group" parameterType="String">
	 <![CDATA[
	delete from c_t_sys_group 
		where G_ID = #{G_ID} 
	  ]]> 
 	</update>
 	
 	<select id="listGroupM_from_G" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
 	     select m.m_id,m.m_name from c_t_sys_group_m gm,c_t_sys_module m 
 	     where 1=1 and gm.m_id=m.m_id
	  ]]>
	  <if test="G_ID != null and G_ID != ''">
	    and  gm.g_id = #{G_ID}
	  </if>
	  <if test="M_ID != null and M_ID != ''">
	    and  gm.m_id = #{M_ID}
	  </if>
	</select>
	
	<select id="listModuleType" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	  select mt.*,(select count(1) c from c_t_sys_module m  where m.mt_id=mt.mt_id) ysy from  c_t_sys_module_type mt where 1=1 
     ]]>
	    <if test="MT_ID != null and MT_ID != ''">
	      and mt.mt_id = #{MT_ID} 
	    </if>
	  order by mt.mt_sort
	</select>
	<select id="listModuleTypeCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(1) c from c_t_sys_module_type where 1=1 
	  ]]>
	    <if test="MT_ID != null and MT_ID != ''">
	      and mt_id = #{MT_ID} 
	    </if> 
	</select>
	<insert id="insert_moduleType" parameterType="map">
	      insert into c_t_sys_module_type(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="MT_ID != null ">MT_ID, </if>
	         <if test="MT_NAME != null ">MT_NAME, </if>
             <if test="MT_TITLE != null ">MT_TITLE, </if>
             <if test="MT_SORT != null ">MT_SORT, </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="MT_ID != null ">#{MT_ID}, </if>
	         <if test="MT_NAME != null ">#{MT_NAME}, </if>
             <if test="MT_TITLE != null ">#{MT_TITLE}, </if>
             <if test="MT_SORT != null ">#{MT_SORT}, </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 
 	<update id="update_moduleType" parameterType="map">
	   update c_t_sys_module_type  
	    <set> 
	         <if test="MT_ID != null ">MT_ID = #{MT_ID}, </if>
             <if test="MT_NAME != null ">MT_NAME = #{MT_NAME}, </if>
             <if test="MT_TITLE != null ">MT_TITLE = #{MT_TITLE}, </if>
             <if test="MT_SORT != null ">MT_SORT = #{MT_SORT} , </if>
	    </set>
         where MT_ID = #{MT_ID}
 	</update>
 	
 	<update id="delete_moduleType" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_module_type 
	  ]]>
	  <where>
	    <if test="MT_ID != null and MT_ID != ''">
	      and mt_id = #{MT_ID} 
	    </if>
	  </where> 
 	</update>
	
	<select id="listModule" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select m.*,(select mt.mt_name from c_t_sys_module_type mt where mt.mt_id=m.mt_id) mt_name,(select count(1) c from c_t_sys_group_m gm  where m.m_id=gm.m_id) ysy from c_t_sys_module m where 1=1  
     ]]>
      <if test="MT_ID != null and MT_ID != ''">
	    and  m.mt_id = #{MT_ID}
	  </if>
	  <if test="M_ID != null and M_ID != ''">
	      and m.m_id = #{M_ID} 
	  </if>
	  <if test="M_STATE != null and M_STATE != ''">
	      and m.m_state = #{M_STATE} 
	  </if>
     order by m.mt_id,m.m_menu,m.m_sort 
	</select>
	<select id="listModuleCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(1) c from c_t_sys_module where 1=1 and m_state=0
	  ]]>
	  <if test="MT_ID != null and MT_ID != ''">
	    and  mt_id = #{MT_ID}
	  </if> 
	  <if test="M_ID != null and M_ID != ''">
	      and m_id = #{M_ID} 
	  </if>
	  <if test="M_STATE != null and M_STATE != ''">
	      and m.m_state = #{M_STATE} 
	  </if>
	</select>
	
	<insert id="insert_module" parameterType="map">
	      insert into c_t_sys_module(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="M_ID != null ">M_ID, </if>
             <if test="M_NAME != null ">M_NAME, </if>
             <if test="M_TITLE != null ">M_TITLE, </if>
             <if test="M_SORT != null ">M_SORT , </if>
             <if test="MT_ID != null ">MT_ID , </if>
             <if test="M_MENU != null ">M_MENU , </if>
             <if test="M_STATE != null ">M_STATE , </if>
             <if test="WINDOWNAME_WEB != null ">WINDOWNAME_WEB , </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="M_ID != null ">#{M_ID}, </if>
             <if test="M_NAME != null ">#{M_NAME}, </if>
             <if test="M_TITLE != null ">#{M_TITLE}, </if>
             <if test="M_SORT != null ">#{M_SORT} , </if>
             <if test="MT_ID != null ">#{MT_ID} , </if>
             <if test="M_MENU != null ">#{M_MENU} , </if>
             <if test="M_STATE != null ">#{M_STATE} , </if>
             <if test="WINDOWNAME_WEB != null ">#{WINDOWNAME_WEB} , </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 
 	<update id="update_module" parameterType="map">
	   update c_t_sys_module  
	    <set> 
             <if test="M_NAME != null ">M_NAME = #{M_NAME}, </if>
             <if test="M_TITLE != null ">M_TITLE = #{M_TITLE}, </if>
             <if test="M_SORT != null ">M_SORT = #{M_SORT} , </if>
             <if test="MT_ID != null ">MT_ID = #{MT_ID} , </if>
             <if test="M_MENU != null ">M_MENU = #{M_MENU} , </if>
             <if test="M_STATE != null ">M_STATE = #{M_STATE} , </if>
             <if test="WINDOWNAME_WEB != null ">WINDOWNAME_WEB = #{WINDOWNAME_WEB} , </if>
	    </set>
         where M_ID = #{M_ID}
 	</update>
 	
 	<update id="delete_module" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_module 
	  ]]>
	  <where>
	    <if test="MT_ID != null and MT_ID != ''">
	      and mt_id = #{MT_ID} 
	    </if>
	    <if test="M_ID != null and M_ID != ''">
	      and m_id = #{M_ID} 
	    </if>
	  </where> 
 	</update>
	
	<insert id="insert_group_c_m" parameterType="map">
	      insert into c_t_sys_group_m(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="GM != null ">GM, </if>
	         <if test="G_ID != null ">G_ID, </if>
             <if test="M_ID != null ">M_ID, </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="GM != null ">#{GM}, </if>
	         <if test="G_ID != null ">#{G_ID}, </if>
             <if test="M_ID != null ">#{M_ID}, </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 	
 	<update id="delete_group_c_m" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_group_m  
	  ]]> 
	  <where>
	    <if test="GM != null and GM != ''">
	    and  gm = #{GM}
	    </if>
	    <if test="G_ID != null and G_ID != ''">
	    and  g_id = #{G_ID}
	  </if>
	  </where>
 	</update>
 	
 	<select id="getMaxGm" parameterType="map" resultType="int">
	 <![CDATA[
	   select max(gm) maxgm from c_t_sys_group_m where 1=1 
	  ]]>
	</select>
	
	
	<!-- 角色组/功能组选人 -->
	<select id="listGroupU_from_G" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
 	     select e.code,e.emname,e.emdepart,e.emid from c_t_sys_group_u gu,c_t_sys_loginuser e 
 	     where 1=1 and gu.u_id=e.emid
	  ]]>
	  <if test="G_ID != null and G_ID != ''">
	    and  gu.g_id = #{G_ID}
	  </if>
	  <if test="U_ID != null and U_ID != ''">
	    and  gu.u_id = #{U_ID}
	  </if>
	</select>

	<insert id="insert_group_c_u" parameterType="map">
	      insert into c_t_sys_group_u(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="GU != null ">GU, </if>
	         <if test="G_ID != null ">G_ID, </if>
             <if test="U_ID != null ">U_ID, </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="GU != null ">#{GU}, </if>
	         <if test="G_ID != null ">#{G_ID}, </if>
             <if test="U_ID != null ">#{U_ID}, </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 	
 	<update id="delete_group_c_u" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_group_u  
	  ]]> 
	  <where>
	    <if test="GM != null and GM != ''">
	    and  gu = #{GU}
	    </if>
	    <if test="G_ID != null and G_ID != ''">
	    and  g_id = #{G_ID}
	  </if>
	  </where>
 	</update>
 	
 	<select id="getMaxGu" parameterType="map" resultType="int">
	 <![CDATA[
	   select max(gu) maxgu from c_t_sys_group_u where 1=1 
	  ]]>
	</select>
	
	<!-- 人管人查询 -->
	<select id="listPerson_from_P" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
 	     select * from c_t_sys_person 
 	     where 1=1 
	  ]]>
	  <if test="QXLX != null and QXLX != ''">
	    and  qxlx = #{QXLX}
	  </if>
	  <if test="GUANLI != null and GUANLI != ''">
	    and  guanli = #{GUANLI}
	  </if>
	  <if test="BEIGUANLI != null and BEIGUANLI != ''">
	    and  beiguanli = #{BEIGUANLI}
	  </if>
	  <if test="SETTING != null and SETTING != ''">
	    and  setting = #{SETTING}
	  </if>
	</select>
	
	<insert id="insert_person_p" parameterType="map">
	      insert into c_t_sys_person(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="QXLX != null ">QXLX, </if>
	         <if test="GUANLI != null ">GUANLI, </if>
             <if test="BEIGUANLI != null ">BEIGUANLI, </if>
             <if test="SETTING != null ">SETTING, </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="QXLX != null ">#{QXLX}, </if>
	         <if test="GUANLI != null ">#{GUANLI}, </if>
             <if test="BEIGUANLI != null ">#{BEIGUANLI}, </if>
             <if test="SETTING != null ">#{SETTING}, </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 	
 	<update id="delete_person_p" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_person  
	  ]]> 
	  <where>
	    <if test="QXLX != null and QXLX != ''">
	      and  qxlx = #{QXLX}
	    </if>
	    <if test="GUANLI != null and GUANLI != ''">
	      and  guanli = #{GUANLI}
	    </if>
	    <if test="BEIGUANLI != null and BEIGUANLI != ''">
	      and  beiguanli = #{BEIGUANLI}
	    </if>
	    <if test="SETTING != null and SETTING != ''">
	      and  setting = #{SETTING}
	    </if>
	  </where>
 	</update>
 	<!-- 日志信息 -->
 	<select id="listLogInfo" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select * 
	   from c_t_sys_loginlog log 
	   where 1=1 
     ]]>
     <if test="BEGIN_DATE != null and BEGIN_DATE != ''">
	    and  log.opetime &gt;= #{BEGIN_DATE} 
	 </if>
	 <if test="END_DATE != null and END_DATE != ''">
	    and  log.opetime &lt;= #{END_DATE} 
	 </if>
	 <if test="NAME != null and NAME != ''">
	    and log.code in (select l.code from c_t_sys_loginuser l where l.code like '${NAME}%' or l.emname like '${NAME}%')
	 </if>
	 <if test="EMIP != null and EMIP != ''">
	    and log.emIP like '${EMIP}%'
	 </if>
      order by log.opetime desc 
	</select>
	
	<select id="listLogInfoCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(*) c 
	   from c_t_sys_loginlog log 
	   where 1=1 
     ]]>
     <if test="BEGIN_DATE != null and BEGIN_DATE != ''">
	    and  log.opetime &gt;= #{BEGIN_DATE} 
	 </if>
	 <if test="END_DATE != null and END_DATE != ''">
	    and  log.opetime &lt;= #{END_DATE} 
	 </if>
	 <if test="NAME != null and NAME != ''">
	    and log.code in (select l.code from c_t_sys_loginuser l where l.code like '${NAME}%' or l.emname like '${NAME}%')
	 </if>
	 <if test="EMIP != null and EMIP != ''">
	    and log.emIP like '${EMIP}%'
	 </if>
	</select>
	
	<insert id="insert_log" parameterType="map">
	      insert into c_t_sys_loginlog(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="ID != null ">ID, </if>
	         <if test="CODE != null ">CODE, </if>
             <if test="EMNAME != null ">EMNAME, </if>
             <if test="EMIP != null ">EMIP, </if>
             <if test="OPENAME != null ">OPENAME , </if>
             <if test="OPETIME != null ">OPETIME , </if>
             <if test="TYPE != null ">TYPE , </if>
             <if test="OPETYPE != null ">OPETYPE , </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="ID != null ">#{ID}, </if>
	         <if test="CODE != null ">#{CODE}, </if>
             <if test="EMNAME != null ">#{EMNAME}, </if>
             <if test="EMIP != null ">#{EMIP}, </if>
             <if test="OPENAME != null ">#{OPENAME} , </if>
             <if test="OPETIME != null ">#{OPETIME} , </if>
             <if test="TYPE != null ">#{TYPE} , </if>
             <if test="OPETYPE != null ">#{OPETYPE} , </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
	<select id="getMaxLog" parameterType="map" resultType="int">
	 <![CDATA[
	   select max(id) maxid from c_t_sys_loginlog where 1=1 
	  ]]>
	</select>
	<!--log4j 日志信息 -->
	<select id="listLog4jInfo" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select * 
	   from c_t_sys_log4jinfo log4j 
	   where 1=1 
     ]]>
     <if test="BEGIN_DATE != null and BEGIN_DATE != ''">
	    and  log4j.logdate &gt;= #{BEGIN_DATE} 
	 </if>
	 <if test="END_DATE != null and END_DATE != ''">
	    and  log4j.logdate &lt;= #{END_DATE} 
	 </if>
	 <if test="USERINFO != null and USERINFO != ''">
	    and log4j.userinfo in like '${USERINFO}' 
	 </if>
	 <if test="LOGLEVEL != null and LOGLEVEL != ''">
	    and log4j.loglevel = #{LOGLEVEL} 
	 </if>
      order by log4j.logdate desc 
	</select>
	
	<select id="listLog4jInfoCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(*) c 
	   from c_t_sys_log4jinfo log4j 
	   where 1=1 
     ]]>
     <if test="BEGIN_DATE != null and BEGIN_DATE != ''">
	    and  log4j.logdate &gt;= #{BEGIN_DATE} 
	 </if>
	 <if test="END_DATE != null and END_DATE != ''">
	    and  log4j.logdate &lt;= #{END_DATE} 
	 </if>
	 <if test="USERINFO != null and USERINFO != ''">
	    and log4j.userinfo in like '${USERINFO}' 
	 </if>
	 <if test="LOGLEVEL != null and LOGLEVEL != ''">
	    and log4j.loglevel = #{LOGLEVEL} 
	 </if>
	</select>
	
	<insert id="insert_log4j" parameterType="map">
	      insert into c_t_sys_log4jinfo(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="ID != null ">ID, </if>
	         <if test="LOGDATE != null ">LOGDATE, </if>
             <if test="LOGTHREAD != null ">LOGTHREAD, </if>
             <if test="LOGLEVEL != null ">LOGLEVEL, </if>
             <if test="LOGCATEGORY != null ">LOGCATEGORY , </if>
             <if test="LOGLOCATION != null ">LOGLOCATION , </if>
             <if test="LOGMESSAGE != null ">LOGMESSAGE , </if>
             <if test="USERINFO != null ">USERINFO , </if>
             <if test="CLIENTINFO != null ">CLIENTINFO , </if>
             <if test="SERVERINFO != null ">SERVERINFO , </if>
             <if test="LOGTHROWABLE != null ">LOGTHROWABLE , </if>
             <if test="LOGNDC != null ">LOGNDC , </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="ID != null ">#{ID}, </if>
	         <if test="LOGDATE != null ">#{LOGDATE}, </if>
             <if test="LOGTHREAD != null ">#{LOGTHREAD}, </if>
             <if test="LOGLEVEL != null ">#{LOGLEVEL}, </if>
             <if test="LOGCATEGORY != null ">#{LOGCATEGORY} , </if>
             <if test="LOGLOCATION != null ">#{LOGLOCATION} , </if>
             <if test="LOGMESSAGE != null ">#{LOGMESSAGE} , </if>
             <if test="USERINFO != null ">#{USERINFO} , </if>
             <if test="CLIENTINFO != null ">#{CLIENTINFO} , </if>
             <if test="SERVERINFO != null ">#{SERVERINFO} , </if>
             <if test="LOGTHROWABLE != null ">#{LOGTHROWABLE} , </if>
             <if test="LOGNDC != null ">#{LOGNDC} , </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 	
 	<update id="update_log4j" parameterType="map">
	   update c_t_sys_log4jinfo  
	    <set> 
             <if test="LOGTHROWABLE != null ">LOGTHROWABLE = #{LOGTHROWABLE}, </if>
             <if test="LOGNDC != null ">LOGNDC = #{LOGNDC}, </if>
	    </set>
         where ID = #{ID}
 	</update>
 	
	<select id="getMaxLog4j" parameterType="map" resultType="int">
	 <![CDATA[
	   select max(id) maxid from c_t_sys_log4jinfo where 1=1 
	  ]]>
	</select>
</mapper>