Newer
Older
huludao / src / main / resources / mapper / Data_User_OrgDao.xml
<?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.newfiber.api.pc.dao.Data_User_OrgDao" >
  
  
	
  <select  id="getUserOrgu"
  resultType="com.newfiber.api.pc.model.entity.Data_User_Org" >

  select  sys_user_org.user_no  from  sys_user_org where  sys_user_org.org_no

 in
     <foreach collection="array" item="Org_Nos" index="index"  
            open="(" close=")" separator=",">  
            #{Org_Nos}  
        </foreach>
  </select>
  
  
  
  
 
  
  
  
  
  
  <sql id = "UserOrg_sql">
			FROM sys_user_info left join sys_user_org on sys_user_info.user_no=sys_user_org.user_no
			<where>
				<if test="fuzzyQuery!=null">
					(sys_user_info.user_no like '%${fuzzyQuery}%' OR sys_user_info.user_name like '%${fuzzyQuery}%')
				</if>
				<if test="orgNo!=null">
				    AND  sys_user_org.org_no like '%${orgNo}%'
				</if>
			
			</where>
		</sql>
   

   
    <select id="orgUserCount" parameterType="com.newfiber.api.pc.model.entity.Data_User_Info" resultType="int">
		SELECT COUNT(DISTINCT sys_user_info.user_no) total
		<include refid="UserOrg_sql"></include>
	</select>
	
	   	<sql id="op">
	
	<choose>
        <when test="sort!=null and sort != ''">
          
           ${sort}
        </when>
        <otherwise>
          create_time
        </otherwise>
    </choose>
	
	</sql>
	<sql id="oc">
	  <choose>
        <when test="order !=null and order  != ''">
           ${order}
        </when>
        <otherwise>
           DESC
        </otherwise>
    </choose>
	
	</sql>
	
	<select id="orgList" parameterType="com.newfiber.api.pc.model.entity.Data_User_Info" resultType="com.newfiber.api.pc.model.entity.Data_User_Info">
		
			select sys_user_org.org_no,
	   sys_user_info.user_no, sys_user_info.user_name, sys_user_info.create_time
	<include refid="UserOrg_sql"></include>
	   order by  
	    <include refid="op"></include> 
	    <include refid="oc"></include>  
	    limit
	    #{pageNo},
	    #{pageSize}
	</select>


 <sql id = "UserOrg_sqlOne">
			FROM sys_user_info
			<where>
				<if test="Org_No!=null">
				  sys_user_info.User_No not in (SELECT sys_user_org.User_NO from sys_user_org where sys_user_org.Org_No like '%${Org_No}%')
				</if>
			
			</where>
		</sql>
   
	 <select id="orgNotUserCount" parameterType="com.newfiber.api.pc.model.entity.Data_User_Info" resultType="int">
		SELECT COUNT(DISTINCT sys_user_info.User_No) total
		<include refid="UserOrg_sqlOne"></include>
	</select>
		<select id="orgNotUserList" parameterType="com.newfiber.api.pc.model.entity.Data_User_Info" resultType="com.newfiber.api.pc.model.entity.Data_User_Info">
		SELECT DISTINCT  sys_user_info.user_no,sys_user_info.user_name,
		sys_user_info.create_time
        FROM sys_user_info
		WHERE  NOT EXISTS (SELECT sys_user_org.user_no from sys_user_org where sys_user_org.user_no = sys_user_info.user_no)
		Order BY 
		<include refid="op"></include> 
	    <include refid="oc"></include>  
		 limit
	    #{pageNo},
	    #{pageSize}
	</select>

<delete id="deleteOrg" parameterType="list" >
    delete from sys_user_org
    where user_no in
          <foreach collection="list" item="item" open="(" separator="," close=")">
              #{item.userNo,jdbcType=VARCHAR}
          </foreach>
    and org_no in
        <foreach collection="list" item="item" open="(" separator="," close=")">
            #{item.orgNo,jdbcType=VARCHAR}
        </foreach>
  </delete>


    <select id="selectByUserNo" parameterType="string" resultType="com.newfiber.api.pc.model.entity.SysOrganization">
        SELECT s.org_no ,o.org_name ,o.org_type  FROM sys_user_org s INNER JOIN sys_organization o ON s.org_no = o.org_no
        WHERE s.user_no = #{userNo} limit 0,1
    </select>
    
    <resultMap id="orgMap" type="com.newfiber.api.pc.model.vo.OrgVo">
        <result property="orgNo" column="org_no"/>
        <result property="orgName" column="org_name"/>
        <result property="orgState" column="org_state"/>
        <result property="orgStateZn" column="org_state_zn"/>
        <result property="orgType" column="org_type"/>
        <result property="orgTypeZn" column="org_type_zn"/>
        <result property="address" column="address"/>
    </resultMap>


    <select id="selectOrgNoByUserNo" resultMap="orgMap" >
        select
           DISTINCT so.org_no org_no,so.org_name org_name,so.org_state org_state,so.org_state_zn org_state_zn,so.org_type org_type,so.org_type_zn org_type_zn,so.address address
        FROM
        sys_user_org suo
        left JOIN
        sys_organization so
        on suo.org_no = so.org_no
        where 1 = 1
        <if test="userNo != 'temp'">
            and suo.user_no = #{userNo}
        </if>

    </select>

  
</mapper>