Newer
Older
huludao / src / main / resources / mapper / RiverManage / OfficialClassificationDao.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.OfficialClassificationDao" >
  <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.River.OfficialClassification" >
    <id column="Serial" property="serial" jdbcType="BIGINT" />
    <result column="Official_Type" property="officialType" jdbcType="INTEGER" />
    <result column="Official_Type_Zn" property="officialTypeZn" jdbcType="NVARCHAR" />
    <result column="Create_User_No" property="createUserNo" jdbcType="VARCHAR" />
    <result column="Update_User_No" property="updateUserNo" jdbcType="VARCHAR" />
    <result column="Create_Time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="Update_Time" property="updateTime" jdbcType="TIMESTAMP" />
    <result column="Remark" property="remark" jdbcType="NVARCHAR" />
  </resultMap>

  <select id="selectOfficialClassificationList" resultType="com.newfiber.api.pc.model.River.OfficialClassification" parameterType="com.newfiber.api.pc.model.River.OfficialClassification" >
    select
      r.Serial serial,r.Official_Type officialType,r.Official_Type_Zn officialTypeZn,r.Create_User_No createUserNo,
      r.Update_User_No updateUserNo,
    DATE_FORMAT(r.Create_Time,'%Y-%m-%d %T') time,DATE_FORMAT(r.Update_Time,'%Y-%m-%d %T') updateDateTime,r.Remark remark,
    o.user_name 'createUserName',
    k.user_name 'updateUserName'
    from official_classification r
    inner join huludao_main.sys_user_info o
    on o.User_No = r.Create_User_No
    left join huludao_main.sys_user_info k
    on k.User_No = r.Update_User_No
    where 1=1
    <if test="officialTypeZn != null and officialTypeZn != ''">
      and r.Official_Type_Zn like '%${officialTypeZn}%'
    </if>
    <if test="pageNo != null" >
      order by r.Serial limit #{pageNo},#{pageSize}
    </if>
  </select>

  <select id="selectMaxOfficialType" parameterType="com.newfiber.api.pc.model.River.OfficialClassification" resultType="java.lang.Integer">
    select max(r.Official_Type)
      from official_classification r
  </select>

  <delete id="deleteOfficialClassification" parameterType="long" >
    delete from official_classification
    where Serial IN
    <foreach collection="serial" item="item" open="(" close=")" separator=",">
        #{item}
    </foreach>
  </delete>

  <insert id="addOfficialClassification" parameterType="com.newfiber.api.pc.model.River.OfficialClassification" >
    insert into official_classification
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="officialType != null" >
        Official_Type,
      </if>
      <if test="officialTypeZn != null" >
        Official_Type_Zn,
      </if>
      <if test="createUserNo != null" >
        Create_User_No,
      </if>
      <if test="remark != null" >
        Remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="officialType != null" >
        #{officialType,jdbcType=INTEGER},
      </if>
      <if test="officialTypeZn != null" >
        #{officialTypeZn,jdbcType=NVARCHAR},
      </if>
      <if test="createUserNo != null" >
        #{createUserNo,jdbcType=VARCHAR},
      </if>
      <if test="remark != null" >
        #{remark,jdbcType=NVARCHAR},
      </if>
    </trim>
  </insert>

  <select id="countOfficialClassification" parameterType="com.newfiber.api.pc.model.River.OfficialClassification" resultType="java.lang.Integer" >
    select count(DISTINCT r.Serial)
      from official_classification r
      where 1=1
      <if test="officialTypeZn != null and officialTypeZn != ''">
        and r.Official_Type_Zn like '%${officialTypeZn}%'
      </if>
  </select>

  <update id="updateOfficialClassification" parameterType="com.newfiber.api.pc.model.River.OfficialClassification" >
    update official_classification
    <set >
      <if test="officialTypeZn != null" >
        Official_Type_Zn = #{officialTypeZn,jdbcType=NVARCHAR},
      </if>
      <if test="updateUserNo != null" >
        Update_User_No = #{updateUserNo,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null" >
        Update_Time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null" >
        Remark = #{remark,jdbcType=NVARCHAR},
      </if>
    </set>
    where Serial = #{serial,jdbcType=INTEGER}
  </update>

  <select id="selectOfficialClassTotal" resultType="com.newfiber.api.pc.model.River.OfficialClassification" parameterType="com.newfiber.api.pc.model.River.OfficialClassification">
    select Official_Type officialType,Official_Type_Zn officialTypeZn
      from official_classification
  </select>

</mapper>