ibatis 引入多个model

时间:2023-10-15 20:31:14
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap namespace="ProductList">
    <typeAlias alias="productList" type="com.founder.ec.goods_no.ProductList"/>

    <typeAlias alias="goodsnos" type="com.founder.ec.goods_no.Goods"/>

    <resultMap class="goodsnos" id="goodsMap">
        <result column="GOODS_ID" property="goodsID"  />
        <result column="GOODS_NO" property="goodsNo" />
        <result column="PRODUCT_ID" property="productID" />
        <result column="GOODS_NAME" property="goodsName" />
        <result column="GOODS_DESC" property="goodsDesc" />
        <result column="STOCK_ID" property="stockID" />
        <result column="SUPPLY_ID" property="supplyID" />
        <result column="GOOD_STOCK" property="goodStock"  />
        <result column="PREPARE_STOCK" property="prepareStock" />
        <result column="LOCK_STOCK" property="lockStock"/>
        <result column="AVAILABLE_STOCK" property="availableStock" />
        <result column="COST_PRICE" property="costPrice"/>
        <result column="EC_PRICE" property="ecPrice"  />
        <result column="MARKET_PRICE" property="marketPrice" />
        <result column="BAR_CODE" property="barCode"  />
        <result column="DOUBLE_BAR_CODE" property="doubleBarCode"  />
        <result column="WEIGHT" property="weight"  />
        <result column="VOLUME" property="volume" />
        <result column="IS_DEFAULT" property="isDefault" />
        <result column="FREIGHT_TYPE" property="freightType"  />
        <result column="GOODS_MANUFACTURE_DATE" property="goodsManufactureDate" />
        <result column="PACKAGE_STANDARD" property="packageStandard"  />
        <result property="productName" column="PRODUCT_NAME"/>
        <result property="goodsUnit" column="UNIT_NAME"/>
        <result property="productCode" column="PRODUCT_CODE"/>
        <result property="proCatalogId" column="PRO_CATALOG_ID"/>
    </resultMap>

    <resultMap class="productList" id="productSimpleListMap">
    <result column="PRODUCT_ID" property="productID"/>
    <result column="PRODUCT_CODE"  property="productCode"/>
    <result column="PRODUCT_NAME"  property="productName"/>
    <result column="PRODUCT_COMMON_NAME"  property="productCommonName"/>
    <result column="PRODUCT_ALIAS_NAME"  property="productAliasName"/>
    <result column="PRODUCT_CHN_NO"  property="productChnNo"/>
    <result column="PRODUCT_ORDER"  property="productOrder"/>
    <result column="PRO_CATALOG_ID"  property="proCatalogID"/>
    <result column="PRODUCT_POINT"  property="productPoint"/>
    <result column="IS_SUPPORT_POINT"  property="isSupportPoint"/>
    <result column="PRODUCT_BRAND_ID"  property="productBrandID"/>
    <result column="DRUG_APPROVE_TYPE"  property="drugApproveType"/>
    <result column="DRUG_APPROVE_NO"  property="drugApproveNo"/>
    <result column="DRUG_TREATMENT"  property="drugTreatment"/>
    <result column="DRUG_COMPOSITION"  property="drugComposition"/>
    <result column="DRUG_TYPE"  property="drugType"/>
    <result column="DRUG_PRESCRIPTION_TYPE"  property="drugPrescriptionType"/>
    <result column="PRODUCT_TYPE_ID"  property="productTypeID"/>
    <result column="PRODUCT_KEYWORD"  property="productKeyword"/>
    <result column="PRODUCT_DESC"  property="productDesc"/>
    <result column="UNIT_ID"  property="unitID"/>
    <result column="PRODUCT_LOCALITY"  property="productLocality"/>
    <result column="PRODUCER" property="producer"/>
    <result column="QUALITY_LIMIT"  property="qualityLimit"/>
    <result column="PRODUCT_MARKET_DATE"  property="productMarketDate"/>
    <result column="IS_ONSALE"  property="isOnsale"/>
    <result column="ONSALE_TIME"  property="onsaleTime"/>
    <result column="PRODUCT_LEAST_ORDER" property="productLeastOrder"/>
    <result column="ORDER_LIMIT_AMOUNT" property="orderLimitAmount"/>
    <result column="IS_STOCK_WARN"  property="isStockWarn"/>
    <result column="PRODUCT_WARN_NUMBER" property="productWarnNumber"/>
    <result column="CATALOG_CODE"  property="catalogCode"/>
    <result column="goods_seller"  property="goodsSeller"/>
    <result column="stock_id"  property="stockNo"/>

    </resultMap>
    <!--   通过商品编码查询满足海外的商品

    <select id="getGoodsByGoodsNoImport"
            parameterClass="java.lang.String">
       select  * from goods g
          left join
           stock s
             on g.STOCK_ID=s.STOCK_ID
          LEFT  join
            GOODS_SELLER gs
             on gs.goods_seller_id=s.goods_seller_id
          LEFT JOIN
          PRODUCT p
             on g.GOODS_NO=p.PRODUCT_CODE
                  where
                     gs.IS_ABROAD='Y' AND gs.IS_DELETE='N'
                       AND G.IS_DELETE='N'
                           and g.goods_no=#goodsNo#
    </select>

-->
    <!--   通过商品编码查询productId

    <select id="getProductIdByGoodsNo"
            parameterClass="ProductList">
        select   * from product p where p.PRODUCT_ID=125858
        and g.goods_no=#goodsNo#
    </select>
 -->
    <!-- 编辑 product更新 -->
    <update id="updateImportProductList"  parameterClass="productList">
        update product
        <dynamic prepend="set">
            <isNotEmpty prepend="," property="editUserId">
                <![CDATA[ EDIT_USER_ID=#editUserId# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="," property="addUserId">
                <![CDATA[ ADD_USER_ID=#addUserId# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="," property="editTime">
                <![CDATA[ EDIT_TIME=#editTime# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="," property="productName">
                <![CDATA[ product_name=#productName# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="," property="productLeastOrder">
                <![CDATA[ product_least_order=#productLeastOrder# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="," property="productLimitAmount">
                <![CDATA[ product_limit_amount=#productLimitAmount# ]]>
            </isNotEmpty>

        </dynamic>
        where PRODUCT_CODE=#productCode#
    </update>

<!-- goods表-->
    <update id="updateImportGoods" parameterClass="goods">
        update goods
        <dynamic prepend="set">
            <isNotEmpty prepend="," property="editUserId">
                <![CDATA[ EDIT_USER_ID=#editUserId# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="," property="addUserId">
                <![CDATA[ ADD_USER_ID=#addUserId# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="," property="editTime">
                <![CDATA[ EDIT_TIME=#editTime# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="," property="standPackage">
                <![CDATA[ stand_package=#standPackage# ]]>
            </isNotEmpty>

            <isNotEmpty prepend="," property="standPackage">
                <![CDATA[ stand_package=#standPackage# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="," property="weight">
                <![CDATA[ weight=#weight# ]]>
            </isNotEmpty>

            <isNotEmpty prepend="," property="marketPrice">
                <![CDATA[ market_price=#marketPrice# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="," property="ecPrice">
                <![CDATA[ ec_price=#ecPrice# ]]>
            </isNotEmpty>

            <isNotEmpty prepend="," property="availableStock">
                <![CDATA[ available_stock=#availableStock# ]]>
            </isNotEmpty>
        </dynamic>
        where PRODUCT_ID=#productId#
    </update>

</sqlMap>