DepartmentMapper.xml 3.6 KB
<?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.tianbo.warehouse.dao.DepartmentMapper" >
  <resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.Department" >
    <id column="department_id" property="departmentId" jdbcType="VARCHAR" />
    <result column="department_name" property="departmentName" jdbcType="VARCHAR" />
    <result column="creat_time" property="creatTime" jdbcType="DATE" />
    <result column="company_id" property="companyId" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    department_id, department_name, creat_time, company_id
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from department
    where department_id = #{departmentId,jdbcType=VARCHAR}
  </select>

  <select id="findAll" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select
    <include refid="Base_Column_List" />
    from department
    <if test="departmentName != '' and departmentName != null" >
      where department_name = #{departmentName, jdbcType=VARCHAR}
    </if>
    ORDER BY department_id
  </select>

  <select id="count" parameterType="string" resultType="int">
    select count(*) from department where department_id = #{value}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from department
    where department_id = #{departmentId,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.tianbo.warehouse.model.Department" >
    insert into department (department_id, department_name, creat_time, 
      company_id)
    values (#{departmentId,jdbcType=VARCHAR}, #{departmentName,jdbcType=VARCHAR}, #{creatTime,jdbcType=DATE}, 
      #{companyId,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.tianbo.warehouse.model.Department" >
    insert into department
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="departmentId != null" >
        department_id,
      </if>
      <if test="departmentName != null" >
        department_name,
      </if>
      <if test="creatTime != null" >
        creat_time,
      </if>
      <if test="companyId != null" >
        company_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="departmentId != null" >
        #{departmentId,jdbcType=VARCHAR},
      </if>
      <if test="departmentName != null" >
        #{departmentName,jdbcType=VARCHAR},
      </if>
      <if test="creatTime != null" >
        #{creatTime,jdbcType=DATE},
      </if>
      <if test="companyId != null" >
        #{companyId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.Department" >
    update department
    <set >
      <if test="departmentName != null" >
        department_name = #{departmentName,jdbcType=VARCHAR},
      </if>
      <if test="creatTime != null" >
        creat_time = #{creatTime,jdbcType=DATE},
      </if>
      <if test="companyId != null" >
        company_id = #{companyId,jdbcType=VARCHAR},
      </if>
    </set>
    where department_id = #{departmentId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.Department" >
    update department
    set department_name = #{departmentName,jdbcType=VARCHAR},
      creat_time = #{creatTime,jdbcType=DATE},
      company_id = #{companyId,jdbcType=VARCHAR}
    where department_id = #{departmentId,jdbcType=VARCHAR}
  </update>
</mapper>