mybais 之parameterType ="list"

时间:2021-05-23 11:26:52
    <!-- 根据货品编号获取商品价格和库存 -->
    <select id="getGoodsPriceAndStockByGoodsNo" resultMap="goodsResult"
        parameterType="list">
        select a.goods_id,
        a.goods_no,
        a.goods_name,
        a.good_stock,
        a.prepare_stock,
        a.lock_stock,
        a.cost_price,
        a.ec_price,
        a.market_price
        from goods a
        where a.is_delete = 'N'
        and a.goods_no in
        <foreach collection="list" item="listItem" index="index" open="("
            separator="," close=")">
            #{listItem,jdbcType=VARCHAR}
        </foreach>
    </select>
    /**
     * 商品信息批量查询接口,根据goodsNo 获取商品价格和库存信息
     * @param goodsNos
     * @return
     */
    public ServiceMessage<List<Goods>> getGoodsPriceAndStockByGoodsNo(List<String> goodsNos){
        logger.debug("[商品信息批量查询接口]:...");
        if(null==goodsNos||goodsNos.size()==0){
            logger.debug("[商品信息批量查询接口]:...参数错误");
            return super.returnCorrectResult(MsgStatus.PARAMS_ERROR.getCode());
        }
        List<Goods> goodsList =this.iGoodsMapper.getGoodsPriceAndStockByGoodsNo(goodsNos);
        return super.returnCorrectResult(goodsList);
    }
    /**
     * 商品信息批量查询接口,根据goodsNo 获取商品价格和库存信息
     *
     * @param goodsNos
     * @return
     */
    List<Goods> getGoodsPriceAndStockByGoodsNo(List<String> goodsNos);
/**
     * 商品信息批量查询接口,根据goodsNo 获取商品价格和库存信息
     * @param goodsNos
     * @return   getGoodsJsonCheck
     */
    ServiceMessage<List<Goods>> getGoodsPriceAndStockByGoodsNo(List<String> goodsNos);
    @Test
    public void getGoodsPriceAndStockByGoodsNo() {
        GoodsService goodsService = J1SOAHessianHelper.getService(url, GoodsService.class);
        List<String> goodList =new ArrayList<String>();
        goodList.add("AK11933");
        goodList.add("14000");
        ServiceMessage<List<Goods>> result =  goodsService.getGoodsPriceAndStockByGoodsNo(goodList);
        System.out.println(JSON.toJSONString(result));
    }