qq_28573739 2016-03-11 02:55 采纳率: 100%
浏览 1818
已采纳

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条回答

  • 夜半无声 2016-03-11 03:23
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 github训练的模型参数无法下载
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题