<?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.hzya.frame.bip.v3.v2207.dao.impl.BipArchivesDaoImpl">
    <resultMap id="get-ArchivesEntity-result" type="com.hzya.frame.bip.v3.v2207.entity.BipArchivesEntity" >
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="leftAppId" column="left_app_id" jdbcType="VARCHAR"/>
        <result property="leftAppCode" column="left_app_code" jdbcType="VARCHAR"/>
        <result property="leftAppName" column="left_app_name" jdbcType="VARCHAR"/>
        <result property="leftApiId" column="left_api_id" jdbcType="VARCHAR"/>
        <result property="leftId" column="left_id" jdbcType="VARCHAR"/>
        <result property="leftCode" column="left_code" jdbcType="VARCHAR"/>
        <result property="leftName" column="left_name" jdbcType="VARCHAR"/>
        <result property="rightAppId" column="right_app_id" jdbcType="VARCHAR"/>
        <result property="rightAppCode" column="right_app_code" jdbcType="VARCHAR"/>
        <result property="rightAppName" column="right_app_name" jdbcType="VARCHAR"/>
        <result property="rightApiId" column="right_api_id" jdbcType="VARCHAR"/>
        <result property="rightId" column="right_id" jdbcType="VARCHAR"/>
        <result property="rightCode" column="right_code" jdbcType="VARCHAR"/>
        <result property="rightName" column="right_name" jdbcType="VARCHAR"/>
        <result property="sorts" column="sorts" jdbcType="INTEGER"/>
        <result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
        <result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
        <result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
        <result property="sts" column="sts" jdbcType="VARCHAR"/>
        <result property="org_id" column="org_id" jdbcType="VARCHAR"/>
        <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
    </resultMap>

    <select id="queryArchivesData" resultMap="get-ArchivesEntity-result"
            parameterType="com.hzya.frame.bip.v3.v2207.entity.BipArchivesEntity">
        select
        right_code
        from
        <choose>
            <when test="archivesType == '1'.toString()"> sys_personnel_control </when>
            <when test="archivesType == '2'.toString()"> sys_org_control </when>
            <when test="archivesType == '6'.toString()"> sys_stock_control </when>
            <when test="archivesType == '73'.toString()"> sys_merchant_control </when>
            <when test="archivesType == 'D01'.toString()"> sys_taxrate_control </when>
            <when test="archivesType == 'jobass'.toString()"> sys_project_control </when>
            <when test="archivesType == '93'.toString()"> sys_bank_control </when>
            <when test="archivesType == '96'.toString()"> sys_bankaccount_control </when>
            <when test="archivesType == '22'.toString()"> sys_assets_control </when>
        </choose>
        <trim prefix="where" prefixOverrides="and">
            <if test="leftCode != null and leftCode != ''">and left_code = #{leftCode}</if>
            <if test="leftOrg != null and leftOrg != ''">and left_org = #{leftOrg}</if>
            and sts='Y'
        </trim>
    </select>

    <select id="queryArchivesDatays" resultMap="get-ArchivesEntity-result"
            parameterType="com.hzya.frame.bip.v3.v2207.entity.BipArchivesEntity">
        select
        right_code
        from
        <choose>
            <when test="archivesType == '0012'.toString()"> sys_stock_control </when>
            <when test="archivesType == '0006'.toString()"> sys_stock_control </when>
            <when test="archivesType == '0004'.toString()"> sys_merchant_control </when>
        </choose>
        <trim prefix="where" prefixOverrides="and">
            <if test="leftCode != null and leftCode != ''">and left_code = #{leftCode}</if>
            <if test="leftOrg != null and leftOrg != ''">and left_org = #{leftOrg}</if>
            and sts='Y'
        </trim>
    </select>

</mapper>

