Browse Source

api接口排序bug

master
xyiege 3 years ago
parent
commit
53f8499b99
  1. 16
      src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java
  2. 50
      src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java

16
src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java

@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -79,7 +80,7 @@ public class GoodsController extends BaseController {
List<Goods> goodsList = goodsService.getTypeGoods(type,createtime,goods_type);
long endtime = System.currentTimeMillis();
JSONObject outjson = new JSONObject();
outjson.put("code",200);
outjson.put("code","success");
outjson.put("msg","成功");
outjson.put("userTime",(endtime-startTime)/1000);
outjson.put("data",goodsList);
@ -92,7 +93,12 @@ public class GoodsController extends BaseController {
List<Goods> goodsList = goodsService.getTypeGoods(type,"","");
long endtime = System.currentTimeMillis();
long howUse = (endtime-startTime)/1000l;
JSONObject outjson = AjaxResult.success("成功",howUse,goodsList);
//JSONObject outjson = AjaxResult.success("成功",howUse,goodsList);
JSONObject outjson = new JSONObject();
outjson.put("code","success");
outjson.put("msg","成功");
outjson.put("userTime",(endtime-startTime)/1000);
outjson.put("data",goodsList);
return outjson;
}
/**
@ -132,9 +138,7 @@ public class GoodsController extends BaseController {
String page = request.getParameter("page");
Integer ipage =StringUtils.isBlank(page)?1:Integer.valueOf(page);
Map retmap =goodsService.getGoodsByMap(qmap,ipage,ilimit);
//抽取出分页信息
JSONObject tmpjson = new JSONObject(retmap);
JSONArray jsonArray = tmpjson.getJSONArray("data");
JSONObject retjson = new JSONObject();
retjson.put("code","200");
@ -142,7 +146,7 @@ public class GoodsController extends BaseController {
retjson.put("page",page);
retjson.put("limit",limit);
retjson.put("userTime","2");
retjson.put("data",jsonArray);
retjson.put("data",retmap);
return retjson;
}
}

50
src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java

@ -544,33 +544,41 @@ public class GoodsServiceImpl implements GoodsService {
tgmap.put("otherIdentifiers",gd.getOtherIdentifiers());
tgmap.put("classification",gd.getClassification());
// tgmap.put("servicecode",null);
// tgmap.put("linkcode",null);
// tgmap.put("publisherId",null);
// tgmap.put("registrant",null);
// tgmap.put("resolution_url",null);
// tgmap.put("source_type",null);
// tgmap.put("source_name_type",null);
// tgmap.put("source_name",null);
// tgmap.put("sourceIdentify",null);
// tgmap.put("source_fragment",null);
// tgmap.put("target_name",null);
// tgmap.put("target_name_type",null);
// tgmap.put("targetIdentify",null);
// tgmap.put("target_fragment",null);
// tgmap.put("targetFormat",null);
// tgmap.put("source_data",null);
// tgmap.put("target_data",null);
// tgmap.put("metadataXml",null);
// tgmap.put("allocationtime",null);
if(glist!=null){
List tmpgs=new ArrayList();
for(GoodsSource gs:gslist){
tgmap.put("servicecode",gs.getServicecode());
tgmap.put("linkcode",gs.getLinkcode());
tgmap.put("publisherId",gs.getPublisherid());
tgmap.put("registrant",gs.getRegistrant());
tgmap.put("resolution_url",gs.getResolutionUrl());
tgmap.put("source_type",gs.getSourceType());
tgmap.put("source_name_type",gs.getSourceNameType());
tgmap.put("source_name",gs.getSourceName());
tgmap.put("sourceIdentify",gs.getSourceIdentify());
tgmap.put("source_fragment",gs.getSourceFragment());
tgmap.put("target_name",gs.getTargetName());
tgmap.put("target_name_type",gs.getTargetNameType());
tgmap.put("targetIdentify",gs.getTargetIdentify());
tgmap.put("target_fragment",gs.getTargetFragment());
tgmap.put("targetFormat",gs.getTargetFormat());
tgmap.put("source_data",gs.getSourceData());
tgmap.put("target_data",gs.getTargetData());
tgmap.put("metadataXml",gs.getMetadataXml());
tgmap.put("allocationtime",gs.getAllocationtime());
tgmap.put("cancellation_reason",gs.getCancellationReason());
}
tgmap.put("source",tmpgs);
}
tgmap.put("cancellationtime",g.getCancelTime());
tgmap.put("cancellation_reason",null);
tgmap.put("sale_count",g.getSaleCount());
tgmap.put("click_count",g.getClickCount());
tgmap.put("stock",gd.getStock());
tgmap.put("goods_image",gd.getGoodsImage());
tgmap.put("source",gslist);
retlist.add(tgmap);
}

Loading…
Cancel
Save