mybatis 之 parameterType="List" 2

<select id="queryGoodsByGoodsNoPcweb" parameterType="List" resultMap="simpleProductExtLucene">
        select g.goods_no,
            wp.PRODUCT_ID, p.product_name, p.drug_treatment, p.drug_prescription_type,
            p.product_least_order || ‘‘ as "product_least_order", p.order_limit_amount || ‘‘ as "order_limit_amount",
            wg.goods_id, g.goods_name,
            g.market_price || ‘‘ as "market_price",
            g.sale_amount, g.click_amount, nvl(g.available_stock,0) || ‘‘ as "available_stock",
            pc.pro_catalog_id || ‘‘ as "pro_catalog_id", pi.pro_image_url, tag.tag_id || ‘‘ as "tag_id",
            tag.tag_icon_url,
            <![CDATA[
                (case when exists (
                        select 1
                            from ec_promote_rule_goods_new npg
                            right join ec_promote_rule_new np on npg.promote_rule_id = np.promote_rule_id
                        where npg.goods_id = wg.goods_id
                            and np.promote_client = ‘wap‘
                            and np.is_enable = ‘Y‘
                            and to_char(sysdate, ‘yyyy-mm-dd hh24:mi:dd‘) between np.begin_time and np.end_time
                    )
                 then ‘Y‘ else ‘N‘ end) as MOBILE_SPECIAL,
            ]]>
            pc.full_index,
            to_number(case
                when wg.discount_state = ‘enable‘
                     <!-- and wg.member_ranks = ‘0‘  -->
                     and to_char(sysdate, ‘yyyy-mm-dd hh24:mi:dd‘) between wg.begin_time and wg.end_time
                     and wg.discount_price is not null
                     and wg.discount_price != 0
                then
                    wg.discount_price
                when g.discount_state = ‘enable‘
                     <!-- and g.member_ranks = ‘0‘  -->
                     and to_char(sysdate, ‘yyyy-mm-dd hh24:mi:dd‘) between g.begin_time and g.end_time
                     and g.discount_price is not null
                     and g.discount_price != 0
                then
                    g.discount_price
                else
                    g.ec_price
            end) || ‘ ‘ as ec_price,
            (case
                when wg.discount_state = ‘enable‘
                    and to_char(sysdate, ‘yyyy-mm-dd hh24:mi:dd‘) between wg.begin_time
                    and wg.end_time
                then
                    wg.promote_phrase
                when g.discount_state = ‘enable‘
                    and to_char(sysdate, ‘yyyy-mm-dd hh24:mi:dd‘) between g.begin_time
                    and g.end_time
                then
                    g.promote_phrase
                else
                    ‘‘
            end) as promote_phrase, pc.pro_catalog_name, wp.product_keyword, wp.PRODUCT_CHN_NO,
            pb.product_brand_name, nvl(wp.product_order,0) product_order
        from product wp
            left join product p on p.product_id = wp.product_id and p.is_delete = ‘N‘
            left join goods wg on wp.product_id = wg.product_id and wg.is_delete = ‘N‘ and wg.is_default = ‘Y‘
            left join goods g on g.goods_id = wg.goods_id and g.is_delete = ‘N‘ and g.is_default = ‘Y‘
            left join product_catalog pc on pc.pro_catalog_id = wp.pro_catalog_id and pc.is_delete = ‘N‘
            left join product_brand pb on pb.product_brand_id = wp.product_brand_id and pb.is_delete = ‘N‘
            left join (
                        select min(pt.tag_id) as tag_id,
                            min(ptd.goods_id) as goods_id,
                            min(pt.tag_icon_url) as tag_icon_url
                        from product_tag_def ptd, product_tag pt
                        where ptd.tag_id = pt.tag_id
                            and pt.is_delete = ‘N‘
                            and pt.tag_type = ‘icon‘
                        group by ptd.goods_id
                    ) tag on tag.goods_id = wg.goods_id
            left join (
                        select pig.product_id as product_id,
                            min(pig.image_order),
                            min(pig.pro_image_url) as
                            pro_image_url
                        from wap_product_img pig
                        where pig.image_type = ‘small‘
                        group by pig.product_id) pi on wp.product_id = pi.product_id
        where wp.is_delete = ‘N‘
            and p.is_onsale = ‘Y‘
            and wg.is_delete = ‘N‘
            and wg.is_default = ‘Y‘
            and wp.pro_catalog_id is not null
            and wp.product_code NOT like ‘AJ%‘
            and g.goods_no in
            <foreach collection="list" item="listItem" index="index"
                open="(" separator="," close=")" >
                #{listItem,jdbcType=VARCHAR}
            </foreach>
    </select>
