2 qq 28573739 qq_28573739 于 2016.03.11 10:55 提问

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
u013772876   2016.03.11 11:23
已采纳

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

Royal_lr
Royal_lr   Ds   Rxr 2016.03.11 13:18

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

dcxy0
dcxy0   Ds   Rxr 2016.03.11 15:45

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

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!