<?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.jsh.erp.datasource.mappers.MaterialMapper">
  <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.Material">
    <id column="Id" jdbcType="BIGINT" property="id" />
    <result column="CategoryId" jdbcType="BIGINT" property="categoryid" />
    <result column="Name" jdbcType="VARCHAR" property="name" />
    <result column="Mfrs" jdbcType="VARCHAR" property="mfrs" />
    <result column="SafetyStock" jdbcType="DECIMAL" property="safetystock" />
    <result column="Model" jdbcType="VARCHAR" property="model" />
    <result column="Standard" jdbcType="VARCHAR" property="standard" />
    <result column="Color" jdbcType="VARCHAR" property="color" />
    <result column="Unit" jdbcType="VARCHAR" property="unit" />
    <result column="Remark" jdbcType="VARCHAR" property="remark" />
    <result column="UnitId" jdbcType="BIGINT" property="unitid" />
    <result column="Enabled" jdbcType="BIT" property="enabled" />
    <result column="OtherField1" jdbcType="VARCHAR" property="otherfield1" />
    <result column="OtherField2" jdbcType="VARCHAR" property="otherfield2" />
    <result column="OtherField3" jdbcType="VARCHAR" property="otherfield3" />
    <result column="enableSerialNumber" jdbcType="VARCHAR" property="enableserialnumber" />
    <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
    <result column="delete_Flag" jdbcType="VARCHAR" property="deleteFlag" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    Id, CategoryId, Name, Mfrs, SafetyStock, Model, Standard, Color, Unit, Remark, UnitId, 
    Enabled, OtherField1, OtherField2, OtherField3, enableSerialNumber, tenant_id, delete_Flag
  </sql>
  <select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from jsh_material
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from jsh_material
    where Id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from jsh_material
    where Id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample">
    delete from jsh_material
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.jsh.erp.datasource.entities.Material">
    insert into jsh_material (Id, CategoryId, Name, 
      Mfrs, SafetyStock, Model, 
      Standard, Color, Unit, 
      Remark, UnitId, Enabled, 
      OtherField1, OtherField2, OtherField3, 
      enableSerialNumber, tenant_id, delete_Flag
      )
    values (#{id,jdbcType=BIGINT}, #{categoryid,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, 
      #{mfrs,jdbcType=VARCHAR}, #{safetystock,jdbcType=DECIMAL}, #{model,jdbcType=VARCHAR}, 
      #{standard,jdbcType=VARCHAR}, #{color,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR}, 
      #{remark,jdbcType=VARCHAR}, #{unitid,jdbcType=BIGINT}, #{enabled,jdbcType=BIT}, 
      #{otherfield1,jdbcType=VARCHAR}, #{otherfield2,jdbcType=VARCHAR}, #{otherfield3,jdbcType=VARCHAR}, 
      #{enableserialnumber,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.Material">
    insert into jsh_material
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        Id,
      </if>
      <if test="categoryid != null">
        CategoryId,
      </if>
      <if test="name != null">
        Name,
      </if>
      <if test="mfrs != null">
        Mfrs,
      </if>
      <if test="safetystock != null">
        SafetyStock,
      </if>
      <if test="model != null">
        Model,
      </if>
      <if test="standard != null">
        Standard,
      </if>
      <if test="color != null">
        Color,
      </if>
      <if test="unit != null">
        Unit,
      </if>
      <if test="remark != null">
        Remark,
      </if>
      <if test="unitid != null">
        UnitId,
      </if>
      <if test="enabled != null">
        Enabled,
      </if>
      <if test="otherfield1 != null">
        OtherField1,
      </if>
      <if test="otherfield2 != null">
        OtherField2,
      </if>
      <if test="otherfield3 != null">
        OtherField3,
      </if>
      <if test="enableserialnumber != null">
        enableSerialNumber,
      </if>
      <if test="tenantId != null">
        tenant_id,
      </if>
      <if test="deleteFlag != null">
        delete_Flag,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="categoryid != null">
        #{categoryid,jdbcType=BIGINT},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="mfrs != null">
        #{mfrs,jdbcType=VARCHAR},
      </if>
      <if test="safetystock != null">
        #{safetystock,jdbcType=DECIMAL},
      </if>
      <if test="model != null">
        #{model,jdbcType=VARCHAR},
      </if>
      <if test="standard != null">
        #{standard,jdbcType=VARCHAR},
      </if>
      <if test="color != null">
        #{color,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        #{unit,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="unitid != null">
        #{unitid,jdbcType=BIGINT},
      </if>
      <if test="enabled != null">
        #{enabled,jdbcType=BIT},
      </if>
      <if test="otherfield1 != null">
        #{otherfield1,jdbcType=VARCHAR},
      </if>
      <if test="otherfield2 != null">
        #{otherfield2,jdbcType=VARCHAR},
      </if>
      <if test="otherfield3 != null">
        #{otherfield3,jdbcType=VARCHAR},
      </if>
      <if test="enableserialnumber != null">
        #{enableserialnumber,jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
        #{tenantId,jdbcType=BIGINT},
      </if>
      <if test="deleteFlag != null">
        #{deleteFlag,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="java.lang.Long">
    select count(*) from jsh_material
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update jsh_material
    <set>
      <if test="record.id != null">
        Id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.categoryid != null">
        CategoryId = #{record.categoryid,jdbcType=BIGINT},
      </if>
      <if test="record.name != null">
        Name = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.mfrs != null">
        Mfrs = #{record.mfrs,jdbcType=VARCHAR},
      </if>
      <if test="record.safetystock != null">
        SafetyStock = #{record.safetystock,jdbcType=DECIMAL},
      </if>
      <if test="record.model != null">
        Model = #{record.model,jdbcType=VARCHAR},
      </if>
      <if test="record.standard != null">
        Standard = #{record.standard,jdbcType=VARCHAR},
      </if>
      <if test="record.color != null">
        Color = #{record.color,jdbcType=VARCHAR},
      </if>
      <if test="record.unit != null">
        Unit = #{record.unit,jdbcType=VARCHAR},
      </if>
      <if test="record.remark != null">
        Remark = #{record.remark,jdbcType=VARCHAR},
      </if>
      <if test="record.unitid != null">
        UnitId = #{record.unitid,jdbcType=BIGINT},
      </if>
      <if test="record.enabled != null">
        Enabled = #{record.enabled,jdbcType=BIT},
      </if>
      <if test="record.otherfield1 != null">
        OtherField1 = #{record.otherfield1,jdbcType=VARCHAR},
      </if>
      <if test="record.otherfield2 != null">
        OtherField2 = #{record.otherfield2,jdbcType=VARCHAR},
      </if>
      <if test="record.otherfield3 != null">
        OtherField3 = #{record.otherfield3,jdbcType=VARCHAR},
      </if>
      <if test="record.enableserialnumber != null">
        enableSerialNumber = #{record.enableserialnumber,jdbcType=VARCHAR},
      </if>
      <if test="record.tenantId != null">
        tenant_id = #{record.tenantId,jdbcType=BIGINT},
      </if>
      <if test="record.deleteFlag != null">
        delete_Flag = #{record.deleteFlag,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update jsh_material
    set Id = #{record.id,jdbcType=BIGINT},
      CategoryId = #{record.categoryid,jdbcType=BIGINT},
      Name = #{record.name,jdbcType=VARCHAR},
      Mfrs = #{record.mfrs,jdbcType=VARCHAR},
      SafetyStock = #{record.safetystock,jdbcType=DECIMAL},
      Model = #{record.model,jdbcType=VARCHAR},
      Standard = #{record.standard,jdbcType=VARCHAR},
      Color = #{record.color,jdbcType=VARCHAR},
      Unit = #{record.unit,jdbcType=VARCHAR},
      Remark = #{record.remark,jdbcType=VARCHAR},
      UnitId = #{record.unitid,jdbcType=BIGINT},
      Enabled = #{record.enabled,jdbcType=BIT},
      OtherField1 = #{record.otherfield1,jdbcType=VARCHAR},
      OtherField2 = #{record.otherfield2,jdbcType=VARCHAR},
      OtherField3 = #{record.otherfield3,jdbcType=VARCHAR},
      enableSerialNumber = #{record.enableserialnumber,jdbcType=VARCHAR},
      tenant_id = #{record.tenantId,jdbcType=BIGINT},
      delete_Flag = #{record.deleteFlag,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.jsh.erp.datasource.entities.Material">
    update jsh_material
    <set>
      <if test="categoryid != null">
        CategoryId = #{categoryid,jdbcType=BIGINT},
      </if>
      <if test="name != null">
        Name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="mfrs != null">
        Mfrs = #{mfrs,jdbcType=VARCHAR},
      </if>
      <if test="safetystock != null">
        SafetyStock = #{safetystock,jdbcType=DECIMAL},
      </if>
      <if test="model != null">
        Model = #{model,jdbcType=VARCHAR},
      </if>
      <if test="standard != null">
        Standard = #{standard,jdbcType=VARCHAR},
      </if>
      <if test="color != null">
        Color = #{color,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        Unit = #{unit,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        Remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="unitid != null">
        UnitId = #{unitid,jdbcType=BIGINT},
      </if>
      <if test="enabled != null">
        Enabled = #{enabled,jdbcType=BIT},
      </if>
      <if test="otherfield1 != null">
        OtherField1 = #{otherfield1,jdbcType=VARCHAR},
      </if>
      <if test="otherfield2 != null">
        OtherField2 = #{otherfield2,jdbcType=VARCHAR},
      </if>
      <if test="otherfield3 != null">
        OtherField3 = #{otherfield3,jdbcType=VARCHAR},
      </if>
      <if test="enableserialnumber != null">
        enableSerialNumber = #{enableserialnumber,jdbcType=VARCHAR},
      </if>
      <if test="tenantId != null">
        tenant_id = #{tenantId,jdbcType=BIGINT},
      </if>
      <if test="deleteFlag != null">
        delete_Flag = #{deleteFlag,jdbcType=VARCHAR},
      </if>
    </set>
    where Id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.jsh.erp.datasource.entities.Material">
    update jsh_material
    set CategoryId = #{categoryid,jdbcType=BIGINT},
      Name = #{name,jdbcType=VARCHAR},
      Mfrs = #{mfrs,jdbcType=VARCHAR},
      SafetyStock = #{safetystock,jdbcType=DECIMAL},
      Model = #{model,jdbcType=VARCHAR},
      Standard = #{standard,jdbcType=VARCHAR},
      Color = #{color,jdbcType=VARCHAR},
      Unit = #{unit,jdbcType=VARCHAR},
      Remark = #{remark,jdbcType=VARCHAR},
      UnitId = #{unitid,jdbcType=BIGINT},
      Enabled = #{enabled,jdbcType=BIT},
      OtherField1 = #{otherfield1,jdbcType=VARCHAR},
      OtherField2 = #{otherfield2,jdbcType=VARCHAR},
      OtherField3 = #{otherfield3,jdbcType=VARCHAR},
      enableSerialNumber = #{enableserialnumber,jdbcType=VARCHAR},
      tenant_id = #{tenantId,jdbcType=BIGINT},
      delete_Flag = #{deleteFlag,jdbcType=VARCHAR}
    where Id = #{id,jdbcType=BIGINT}
  </update>
</mapper>