Newer
Older
huludao / src / main / resources / mapper / RiverManage / RiverPicsDao.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.RiverPicsDao" >
  <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.River.RiverPics" >
    <id column="Serial" property="serial" jdbcType="BIGINT" />
    <result column="River_Pics_No" property="riverPicsNo" jdbcType="VARCHAR" />
    <result column="River_Pics_Name" property="riverPicsName" jdbcType="NVARCHAR" />
    <result column="River_Pics_Address" property="riverPicsAddress" jdbcType="NVARCHAR" />
    <result column="Create_User_No" property="createUserNo" jdbcType="VARCHAR" />
    <result column="Create_Time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>

  <select id="selectRiverPicsList" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverPics" >
    select
      r.Serial serial,r.River_Pics_No riverPicsNo,r.River_Pics_Name riverPicsName,r.River_Pics_Address ,
      r.Create_User_No createUserNo,
    DATE_FORMAT(r.Create_Time,'%Y-%m-%d %T') time
    from river_pics r
    where 1=1
    <if test="riverPicsNo != null and riverPicsNo != ''">
      and r.River_Pics_No = #{riverPicsNo,jdbcType=VARCHAR}
    </if>
  </select>

  <delete id="deleteRiverPics" parameterType="java.util.List" >
    delete from river_pics
    where River_Pics_No in
    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
      #{item}
    </foreach>
  </delete>

  <insert id="addRiverPics" parameterType="com.newfiber.api.pc.model.River.RiverPics" >
    insert into river_pics
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="riverPicsNo != null" >
        River_Pics_No,
      </if>
      <if test="riverPicsName != null" >
        River_Pics_Name,
      </if>
      <if test="riverPicsAddress != null" >
        River_Pics_Address,
      </if>
      <if test="createUserNo != null" >
        Create_User_No,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="riverPicsNo != null" >
        #{riverPicsNo,jdbcType=VARCHAR},
      </if>
      <if test="riverPicsName != null" >
        #{riverPicsName,jdbcType=NVARCHAR},
      </if>
      <if test="riverPicsAddress != null" >
        #{riverPicsAddress,jdbcType=NVARCHAR},
      </if>
      <if test="createUserNo != null" >
        #{createUserNo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <select id="countRiverPics" parameterType="com.newfiber.api.pc.model.River.RiverPics" resultType="java.lang.Integer" >
    select count(DISTINCT r.Serial)
      from river_pics r
      where 1=1
      <if test="riverPicsNo != null" >
        and r.River_Pics_No = #{riverPicsNo,jdbcType=VARCHAR}
      </if>
  </select>

  <update id="updateRiverPics" parameterType="com.newfiber.api.pc.model.River.RiverPics" >
    update river_pics
    <set >
      <if test="riverPicsName != null" >
        River_Pics_Name = #{riverPicsName,jdbcType=NVARCHAR},
      </if>
      <if test="riverPicsAddress != null" >
        River_Pics_Address = #{riverPicsAddress,jdbcType=NVARCHAR},
      </if>
      <if test="createUserNo != null" >
        Create_User_No = #{createUserNo,jdbcType=VARCHAR},
      </if>
    </set>
    where River_Pics_No = #{riverPicsNo,jdbcType=VARCHAR}
  </update>

  <insert id="batchInsert">
    insert into river_pics(River_Pics_No,River_Pics_Name,River_Pics_Address,Create_User_No)
    values
    <foreach collection="riverPics" item="item" index="index" separator=",">
      (#{item.riverPicsNo},#{item.riverPicsName},#{item.riverPicsAddress},#{item.createUserNo})
    </foreach>
  </insert>

  <insert id="insert"  useGeneratedKeys="true" keyProperty="serial" parameterType="com.newfiber.api.pc.model.River.RiverPics" >
    insert into river_pics
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="riverPicsNo != null" >
        River_Pics_No,
      </if>
      <if test="riverPicsName != null" >
        River_Pics_Name,
      </if>
      <if test="riverPicsAddress != null" >
        River_Pics_Address,
      </if>
      <if test="createUserNo != null" >
        Create_User_No,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="riverPicsNo != null" >
        #{riverPicsNo,jdbcType=VARCHAR},
      </if>
      <if test="riverPicsName != null" >
        #{riverPicsName,jdbcType=NVARCHAR},
      </if>
      <if test="riverPicsAddress != null" >
        #{riverPicsAddress,jdbcType=NVARCHAR},
      </if>
      <if test="createUserNo != null" >
        #{createUserNo,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <insert id="batchUpdate">
    update river_pics
    set River_Pics_No = #{riverPicsNo}
    where Serial in
    <foreach collection="serial" item="item" index="index" separator="," open="(" close=")">
      (#{item})
    </foreach>
  </insert>

  <select id="batchSelect" resultMap="BaseResultMap" parameterType="com.newfiber.api.pc.model.River.RiverPics" >
    select
    Serial, River_Pics_No, River_Pics_Name, River_Pics_Address, Create_User_No, Create_Time
    from river_pics
    where River_Pics_No in
    <foreach collection="riverPics" item="item" index="index" separator="," open="(" close=")">
      (#{item})
    </foreach>
  </select>
</mapper>