CompanyMapper.xml 3.8 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.CompanyMapper" >
  <resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.Company" >
    <id column="company_id" property="companyId" jdbcType="VARCHAR" />
    <result column="company_name" property="companyName" jdbcType="VARCHAR" />
    <result column="group_id" property="groupId" jdbcType="VARCHAR" />
    <result column="creat_time" property="creatTime" jdbcType="TIMESTAMP" />
    <result column="company_status" property="companyStatus" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    company_id, company_name, group_id, creat_time, company_status
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from company
    where company_id = #{companyId,jdbcType=VARCHAR}
  </select>

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

  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from company
    where company_id = #{companyId,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.tianbo.warehouse.model.Company" >
    insert into company (company_id, company_name, group_id, 
      creat_time, company_status)
    values (#{companyId,jdbcType=VARCHAR}, #{companyName,jdbcType=VARCHAR}, #{groupId,jdbcType=VARCHAR}, 
      #{creatTime,jdbcType=TIMESTAMP}, #{companyStatus,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.tianbo.warehouse.model.Company" >
    insert into company
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="companyId != null" >
        company_id,
      </if>
      <if test="companyName != null" >
        company_name,
      </if>
      <if test="groupId != null" >
        group_id,
      </if>
      <if test="creatTime != null" >
        creat_time,
      </if>
      <if test="companyStatus != null" >
        company_status,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="companyId != null" >
        #{companyId,jdbcType=VARCHAR},
      </if>
      <if test="companyName != null" >
        #{companyName,jdbcType=VARCHAR},
      </if>
      <if test="groupId != null" >
        #{groupId,jdbcType=VARCHAR},
      </if>
      <if test="creatTime != null" >
        #{creatTime,jdbcType=TIMESTAMP},
      </if>
      <if test="companyStatus != null" >
        #{companyStatus,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.Company" >
    update company
    <set >
      <if test="companyName != null" >
        company_name = #{companyName,jdbcType=VARCHAR},
      </if>
      <if test="groupId != null" >
        group_id = #{groupId,jdbcType=VARCHAR},
      </if>
      <if test="creatTime != null" >
        creat_time = #{creatTime,jdbcType=TIMESTAMP},
      </if>
      <if test="companyStatus != null" >
        company_status = #{companyStatus,jdbcType=VARCHAR},
      </if>
    </set>
    where company_id = #{companyId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.Company" >
    update company
    set company_name = #{companyName,jdbcType=VARCHAR},
      group_id = #{groupId,jdbcType=VARCHAR},
      creat_time = #{creatTime,jdbcType=TIMESTAMP},
      company_status = #{companyStatus,jdbcType=VARCHAR}
    where company_id = #{companyId,jdbcType=VARCHAR}
  </update>

</mapper>