From 93028e8e57b05e6f9fc4350f2eb230b23d39d0d2 Mon Sep 17 00:00:00 2001 From: xyiege Date: Tue, 28 Mar 2023 09:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BA=E5=80=BC=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../szwh/controller/api/GoodsController.java | 17 +++++++---------- src/test/java/cn/chjyj/szwh/UserTest.java | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java b/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java index c98ce2d..8fa1168 100644 --- a/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java +++ b/src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java @@ -195,47 +195,44 @@ public class GoodsController extends BaseController { Map qmap = new HashMap<>(); //查询条件 qmap.put("is_delete", 0);//正常状态的 String payType = request.getString("pay_type"); - if (StringUtils.isNotBlank(payType)) { // 付费 or 免费 + if (StringUtils.isNotEmpty(payType)) { // 付费 or 免费 Integer ipayType = Integer.valueOf(payType); qmap.put("gd.charges_type", ipayType); } //商品状态 String goodsStatus = request.getString("goods_status"); - if (StringUtils.isNotBlank(goodsStatus)) { + if (StringUtils.isNotEmpty(goodsStatus)) { qmap.put("g.goods_status", goodsStatus); } // 委托数据名称 String entrustName = request.getString("entrust_name"); - if (StringUtils.isNotBlank(entrustName) || !"undefined".equals(entrustName)) { + if (StringUtils.isNotEmpty(entrustName) && !"undefined".equals(entrustName)) { qmap.put("gd.goods_name", entrustName); } //数据类型 String recordType = request.getString("record_type"); - if (StringUtils.isNotBlank(recordType) || !"undefined".equals(recordType)) { + if (StringUtils.isNotEmpty(recordType) && !"undefined".equals(recordType)) { qmap.put("gd.goods_type", recordType); } //委托方 String entrustUser = request.getString("entrust_user_name"); - if (StringUtils.isNotBlank(entrustUser) || !"undefined".equals(entrustUser)) { + if (StringUtils.isNotEmpty(entrustUser) && !"undefined".equals(entrustUser)) { qmap.put("g.entrust_name", entrustUser); } // 授权类型 String authorization = request.getString("authorization"); - if (StringUtils.isNotBlank(authorization) || !"undefined".equals(authorization)) { + if (StringUtils.isNotEmpty(authorization) && !"undefined".equals(authorization)) { Integer igoodsEntrust = Integer.valueOf(authorization); qmap.put("gd.goods_entrust", igoodsEntrust); } // goods islicode String goodsIsliCode = request.getString("goods_islicode"); - if (StringUtils.isNotBlank(goodsIsliCode) ) { + if (StringUtils.isNotEmpty(goodsIsliCode) ) { qmap.put("g.gisli", goodsIsliCode); } // 系统标识,必须字段,不能为空 String appkey = request.getString("appkey"); - if (StringUtils.isBlank(appkey)) { - // - } // 排序字段 String orderType = request.getString("order_type"); String norderType = StringUtils.isBlank(orderType) ? "id" : orderType; diff --git a/src/test/java/cn/chjyj/szwh/UserTest.java b/src/test/java/cn/chjyj/szwh/UserTest.java index 6085a19..a5136d4 100644 --- a/src/test/java/cn/chjyj/szwh/UserTest.java +++ b/src/test/java/cn/chjyj/szwh/UserTest.java @@ -2,6 +2,7 @@ package cn.chjyj.szwh; import cn.chjyj.szwh.utils.SzwhApiUtils; import com.alibaba.fastjson2.JSONObject; +import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.springframework.boot.test.context.SpringBootTest; @@ -14,4 +15,18 @@ public class UserTest { JSONObject json = SzwhApiUtils.getApiUser(usisli); System.out.println(json); } + @Test + public void jtest(){ + String sq="{\"appkey\":\"0acdbb709ee95707\",\"authorization\":\"\",\"entrust_name\":\"\",\"entrust_user_name\":\"\",\"goods_status\":\"1\",\"limit\":\"8\",\"order\":\"desc\",\"order_type\":\"createtime\",\"page\":\"1\",\"pay_type\":\"2\",\"record_type\":\"\",\"source_type\":\"\",\"timestamp\":\"1679930572\"}"; + JSONObject ijson = JSONObject.parseObject(sq); + String auth = ijson.getString("authorization"); + + if(StringUtils.isNotEmpty(auth) && !"undefined".equals(auth)){ + System.out.println("not empty"); + Integer ixx = Integer.valueOf(auth); + System.out.println(ixx); + } + System.out.println(auth); + //System.out.println(ijson.getString("authorization")); + } }