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

    <!-- 通用映射列 -->
    <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.River.PatrolManageUserRelation">
        <result column="id" property="id"/>
        <result column="patrol_type" property="patrolType"/>
        <result column="bind_no" property="bindNo"/>
        <result column="handler_no" property="handlerNo"/>
        <result column="handler_name" property="handlerName"/>
        <result column="update_user_no" property="updateUserNo"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <!-- 通用数据库列 -->
    <sql id="Base_Column_List">
              id,
              patrol_type,
              bind_no,
              handler_no,
              handler_name,
              update_user_no,
              create_time,
              update_time
          </sql>

    <select id="selectByBindNo" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM `patrol_manage_user_relation`
        where bind_no = #{bindNo} and patrol_type = #{patrolType}
        limit 1
    </select>

    <select id="selectByUsername" resultMap="BaseResultMap">
        SELECT
       pmur.id,
       pmur.patrol_type,
       pmur.bind_no,
       pmur.handler_no,
       pmur.handler_name,
       pmur.update_user_no,
       pmur.create_time,
       pmur.update_time,
       pmb.project_name FROM `patrol_manage_user_relation` pmur
        left join patrol_manage_base pmb on pmur.bind_no = pmb.id
        where 1=1
        <if test='userName !="" and userName != null '>
            and pmur.handler_name like concat('%',#{userName},'%')
        </if>
        <if test='patrolType !="" and patrolType != null '>
            and pmur.patrol_type = #{patrolType}
        </if>
        GROUP BY handler_no,bind_no
    </select>

    <delete id="deleteByData">
        delete
        FROM `patrol_manage_user_relation`
        where bind_no = #{id} and patrol_type = #{patrolType}
        and handler_no = #{oldUserNo}
    </delete>

    <update id="updatebatchName" parameterType="string" >
        update patrol_manage_user_relation
        set handler_name = #{name}
        where handler_no = #{userNo}
    </update>
</mapper>