<?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="cn.superdesk.uniorder.dao.mapper.organisation.SysEnterpriseExtAccountingMapper">
  <resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.organisation.SysEnterpriseExtAccounting">

    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="service_no" jdbcType="INTEGER" property="serviceNo" />
    <result column="sys_org_id" jdbcType="BIGINT" property="sysOrgId" />
    <result column="sys_virt_id" jdbcType="BIGINT" property="sysVirtId" />
    <result column="out_org_id" jdbcType="BIGINT" property="outOrgId" />
    <result column="out_virt_id" jdbcType="BIGINT" property="outVirtId" />
    <result column="rule_of_account" jdbcType="INTEGER" property="ruleOfAccount" />
    <result column="day_of_month" jdbcType="INTEGER" property="dayOfMonth" />
    <result column="account_period" jdbcType="INTEGER" property="accountPeriod" />
    <result column="is_default" jdbcType="BIT" property="isDefault" />
    <result column="deleted" jdbcType="BIT" property="deleted" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_user_id" jdbcType="BIGINT" property="createUserId" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="update_user_id" jdbcType="BIGINT" property="updateUserId" />
  </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, service_no, sys_org_id, sys_virt_id, out_org_id, out_virt_id, rule_of_account, 
    day_of_month, account_period, is_default, deleted, create_time, create_user_id, update_time, 
    update_user_id
  </sql>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.organisation.SysEnterpriseExtAccountingExample" resultMap="BaseResultMap">

    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from sys_enterprise_ext_accounting
    <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 sys_enterprise_ext_accounting
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">

    delete from sys_enterprise_ext_accounting
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.superdesk.uniorder.dao.entity.organisation.SysEnterpriseExtAccountingExample">

    delete from sys_enterprise_ext_accounting
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.organisation.SysEnterpriseExtAccounting">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sys_enterprise_ext_accounting (service_no, sys_org_id, sys_virt_id, 
      out_org_id, out_virt_id, rule_of_account, 
      day_of_month, account_period, is_default, 
      deleted, create_time, create_user_id, 
      update_time, update_user_id)
    values (#{serviceNo,jdbcType=INTEGER}, #{sysOrgId,jdbcType=BIGINT}, #{sysVirtId,jdbcType=BIGINT}, 
      #{outOrgId,jdbcType=BIGINT}, #{outVirtId,jdbcType=BIGINT}, #{ruleOfAccount,jdbcType=INTEGER}, 
      #{dayOfMonth,jdbcType=INTEGER}, #{accountPeriod,jdbcType=INTEGER}, #{isDefault,jdbcType=BIT}, 
      #{deleted,jdbcType=BIT}, #{createTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=BIGINT}, 
      #{updateTime,jdbcType=TIMESTAMP}, #{updateUserId,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.organisation.SysEnterpriseExtAccounting">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sys_enterprise_ext_accounting
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="serviceNo != null">
        service_no,
      </if>
      <if test="sysOrgId != null">
        sys_org_id,
      </if>
      <if test="sysVirtId != null">
        sys_virt_id,
      </if>
      <if test="outOrgId != null">
        out_org_id,
      </if>
      <if test="outVirtId != null">
        out_virt_id,
      </if>
      <if test="ruleOfAccount != null">
        rule_of_account,
      </if>
      <if test="dayOfMonth != null">
        day_of_month,
      </if>
      <if test="accountPeriod != null">
        account_period,
      </if>
      <if test="isDefault != null">
        is_default,
      </if>
      <if test="deleted != null">
        deleted,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createUserId != null">
        create_user_id,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="updateUserId != null">
        update_user_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="serviceNo != null">
        #{serviceNo,jdbcType=INTEGER},
      </if>
      <if test="sysOrgId != null">
        #{sysOrgId,jdbcType=BIGINT},
      </if>
      <if test="sysVirtId != null">
        #{sysVirtId,jdbcType=BIGINT},
      </if>
      <if test="outOrgId != null">
        #{outOrgId,jdbcType=BIGINT},
      </if>
      <if test="outVirtId != null">
        #{outVirtId,jdbcType=BIGINT},
      </if>
      <if test="ruleOfAccount != null">
        #{ruleOfAccount,jdbcType=INTEGER},
      </if>
      <if test="dayOfMonth != null">
        #{dayOfMonth,jdbcType=INTEGER},
      </if>
      <if test="accountPeriod != null">
        #{accountPeriod,jdbcType=INTEGER},
      </if>
      <if test="isDefault != null">
        #{isDefault,jdbcType=BIT},
      </if>
      <if test="deleted != null">
        #{deleted,jdbcType=BIT},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null">
        #{createUserId,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null">
        #{updateUserId,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.organisation.SysEnterpriseExtAccountingExample" resultType="java.lang.Long">

    select count(*) from sys_enterprise_ext_accounting
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">

    update sys_enterprise_ext_accounting
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.serviceNo != null">
        service_no = #{record.serviceNo,jdbcType=INTEGER},
      </if>
      <if test="record.sysOrgId != null">
        sys_org_id = #{record.sysOrgId,jdbcType=BIGINT},
      </if>
      <if test="record.sysVirtId != null">
        sys_virt_id = #{record.sysVirtId,jdbcType=BIGINT},
      </if>
      <if test="record.outOrgId != null">
        out_org_id = #{record.outOrgId,jdbcType=BIGINT},
      </if>
      <if test="record.outVirtId != null">
        out_virt_id = #{record.outVirtId,jdbcType=BIGINT},
      </if>
      <if test="record.ruleOfAccount != null">
        rule_of_account = #{record.ruleOfAccount,jdbcType=INTEGER},
      </if>
      <if test="record.dayOfMonth != null">
        day_of_month = #{record.dayOfMonth,jdbcType=INTEGER},
      </if>
      <if test="record.accountPeriod != null">
        account_period = #{record.accountPeriod,jdbcType=INTEGER},
      </if>
      <if test="record.isDefault != null">
        is_default = #{record.isDefault,jdbcType=BIT},
      </if>
      <if test="record.deleted != null">
        deleted = #{record.deleted,jdbcType=BIT},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createUserId != null">
        create_user_id = #{record.createUserId,jdbcType=BIGINT},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateUserId != null">
        update_user_id = #{record.updateUserId,jdbcType=BIGINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">

    update sys_enterprise_ext_accounting
    set id = #{record.id,jdbcType=BIGINT},
      service_no = #{record.serviceNo,jdbcType=INTEGER},
      sys_org_id = #{record.sysOrgId,jdbcType=BIGINT},
      sys_virt_id = #{record.sysVirtId,jdbcType=BIGINT},
      out_org_id = #{record.outOrgId,jdbcType=BIGINT},
      out_virt_id = #{record.outVirtId,jdbcType=BIGINT},
      rule_of_account = #{record.ruleOfAccount,jdbcType=INTEGER},
      day_of_month = #{record.dayOfMonth,jdbcType=INTEGER},
      account_period = #{record.accountPeriod,jdbcType=INTEGER},
      is_default = #{record.isDefault,jdbcType=BIT},
      deleted = #{record.deleted,jdbcType=BIT},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      create_user_id = #{record.createUserId,jdbcType=BIGINT},
      update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{record.updateUserId,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.organisation.SysEnterpriseExtAccounting">

    update sys_enterprise_ext_accounting
    <set>
      <if test="serviceNo != null">
        service_no = #{serviceNo,jdbcType=INTEGER},
      </if>
      <if test="sysOrgId != null">
        sys_org_id = #{sysOrgId,jdbcType=BIGINT},
      </if>
      <if test="sysVirtId != null">
        sys_virt_id = #{sysVirtId,jdbcType=BIGINT},
      </if>
      <if test="outOrgId != null">
        out_org_id = #{outOrgId,jdbcType=BIGINT},
      </if>
      <if test="outVirtId != null">
        out_virt_id = #{outVirtId,jdbcType=BIGINT},
      </if>
      <if test="ruleOfAccount != null">
        rule_of_account = #{ruleOfAccount,jdbcType=INTEGER},
      </if>
      <if test="dayOfMonth != null">
        day_of_month = #{dayOfMonth,jdbcType=INTEGER},
      </if>
      <if test="accountPeriod != null">
        account_period = #{accountPeriod,jdbcType=INTEGER},
      </if>
      <if test="isDefault != null">
        is_default = #{isDefault,jdbcType=BIT},
      </if>
      <if test="deleted != null">
        deleted = #{deleted,jdbcType=BIT},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null">
        create_user_id = #{createUserId,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null">
        update_user_id = #{updateUserId,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.organisation.SysEnterpriseExtAccounting">

    update sys_enterprise_ext_accounting
    set service_no = #{serviceNo,jdbcType=INTEGER},
      sys_org_id = #{sysOrgId,jdbcType=BIGINT},
      sys_virt_id = #{sysVirtId,jdbcType=BIGINT},
      out_org_id = #{outOrgId,jdbcType=BIGINT},
      out_virt_id = #{outVirtId,jdbcType=BIGINT},
      rule_of_account = #{ruleOfAccount,jdbcType=INTEGER},
      day_of_month = #{dayOfMonth,jdbcType=INTEGER},
      account_period = #{accountPeriod,jdbcType=INTEGER},
      is_default = #{isDefault,jdbcType=BIT},
      deleted = #{deleted,jdbcType=BIT},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_user_id = #{createUserId,jdbcType=BIGINT},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{updateUserId,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>