Newer
Older
huludao / src / main / resources / mapper / Data_User_InfoDao.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_InfoDao" >


  <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.entity.Data_User_Info">
    <result column="user_no" property="userNo"/>
    <result column="password" property="password"/>
      <result column="user_name" property="userName"/>
    <result column="highest_authority" property="highestAuthority"/>
  </resultMap>


    <select id="selectUserByOrg" parameterType="java.lang.String" resultType="com.newfiber.api.pc.model.entity.UserInfo">
      select user_no userNo,user_name userName,sex,phone_num phoneNum from sys_user_info
      where 1 = 1 and exists (select 1 from sys_user_org where sys_user_info.user_no = sys_user_org.user_no and sys_user_org.org_no = #{orgNo})
    </select>




    <select id="selectUserInfoList" parameterType="com.newfiber.api.pc.model.entity.UserInfo" resultType="com.newfiber.api.pc.model.entity.UserInfo">
        select DISTINCT s.user_no userNo,
        s.user_name,s.sex,s.phone_num
          from sys_user_info s  WHERE 1=1
          <if test="userName != null and userName != ''">
              and s.user_name like '%${userName}%' or s.user_no like '%${userName}%'
          </if>
          <if test="pageNo != null" >
            order by s.user_no limit #{pageNo},#{pageSize}
          </if>
    </select>
    
    <select id="gethighestAuthorityTotal" resultType="int">
        select count(1) from sys_user_info where highest_authority = 'yes'
    </select>


    <resultMap id="userVoMap" type="com.newfiber.api.pc.model.vo.UserVo">
        <id column="user_no" property="userNo"/>
        <result column="user_name" property="userName"/>
        <result column="password" property="passWord" />
        <result column="age" property="age" />
        <result column="sex" property="sex" />
        <result column="phone_num" property="phoneNum" />
        <result column="create_time" property="createTime" />
    </resultMap>


    <select id="selectNoProjectUser" resultMap="userVoMap">
        SELECT
        user_no,user_name,password,age,sex,phone_num,create_time
        from  sys_user_info
        where 1 = 1
        <if test="list != null and list.size > 0">
           AND user_no not in
            <foreach collection="list" index="index" item="item"
                                        open="("  separator="," close=")">
                          #{item}
            </foreach>
        </if>
        <if test="userNo != null and userNo != ''">
            and (user_no like '%#{userNo}%' or user_name like '%{userNo}%')
        </if>
        limit #{start},#{size}
    </select>

    <select id="selectNoProjectUserCount" resultType="long">
        SELECT
          COUNT(user_no)
        from  sys_user_info
        where 1 = 1
        <if test="list != null and list.size > 0">
            AND user_no not in
            <foreach collection="list" index="index" item="item"
                                        open="("  separator="," close=")">
                        #{item}
            </foreach>
        </if>
        <if test="userNo != null and userNo != ''">
            and (user_no like '%{userNo}%' or user_name like '%{userNo}%')
        </if>
    </select>

    <select id="selectProjectUser" resultMap="userVoMap">
        SELECT
        user_no,user_name,password,age,sex,phone_num,create_time
        from  sys_user_info
        where 1 = 1
        <if test="list != null and list.size > 0">
            AND user_no  in
            <foreach collection="list" index="index" item="item"
                     open="("  separator="," close=")">
                #{item}
            </foreach>
        </if>
        limit #{start},#{size}
    </select>

    <select id="selectProjectUserCount" resultType="long">
        SELECT
        COUNT(user_no)
        from  sys_user_info
        where 1 = 1
        <if test="list != null and list.size > 0">
            AND user_no  in
            <foreach collection="list" index="index" item="item"
                     open="("  separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>

    <select id="selectUserByUserNo" resultMap="userVoMap">
        select  user_no,user_name,password,age,sex,phone_num,create_time from sys_user_info where user_no = #{userNo}
    </select>






   <select id="GetUserList" resultType="com.newfiber.api.pc.model.entity.Data_User_Info">
   SELECT * FROM sys_user_info ;
   </select>

   
  <select id="selectUser" resultType="com.newfiber.api.pc.model.entity.Data_User_Info" parameterType="string" >
    select
        user_no,user_name,password,age,sex,phone_num,create_time,highest_authority
    from sys_user_info
    
    where user_no = #{userNo,jdbcType=VARCHAR}
      
    
  </select>
  
  <select id="GetLogin" resultMap="BaseResultMap" parameterType="string">
  select id,user_no,password, user_name,highest_authority from sys_user_info where user_no = #{userNo,jdbcType=VARCHAR}
  
  </select>
  
  <delete id="deleteUser" parameterType="list" >
    delete from sys_user_info
    where user_no in
    <foreach collection="list" item="item" separator="," open="(" close=")">
        #{item}
    </foreach>
  </delete>

    <select id="getUserInfo" resultType="com.newfiber.api.pc.model.entity.UserInfoVo">
        SELECT user_no as userNo,user_name as userName,phone_num as phoneNumber FROM sys_user_info where highest_authority is null
    </select>
  
  
  <insert id="addUser" parameterType="com.newfiber.api.pc.model.entity.Data_User_Info" >
    insert into sys_user_info
    <trim prefix="(" suffix=")" suffixOverrides="," >
     
      <if test="userNo != null" >
          user_no,
      </if>
      
      <if test="userName != null" >
          user_name,
      </if>
      <if test="password != null" >
          password,
      </if>
      <if test=" age != null" >
        age,
      </if>
      <if test="sex != null" >
        sex,
      </if>  
      <if test="phoneNum != null" >
          phone_num,
      </if>
      <if test="picPath != null">
          pic_path,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >

        <if test="userNo != null" >
            #{userNo},
        </if>

        <if test="userName != null" >
            #{userName},
        </if>
        <if test="password != null" >
            #{password},
        </if>
        <if test=" age != null" >
            #{age},
        </if>
        <if test="sex != null" >
            #{sex},
        </if>
        <if test="phoneNum != null" >
            #{phoneNum},
        </if>
        <if test="picPath != null">
            #{picPath},
        </if>
    </trim>
  </insert>
  
  
  
  
  
  <update id="updateUser" parameterType="com.newfiber.api.pc.model.entity.Data_User_Info" >
    update sys_user_info
    <set >
      <if test="userName != null" >
          user_name = #{userName,jdbcType=VARCHAR},
      </if>
      <if test="password != null" >
        password = #{password,jdbcType=VARCHAR},
      </if>
      <if test="age != null">
          age = #{age},
      </if>
      <if test="sex != null">
          sex = #{sex},
      </if>
      <if test="phoneNum != null">
          phone_num = #{phoneNum},
      </if>
      <if test="picPath != null">
          pic_path = #{picPath},
      </if>
    </set>
    where user_no = #{userNo,jdbcType=VARCHAR}
  </update>

  
</mapper>