<select id="queryGoodsByGoodsNoMobile" parameterType="List" resultMap="simpleProductExtLucene">
        select g.goods_no,
            wp.PRODUCT_ID, p.product_name, p.drug_treatment, p.drug_prescription_type,
            p.product_least_order || ‘‘ as "product_least_order", p.order_limit_amount || ‘‘ as "order_limit_amount",
            wg.goods_id, g.goods_name,
            g.market_price || ‘‘ as "market_price",
            g.sale_amount, g.click_amount, nvl(g.available_stock,0) || ‘‘ as "available_stock",
            pc.pro_catalog_id || ‘‘ as "pro_catalog_id", pi.pro_image_url, tag.tag_id || ‘‘ as "tag_id",
            tag.tag_icon_url,
            <![CDATA[
                (case when exists (
                        select 1
                            from ec_promote_rule_goods_new npg
                            right join ec_promote_rule_new np on npg.promote_rule_id = np.promote_rule_id
                        where npg.goods_id = wg.goods_id
                            and np.promote_client = ‘wap‘
                            and np.is_enable = ‘Y‘
                            and to_char(sysdate, ‘yyyy-mm-dd hh24:mi:dd‘) between np.begin_time and np.end_time
                    )
                 then ‘Y‘ else ‘N‘ end) as MOBILE_SPECIAL,
            ]]>
            pc.full_index,
            to_number(case
                when wg.discount_state = ‘enable‘
                     <!-- and wg.member_ranks = ‘0‘  -->
                     and to_char(sysdate, ‘yyyy-mm-dd hh24:mi:dd‘) between wg.begin_time and wg.end_time
                     and wg.discount_price is not null
                     and wg.discount_price != 0
                then
                    wg.discount_price
                when g.discount_state = ‘enable‘
                     <!-- and g.member_ranks = ‘0‘  -->
                     and to_char(sysdate, ‘yyyy-mm-dd hh24:mi:dd‘) between g.begin_time and g.end_time
                     and g.discount_price is not null
                     and g.discount_price != 0
                then
                    g.discount_price
                else
                    g.ec_price
            end) || ‘ ‘ as ec_price,
            (case
                when wg.discount_state = ‘enable‘
                    and to_char(sysdate, ‘yyyy-mm-dd hh24:mi:dd‘) between wg.begin_time
                    and wg.end_time
                then
                    wg.promote_phrase
                when g.discount_state = ‘enable‘
                    and to_char(sysdate, ‘yyyy-mm-dd hh24:mi:dd‘) between g.begin_time
                    and g.end_time
                then
                    g.promote_phrase
                else
                    ‘‘
            end) as promote_phrase, pc.pro_catalog_name, wp.product_keyword, wp.PRODUCT_CHN_NO,
            pb.product_brand_name, nvl(wp.product_order,0) product_order
        from wap_product wp
            left join product p on p.product_id = wp.product_id and p.is_delete = ‘N‘
            left join wap_goods wg on wp.product_id = wg.product_id and wg.is_delete = ‘N‘ and wg.is_default = ‘Y‘
            left join goods g on g.goods_id = wg.goods_id and g.is_delete = ‘N‘ and g.is_default = ‘Y‘
            left join product_catalog pc on pc.pro_catalog_id = wp.pro_catalog_id and pc.is_delete = ‘N‘
            left join product_brand pb on pb.product_brand_id = wp.product_brand_id and pb.is_delete = ‘N‘
            left join (
                        select min(pt.tag_id) as tag_id,
                            min(ptd.goods_id) as goods_id,
                            min(pt.tag_icon_url) as tag_icon_url
                        from product_tag_def ptd, product_tag pt
                        where ptd.tag_id = pt.tag_id
                            and pt.is_delete = ‘N‘
                            and pt.tag_type = ‘icon‘
                        group by ptd.goods_id
                    ) tag on tag.goods_id = wg.goods_id
            left join (
                        select pig.product_id as product_id,
                            min(pig.image_order),
                            min(pig.pro_image_url) as
                            pro_image_url
                        from wap_product_img pig
                        where pig.image_type = ‘small‘
                        group by pig.product_id) pi on wp.product_id = pi.product_id
        where wp.is_delete = ‘N‘
            and p.is_onsale = ‘Y‘
            and wg.is_delete = ‘N‘
            and wg.is_default = ‘Y‘
            and wp.pro_catalog_id is not null
            and wp.product_code NOT like ‘AJ%‘
            and g.goods_no in
            <foreach collection="list" item="listItem" index="index"
                open="(" separator="," close=")" >
                #{listItem,jdbcType=VARCHAR}
            </foreach>
    </select>

    public List<Map<String, Object>> queryGoodsByGoodsNoPcweb(List<String> goodsNos);
