qq_28573739
qq_28573739
采纳率57.1%
2016-03-11 02:55 阅读 1.7k
已采纳

list集合存不进去数据

这是个后台接口
public Map getUserCouponsList(JSONObject head,JSONObject body) throws Exception {

    // 业务信息
    Map<String, Object> attributes=new HashMap<String, Object>();

    //cityCode 
    String cityCode=head.optString("cityCode");
    cityCode=GetCItyCode.getCityCode(cityCode);

    String page=body.optString("page");
    String rows=body.optString("rows");
    int type=body.optInt("type");

    String token=head.optString("token");
    Object object=UserCacheManage.getAppUser(token);

    if(object!=null){       
        UserCache user=(UserCache)object;
        String userId=user.getUserId();
        HhUserEntity hhUserEntity=super.getEntity(HhUserEntity.class, userId);
        if(hhUserEntity!=null){

            String nowTime=DateUtils.formatTime();

//%h:%i:%s
String queryString=" SELECT c.id,c.coupons_name as couponsName,c.coupons_cost as couponsCost,c.coupons_type as couponsType"
+ ",coupons_type_desc as couponsTypeDesc,c.pic_brand as picBrand,uc.is_use as isUse,date_format(c.start_time,'%Y-%c-%d') as startTime,date_format(c.end_time,'%Y-%c-%d') as endTime "
+ ",c.coupons_fullcut_desc as couponsFullcutDesc,c.coupons_discount_desc as couponsDiscountDesc,c.validity_period_desc as validityPeriodDesc "
+ " FROM hh_merchant_shop s,hh_coupons c,hh_coupons_shop cs,hh_user_coupons uc "
+ " WHERE cs.coupons_id = c.id AND cs.shop_id = s.id and uc.coupons_id=c.id and s.city_code='"+cityCode+"' and uc.user_id='"+userId+"'";

            String whereString="";
            //优惠卷类别  1.可用;2.历史
            if(type==1){
                whereString=whereString+" and ( '"+nowTime+"' between c.start_time and c.end_time ) and  uc.is_use=0 ";
            }else{
                whereString=whereString+" and (( '"+nowTime+"' > c.end_time ) or uc.is_use=1  )";
            }

            String orderString=" group by uc.id order by uc.is_use desc,c.update_time desc,c.coupons_name asc ";

            int offset=PagerUtil.getOffset(Integer.valueOf(page),Integer.valueOf(rows));
            List<Map> list=super.findListbySqlReturnMapByPage(queryString+whereString+orderString, offset, Integer.valueOf(rows));

            attributes.put("coupons", list);

        }else{
            throw new InterfaceException(new ErrorBean(ErrorCode.USER_NO_LOGIN));
        }

    }else{
        throw new InterfaceException(new ErrorBean(ErrorCode.USER_NO_LOGIN));
    }

    return  attributes;
}
debug发现查到的数据没有存到list里,咋回事??
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    u013772876 夜半无声 2016-03-11 03:23

    你是指List list=super.findListbySqlReturnMapByPage(queryString+whereString+orderString, offset, Integer.valueOf(rows));
    这个list没有数据是吧!你可以执行下你拼装的SQL能否在数据库中查到数据。还有看下findListbySqlReturnMapByPage方法是否返回数据

    点赞 1 评论 复制链接分享
  • Royal_lr Royal_lr 2016-03-11 05:18

    打个断点看看,,list有没数据,,

    点赞 1 评论 复制链接分享
  • dcxy0 Q544471255 2016-03-11 07:45

    debug看一下,可能是数据库你查询回来没数据,另外下次可以高亮一下代码,比较方便一些、。

    点赞 1 评论 复制链接分享

相关推荐