|
|
|
@ -1,9 +1,12 @@ |
|
|
|
package cn.chjyj.szwh.controller.api; |
|
|
|
|
|
|
|
import cn.chjyj.szwh.annotation.PassToken; |
|
|
|
import cn.chjyj.szwh.bean.Goods; |
|
|
|
import cn.chjyj.szwh.controller.BaseController; |
|
|
|
import cn.chjyj.szwh.service.GoodsService; |
|
|
|
import cn.chjyj.szwh.utils.AjaxResult; |
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
|
import com.alibaba.fastjson2.JSONArray; |
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
@ -11,6 +14,7 @@ import org.apache.commons.logging.LogFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
@ -69,21 +73,16 @@ public class GoodsController extends BaseController { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@RequestMapping("/getTypeGoods") |
|
|
|
public JSONObject getTypeGoods(String type,String createtime,String goods_type){ |
|
|
|
public JSONObject getTypeGoods(String type, String createtime, String goods_type){ |
|
|
|
//10长的时间戳
|
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
List<Goods> goodsList = goodsService.getTypeGoods(type,createtime,goods_type); |
|
|
|
long endtime = System.currentTimeMillis(); |
|
|
|
JSONObject outjson = new JSONObject(); |
|
|
|
if(goodsList!=null){ |
|
|
|
outjson.put("code","00000000"); |
|
|
|
outjson.put("msg","成功"); |
|
|
|
outjson.put("useTime",(endtime-startTime)/1000l+"ms"); |
|
|
|
outjson.put("data",goodsList); |
|
|
|
}else{ |
|
|
|
outjson.put("code","failure"); |
|
|
|
outjson.put("msg","请求失败"); |
|
|
|
} |
|
|
|
outjson.put("code",200); |
|
|
|
outjson.put("msg","成功"); |
|
|
|
outjson.put("userTime",(endtime-startTime)/1000); |
|
|
|
outjson.put("data",goodsList); |
|
|
|
return outjson; |
|
|
|
} |
|
|
|
|
|
|
|
@ -92,16 +91,8 @@ public class GoodsController extends BaseController { |
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
List<Goods> goodsList = goodsService.getTypeGoods(type,"",""); |
|
|
|
long endtime = System.currentTimeMillis(); |
|
|
|
JSONObject outjson = new JSONObject(); |
|
|
|
if(goodsList!=null){ |
|
|
|
outjson.put("code","00000000"); |
|
|
|
outjson.put("msg","成功"); |
|
|
|
outjson.put("useTime",(endtime-startTime)/1000l+"ms"); |
|
|
|
outjson.put("data",goodsList); |
|
|
|
}else{ |
|
|
|
outjson.put("code","failure"); |
|
|
|
outjson.put("msg","请求失败"); |
|
|
|
} |
|
|
|
long howUse = (endtime-startTime)/1000l; |
|
|
|
JSONObject outjson = AjaxResult.success("成功",howUse,goodsList); |
|
|
|
return outjson; |
|
|
|
} |
|
|
|
/** |
|
|
|
@ -109,37 +100,49 @@ public class GoodsController extends BaseController { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@RequestMapping("/searchGoods") |
|
|
|
public JSONObject searchGoods(@RequestBody String reqstr){ |
|
|
|
//{"pay_type":1,"goods_status":1,"record_type":"","entrust_name":"clytest1012-1","entrust_user_name":"","page":1,"limit":8}
|
|
|
|
log.info("查询委托信息接口:"+reqstr); |
|
|
|
JSONObject reqjson = JSONObject.parseObject(reqstr); |
|
|
|
public JSONObject searchGoods(HttpServletRequest request){ |
|
|
|
//{"pay_type":1,"goods_status":1,"record_type":"","entrust_name":"clytest1012-1",
|
|
|
|
// "entrust_user_name":"","page":1,"limit":8}
|
|
|
|
|
|
|
|
Map qmap = new HashMap<>(); //查询条件
|
|
|
|
qmap.put("is_delete",0);//正常状态的
|
|
|
|
if(StringUtils.isNotBlank(reqstr)){ |
|
|
|
Integer ipage = reqjson.getInteger("page"); |
|
|
|
if(ipage==null){ |
|
|
|
ipage=1; |
|
|
|
} |
|
|
|
String limit = reqjson.getString("limit"); |
|
|
|
int ilimit = (StringUtils.isBlank(limit))?8:Integer.valueOf(limit); |
|
|
|
//搜索关键词
|
|
|
|
String entrustName = reqjson.getString("entrust_name"); |
|
|
|
if(StringUtils.isNotBlank(entrustName)){ |
|
|
|
qmap.put("gd.goods_name",entrustName); |
|
|
|
} |
|
|
|
//排序方式
|
|
|
|
String orderType=reqjson.getString("record_type"); |
|
|
|
if(StringUtils.isNotBlank(orderType)){ |
|
|
|
qmap.put("orderway",orderType); |
|
|
|
} |
|
|
|
String payType = request.getParameter("pay_tyep"); |
|
|
|
if(StringUtils.isNotBlank(payType)){ |
|
|
|
qmap.put("pay_type",payType); |
|
|
|
} |
|
|
|
String goodsStatus=request.getParameter("goods_status"); |
|
|
|
if(StringUtils.isNotBlank(goodsStatus)){ |
|
|
|
qmap.put("goods_status",goodsStatus); |
|
|
|
} |
|
|
|
String entrustName = request.getParameter("entrust_name"); |
|
|
|
if(StringUtils.isNotBlank(entrustName)){ |
|
|
|
qmap.put("gd.goods_name",entrustName); |
|
|
|
} |
|
|
|
String recordType = request.getParameter("record_type"); |
|
|
|
if(StringUtils.isNotBlank(recordType)){ |
|
|
|
qmap.put("gd.goods_type",recordType); |
|
|
|
} |
|
|
|
String entrustUser= request.getParameter("entrust_user_name"); |
|
|
|
if(StringUtils.isNotBlank(entrustUser)){ |
|
|
|
qmap.put("username",entrustUser); |
|
|
|
} |
|
|
|
|
|
|
|
String limit = request.getParameter("limit"); |
|
|
|
int ilimit = (StringUtils.isBlank(limit))?20:Integer.valueOf(limit); |
|
|
|
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"); |
|
|
|
|
|
|
|
Map retmap =goodsService.getGoodsByMap(qmap,ipage,ilimit); |
|
|
|
// 结果转为json
|
|
|
|
JSONObject retjson = new JSONObject(retmap); |
|
|
|
return AjaxResult.success("成功",retjson); |
|
|
|
}else{ |
|
|
|
return AjaxResult.error("参数为空"); |
|
|
|
} |
|
|
|
JSONObject retjson = new JSONObject(); |
|
|
|
retjson.put("code","200"); |
|
|
|
retjson.put("msg","成功"); |
|
|
|
retjson.put("page",page); |
|
|
|
retjson.put("limit",limit); |
|
|
|
retjson.put("userTime","2"); |
|
|
|
retjson.put("data",jsonArray); |
|
|
|
return retjson; |
|
|
|
} |
|
|
|
} |
|
|
|
|