public ServiceMessage<List<Map<String, Object>>> queryGoodsListByGoodsNoList(List<String> goodsNoList, SiteType siteType) {
        try {
            if (goodsNoList == null || goodsNoList.size() < 1) {
                return super.returnParamsError("接收到的goodsNoList(" + goodsNoList + ")为空");
            } else if (goodsNoList.get(0) == null || "".equals(goodsNoList.get(0).trim())) {
                return super.returnParamsError("接收到的goodsNoList(" + goodsNoList.get(0) + ")元素为空");
            } else if (siteType == null) {
                return super.returnParamsError("接收到的SiteType(" + siteType + ")元素为空");
            }
            List<Map<String, Object>> goodsList = null;
            if (SiteType.PCWEB.equals(siteType)) {
                goodsList = goodsMapper.queryGoodsByGoodsNoPcweb(goodsNoList);
            } else if (SiteType.MOBILE.equals(siteType)) {
                goodsList = goodsMapper.queryGoodsByGoodsNoMobile(goodsNoList);
            }
            return super.returnCorrectResult(goodsList);
        } catch (Throwable e) {
            return super.returnException(e);
        }
    }
时间: 2024-07-29 17:36:03

mybatis 之 parameterType="List" 2的相关文章

mybatis的parameterType使用map实现真正的sql随意写

在dao层给map赋值 纠正一下应该把dd作为传入而不是sbiId; sqlMap中的parameterType="java.util.Map", 就 OK package com.ldrc.srm.jczx.web.results.module.screen; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.spr

记录一次mybatis中parameterType中使用String和string的区别

今天修改一个问题. xml中使用的是#{xxxx  jdbcType=String} 但是这个sql  查询需要用到  in 如果这样查询 会变成 in  ( "1,2,3,4,5") 所以我把他改成 in <foreach collection="xxx.split(',')" item="item" open="(" close=")" separator=","> #{

mybatis 之 parameterType=&quot;java.util.List&quot;

<!-- 添加 --> <insert id="saveBatchMemberRoleConnRepModel" parameterType="java.util.List"> INSERT INTO member_role_conn (member_id,role_id,rank_id,time_rang,begin_time,end_time,long_date,get_time,is_delete,add_user,add_time,e

mybatis 之 parameterType=&quot;list&quot;1

/** * 判断当前分类产品分类的父分类是否已经添加到标签分类中, * 如果存在 返回true,否则,返回false * @param catalogId * @return */ public ServiceMessage<Boolean> checkParentCatalogIsExistInLabel(long catalogId){ // List<Long> catalogList =this.productCatalogMapper.getParentCatalogBy

mybatis 之 parameterType=&quot;Map&quot;

// 获得品牌下的商品 Map<String, Object> params = new HashMap<String, Object>(); params.put("brands", brandId); List<HashMap<String, Object>> productBrands = productBrandService.getBrandProductByBrandId(params); public List<Has

mybatis 之 parameterType=&quot;list&quot;

<!-- 根据货品编号查找货品图片地址,货品ID,商品ID,货品名称 --> <select id="getGoodsInfoByGoodsNo" parameterType="list" resultMap="goodsResultImg"> select g.product_id,g.goods_id,g.goods_name,m.pro_image_url,g.goods_no,g.market_price from

mybatis 之parameterType=&quot;Long&quot;

<select id="selectByPrimaryKeyByArrayMemberId" resultType="memberModel" parameterType="Long"> select <include refid="Base_Column_List"/> from member m where m.IS_DELETE = 'N' and m.member_id IN <forea

mybatis(一) mapper动态代理

因为dao开发,会每次创建实体类对象,会传入id等固定查询值,存在硬编码问题,所以采用mapper动态代理(不用创建实体类对象,只需要接口,由mapper自动生成) 与之前mybatis(一)步骤一样,但是需要将mapper.xml文件作出修改: namespace:必须是接口类的全路径 (<mapper namespace="">) id:必须是接口的方法名(<select id=""/>) parameterType:必须是接口方法里面的

记录一次bug解决过程:规范变量名称和mybatis的使用以及代码优化

一.总结 Mybatis中当parameterType为基本数据类型的时候,统一采用_parameter来代替基本数据类型变量. Mybatis中resultMap返回一个对象,resultType返回一个Map简单数据类型(由于需要缓存到JVM中)的映射关系. String类型转Integer类型:String类型转int类型用到的方法是不一样的. 方法入口处第一行写new Date(),防止时间在23:59:59跨界对逻辑带来影响. 考虑到上线app_resource表忘记配置供应商比例,在