Mybatis association

来源:互联网 发布:网络教育选什么专业 编辑:程序博客网 时间:2024/05/18 00:32

javabean

  

sql封装












<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd"><mapper namespace="com.msk.bs.logic.BS2101112Logic">    <!-- map返回 -->    <resultMap type="com.msk.bs.bean.IBS2101112Bean" id="aaMap">        <result property="hisId" column="HIS_ID"/>        <result property="buyerReason" column="BUYER_REASON"/>        <result property="buyershopReason" column="BUYERSHOP_REASON"/>        <result property="slCode" column="SL_CODE"/>        <result property="houseCode" column="HOUSE_CODE"/>        <result property="buyerId" column="BUYER_ID"/>        <result property="startTime" column="START_TIME"/>        <result property="endTime" column="END_TIME"/>        <result property="applyTime" column="APPLY_TIME"/>        <result property="applyStatus" column="APPLY_STATUS"/>       <!-- <result property="applyStatusName" column="BUSI_TEL"/>-->        <result property="applySide" column="APPLY_SIDE"/>        <result property="ver" column="VER"/>        <association property="buyerInfo" javaType="com.msk.core.entity.ByBuyerBasicInfo">            <result property="buyerId" column="BUYER_ID"/>            <result property="buyerCode" column="BUYER_CODE"/>            <result property="buyerName" column="BUYER_NAME"/>            <result property="buyerAddr" column="BUYER_ADDR"/>            <result property="lgcsAreaCode" column="LGCS_AREA_CODE"/>            <result property="provinceCode" column="PROVINCE_CODE"/>            <result property="cityCode" column="CITY_CODE"/>            <result property="districtCode" column="DISTRICT_CODE "/>            <result property="buyerAddr" column="BUYER_ADDR"/>            <result property="busiTel" column="BUSI_TEL"/>        </association>        <association property="houseInfo" javaType="com.msk.core.entity.SlHouseAccount">            <result property="slCode" column="SL_CODE"/>            <result property="houseAccount" column="HOUSE_ACCOUNT"/>            <result property="houseCode" column="HOUSE_CODE"/>            <result property="houseCodeDis" column="HOUSE_CODE_DIS"/>            <result property="houseTel" column="HOUSE_TEL"/>            <result property="houseShowName" column="HOUSE_SHOW_NAME"/>            <result property="houseContact" column="HOUSE_CONTACT"/>            <result property="accountPsd" column="ACCOUNT_PSD"/>            <result property="authStatus" column="AUTH_STATUS"/>            <result property="slIdcard" column="SL_IDCARD"/>            <result property="slConFlg" column="SL_CON_FLG"/>            <result property="areaCode" column="AREA_CODE"/>            <result property="lgcsAreaCode" column="LGCS_AREA_CODE"/>            <result property="provinceCode" column="PROVINCE_CODE"/>            <result property="cityCode" column="CITY_CODE"/>            <result property="districtCode" column="DISTRICT_CODE"/>            <result property="houseAddress" column="HOUSE_ADDRESS"/>            <result property="vareaCode" column="V_AREA_CODE"/>            <result property="vlgcsAreaCode" column="V_LGCS_AREA_CODE"/>            <result property="vprovinceCode" column="V_PROVINCE_CODE"/>            <result property="vcityCode" column="V_CITY_CODE"/>            <result property="vdistrictCode" column="V_DISTRICT_CODE"/>            <result property="vhouseAddress" column="V_HOUSE_ADDRESS"/>            <result property="lat" column="LAT"/>            <result property="lon" column="LON"/>            <result property="vlat" column="V_LAT"/>            <result property="vlon" column="V_LON"/>            <result property="licenses" column="LICENSES"/>            <result property="buyerAsign" column="BUYER_ASIGN"/>            <result property="wechat" column="WECHAT"/>            <result property="qq" column="QQ"/>            <result property="email" column="EMAIL"/>            <result property="fixedTel" column="FIXED_TEL"/>            <result property="fax" column="FAX"/>            <result property="flag20" column="FLAG20"/>            <result property="flag19" column="FLAG19"/>            <result property="flag18" column="FLAG18"/>            <result property="flag17" column="FLAG17"/>            <result property="flag16" column="FLAG16"/>            <result property="flag15" column="FLAG15"/>            <result property="flag14" column="FLAG14"/>            <result property="flag13" column="FLAG13"/>            <result property="flag12" column="FLAG12"/>            <result property="flag11" column="FLAG11"/>            <result property="flag10" column="FLAG10"/>            <result property="flag9" column="FLAG9"/>            <result property="flag8" column="FLAG8"/>            <result property="flag7" column="FLAG7"/>            <result property="flag6" column="FLAG6"/>            <result property="flag5" column="FLAG5"/>            <result property="flag4" column="FLAG4"/>            <result property="flag3" column="FLAG3"/>            <result property="flag2" column="FLAG2"/>            <result property="flag1" column="FLAG1"/>            <result property="houseIntroduce" column="HOUSE_INTRODUCE"/>            <result property="houseClass" column="HOUSE_CLASS"/>            <result property="houseCategory" column="HOUSE_CATEGORY"/>            <result property="houseCategory0" column="HOUSE_CATEGORY0"/>            <result property="houseCategory1" column="HOUSE_CATEGORY1"/>            <result property="houseCategory2" column="HOUSE_CATEGORY2"/>            <result property="houseCategory3" column="HOUSE_CATEGORY3"/>            <result property="houseCategory4" column="HOUSE_CATEGORY4"/>            <result property="houseCategory5" column="HOUSE_CATEGORY5"/>            <result property="houseCategory6" column="HOUSE_CATEGORY6"/>            <result property="houseCategory7" column="HOUSE_CATEGORY7"/>            <result property="houseCategory8" column="HOUSE_CATEGORY8"/>            <result property="ver" column="VER"/>        </association>    </resultMap>    <sql id="selectFiled">        A.SL_CODE,        A.HOUSE_CODE,        A.BUYER_ID,        A.START_TIME,        A.END_TIME,        A.APPLY_TIME,        A.APPLY_STATUS,        A.APPLY_SIDE,        A.VER,        <!-- <if test="filterMap.buyerFlag==1">             IFNULL(A.APPLY_SIDE,'') AS applySide,             IFNULL(A.APPLY_STATUS,'') AS applyStatus,             (CASE A.APPLY_STATUS WHEN '2' THEN '专属会员'             WHEN '1' THEN '申请中'             ELSE '' END) AS applyStatusName,             IFNULL(A.APPLY_TIME,NOW()) AS applyTime,         </if>-->        /* IFNULL(B.BUYER_CODE,''),        IFNULL(B.BUYER_NAME,''),*/        -- IFNULL(B.LGCS_AREA_CODE,'') AS lgcsAreaCode,        -- /* IFNULL(D.LGCS_AREA_NAME,'') AS lgcsAreaName,*/        -- IFNULL(B.PROVINCE_CODE,'') AS provinceCode,        -- /*IFNULL(E.PROVINCE_NAME,'') AS provinceName,*/        -- IFNULL(B.CITY_CODE,'') AS cityCode,        -- /* IFNULL(F.CITY_NAME,'') AS cityName,*/        -- IFNULL(B.DISTRICT_CODE,'') AS districtCode,        -- /* IFNULL(G.DISTRICT_NAME,'') AS districtName,*/        -- /* IFNULL(CONCAT(C.PRLGCSNAME,' ',C.CITYNAME,' ',C.DISTRICTNAME),'') AS cityName,*/        -- IFNULL(B.BUYER_ADDR,'') AS buyerAddr,        -- IFNULL(B.BUSI_TEL,'') AS busiTel        B.BUYER_CODE,        B.BUYER_NAME,        B.LGCS_AREA_CODE,        B.PROVINCE_CODE,        B.CITY_CODE,        B.DISTRICT_CODE,        B.BUYER_ADDR,        B.BUSI_TEL,        L.SL_CODE,        L.HOUSE_ACCOUNT,        L.HOUSE_CODE,        L.HOUSE_CODE_DIS,        L.HOUSE_TEL,        L.HOUSE_SHOW_NAME,        L.HOUSE_CONTACT,        L.ACCOUNT_PSD,        L.AUTH_STATUS,        L.SL_IDCARD,        L.SL_CON_FLG,        L.AREA_CODE,        L.LGCS_AREA_CODE,        L.PROVINCE_CODE,        L.CITY_CODE,        L.DISTRICT_CODE,        L.HOUSE_ADDRESS,        L.V_AREA_CODE,        L.V_LGCS_AREA_CODE,        L.V_PROVINCE_CODE,        L.V_CITY_CODE,        L.V_DISTRICT_CODE,        L.V_HOUSE_ADDRESS,        L.LAT,        L.LON,        L.V_LAT,        L.V_LON,        L.LICENSES,        L.BUYER_ASIGN,        L.WECHAT,        L.QQ,        L.EMAIL,        L.FIXED_TEL,        L.FAX,        L.FLAG20,        L.FLAG19,        L.FLAG18,        L.FLAG17,        L.FLAG16,        L.FLAG15,        L.FLAG14,        L.FLAG13,        L.FLAG12,        L.FLAG11,        L.FLAG10,        L.FLAG9,        L.FLAG8,        L.FLAG7,        L.FLAG6,        L.FLAG5,        L.FLAG4,        L.FLAG3,        L.FLAG2,        L.FLAG1,        L.HOUSE_INTRODUCE,        L.HOUSE_CLASS,        L.HOUSE_CATEGORY,        L.HOUSE_CATEGORY0,        L.HOUSE_CATEGORY1,        L.HOUSE_CATEGORY2,        L.HOUSE_CATEGORY3,        L.HOUSE_CATEGORY4,        L.HOUSE_CATEGORY5,        L.HOUSE_CATEGORY6,        L.HOUSE_CATEGORY7,        L.HOUSE_CATEGORY8,        L.VER,       /* I.GREADE,*/        K.HIS_ID,        K.BUYER_REASON,        k.BUYERSHOP_REASON    </sql>    <sql id="selectFrom">        <!-- <if test="filterMap.buyerFlag==1">             FROM sl_bs_buyer AS A         </if>         <if test="filterMap.buyerFlag==2">             FROM sl_bs_buyer_get AS A         </if>-->        FROM sl_bs_buyer AS A        LEFT JOIN by_buyer_basic_info AS B ON A.BUYER_ID = B.BUYER_ID        /*LEFT JOIN MD_LOGISTICS_AREA AS D ON B.LGCS_AREA_CODE=D.LGCS_AREA_CODE        LEFT JOIN MD_PROVINCE E ON B.PROVINCE_CODE=E.PROVINCE_CODE        LEFT JOIN MD_CITY F ON F.CITY_CODE=B.CITY_CODE        LEFT JOIN MD_DISTRICT G ON G.DISTRICT_CODE=B.DISTRICT_CODE AND F.CITY_ID=G.CITY_ID*/        LEFT JOIN sl_bs_buyer_his K ON K.SL_CODE = A.SL_CODE        LEFT JOIN sl_house_account L ON L.SL_CODE = A.SL_CODE AND L.HOUSE_CODE = A.HOUSE_CODE        /* LEFT JOIN sl_bs_house_grade I ON I.SL_CODE = L.SL_CODE AND I.HOUSE_CODE = L.HOUSE_CODE        */        <!-- LEFT JOIN v_md_dist_area AS C ON C.PRLGCSCODE=B.PROVINCE_CODE AND C.CITYCODE=B.CITY_CODE AND C.DISTRICTCODE = B.DISTRICT_CODE     <if test="filterMap.salesTargetType!=null and filterMap.salesTargetType!=''">         INNER JOIN by_buyer_salestarget H ON H.BUYER_ID=A.BUYER_ID     </if>     <if test="filterMap.classCode!=null and filterMap.classCode!=''">         INNER JOIN by_buyer_pd_cla I ON I.BUYER_ID=A.BUYER_ID     </if>-->    </sql>    <sql id="whereCondition">        <where>            <if test="filterMap.buyerId!=null and filterMap.buyerId!=''">                AND A.BUYER_ID like #{filterMap.buyerId}            </if>            <if test="filterMap.buyerCode!=null and filterMap.buyerCode!=''">                AND B.BUYER_CODE like #{filterMap.buyerCode}            </if>            <if test="filterMap.houseCode!=null and filterMap.houseCode!=''">                AND A.HOUSE_CODE like #{filterMap.houseCode}            </if>            <if test="filterMap.buyerName!=null and filterMap.buyerName!=''">                AND B.BUYER_NAME like #{filterMap.buyerName}            </if>            <if test="filterMap.lgcsCode!=null and filterMap.lgcsCode!=''">                AND B.LGCS_CODE like #{filterMap.lgcsCode}            </if>            <if test="filterMap.buyerAddr!=null and filterMap.buyerAddr!=''">                AND B.BUYER_ADDR like #{filterMap.buyerAddr}            </if>            <if test="filterMap.busiTel!=null and filterMap.busiTel!=''">                AND B.BUSI_TEL like #{filterMap.busiTel}            </if>            <if test="filterMap.applyStatus!=null and filterMap.applyStatus!=''">                AND A.APPLY_STATUS = #{filterMap.applyStatus}            </if>            <if test="filterMap.applyStatusNames!=null">                AND A.APPLY_STATUS in                <foreach collection="filterMap.applyStatusNames" item="applyStatusName" separator="," open="("                         close=")">                    #{applyStatusName}                </foreach>            </if>            <if test="filterMap.slCode!=null and filterMap.slCode!=''">                AND A.SL_CODE = #{filterMap.slCode}            </if>            <if test="filterMap.buyerId!=null and filterMap.buyerId!=''">                AND A.BUYER_ID = #{filterMap.buyerId}            </if>            <if test="filterMap.salesTargetType!=null and filterMap.salesTargetType!=''">                AND H.SALES_TARGET_TYPE=#{filterMap.salesTargetType}            </if>            <if test="filterMap.classCode!=null and filterMap.classCode!=''">                AND I.CLASS_CODE=#{filterMap.classCode}            </if>            <if test="filterMap.provinceCode!=null and filterMap.provinceCode!=''">                AND B.PROVINCE_CODE = #{filterMap.provinceCode}            </if>            <if test="filterMap.cityCode!=null and filterMap.cityCode!=''">                AND B.CITY_CODE = #{filterMap.cityCode}            </if>            <if test="filterMap.districtCode!=null and filterMap.districtCode!=''">                AND B.DISTRICT_CODE = #{filterMap.districtCode}            </if>            AND (A.DEL_FLG IS NULL OR A.DEL_FLG =0)        </where>    </sql>    <select id="getPageCount" resultType="int" parameterType="BasePageParam">        SELECT COUNT(1)        <include refid="selectFrom"/>        <include refid="whereCondition"/>    </select>    <select id="findPageList" resultMap="aaMap"            parameterType="BasePageParam">        SELECT        <include refid="selectFiled"/>        <include refid="selectFrom"/>        <include refid="whereCondition"/>        /* order by slCode*/        <if test="paging==true">            LIMIT #{startPos},#{pageSize};        </if>    </select>    <!--<select id="findByBuyerSalestarget" resultType="com.msk.core.entity.ByBuyerSalestarget"            parameterType="BasePageParam">        SELECT          SALES_TARGET_TYPE AS salesTargetType,          SALES_TARGET_NAME AS salesTargetName        FROM by_buyer_salestarget        WHERE BUYER_ID=#{filterMap.buyerId}        AND (DEL_FLG IS NULL OR DEL_FLG =0)    </select>    <select id="findByBuyerPdCla" resultType="com.msk.core.entity.ByBuyerPdCla"            parameterType="BasePageParam">        SELECT        CLASS_CODE AS classCode,        CLASS_NAME AS className        FROM by_buyer_pd_cla        WHERE BUYER_ID=#{filterMap.buyerId}        AND (DEL_FLG IS NULL OR DEL_FLG =0)    </select>--></mapper>


0 0
原创粉丝点击