From 24ce46c5251e59516063eeea3c4a1eb4544b30f2 Mon Sep 17 00:00:00 2001 From: Bo Date: Sat, 14 Aug 2021 21:13:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86Gson=E6=94=B9=E4=B8=BA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8fastjson,=E4=B8=8E=E8=8B=A5=E4=BE=9D=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E4=B8=80=E8=87=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/bps/controller/QueryExpressController.java | 2 -- .../ruoyi/bps/service/impl/ExpSubsPushApiServiceImpl.java | 4 ---- .../com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java | 3 --- .../java/com/ruoyi/bps/service/impl/ExpressServiceImpl.java | 6 ------ box-test/pom.xml | 4 ---- ruoyi-system/pom.xml | 4 ---- .../com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 4 ---- .../com/ruoyi/system/service/impl/SysUserServiceImpl.java | 6 ------ .../com/ruoyi/system/service/impl/WechatApiServiceImpl.java | 3 +-- 9 files changed, 1 insertion(+), 35 deletions(-) diff --git a/box-bps/src/main/java/com/ruoyi/bps/controller/QueryExpressController.java b/box-bps/src/main/java/com/ruoyi/bps/controller/QueryExpressController.java index 68e9816ed..a0884a030 100644 --- a/box-bps/src/main/java/com/ruoyi/bps/controller/QueryExpressController.java +++ b/box-bps/src/main/java/com/ruoyi/bps/controller/QueryExpressController.java @@ -9,7 +9,6 @@ import com.alibaba.fastjson.JSONObject; import com.ruoyi.bps.service.IExpressService; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.page.TableDataInfo; -//import com.google.gson.Gson; import com.kuaidi100.sdk.request.QueryTrackParam; import com.kuaidi100.sdk.response.QueryTrackResp; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -63,7 +62,6 @@ public class QueryExpressController extends BaseController { System.out.println("快递公司:" + queryTrackParam.getCom()); System.out.println("电话:" + queryTrackParam.getPhone()); String info=expressService.QueryTrackExpress(queryTrackParam); - //QueryTrackResp queryTrackResp = new Gson().fromJson(info,QueryTrackResp.class); QueryTrackResp queryTrackResp= JSONObject.parseObject(info,QueryTrackResp.class); result = new HashMap<>(); result.put("code", "1"); diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubsPushApiServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubsPushApiServiceImpl.java index d4f5b1922..4348c9701 100644 --- a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubsPushApiServiceImpl.java +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpSubsPushApiServiceImpl.java @@ -1,7 +1,6 @@ package com.ruoyi.bps.service.impl; import com.alibaba.fastjson.JSONObject; -//import com.google.gson.Gson; import com.kuaidi100.sdk.api.Subscribe; import com.kuaidi100.sdk.contant.ApiInfoConstant; import com.kuaidi100.sdk.core.IBaseClient; @@ -102,14 +101,12 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService { SubscribeReq subscribeReq = new SubscribeReq(); subscribeReq.setSchema(ApiInfoConstant.SUBSCRIBE_SCHEMA); - //subscribeReq.setParam(new Gson().toJson(subscribeParam)); subscribeReq.setParam(JSONObject.toJSONString(subscribeParam)); IBaseClient subscribe = new Subscribe(); try{ //推送订阅,并获得快递100响应结果 HttpResult httpResult= subscribe.execute(subscribeReq); - //subscribeResp= new Gson().fromJson(httpResult.getBody(),SubscribeResp.class); subscribeResp = JSONObject.parseObject(httpResult.getBody(),SubscribeResp.class); }catch (Exception e) { @@ -278,7 +275,6 @@ public class ExpSubsPushApiServiceImpl implements IExpSubsPushApiService { //加密相等,继续处理业务逻辑 subscribeResp.setMessage("接受成功!加密验证通过!【sign】"+sign+"【ourSign】"+ourSign); - //SubscribePushParamResp subscribePushParamResp = new Gson().fromJson(param, SubscribePushParamResp.class); SubscribePushParamResp subscribePushParamResp=JSONObject.parseObject(param,SubscribePushParamResp.class); SubscribePushResult subscribePushResult = subscribePushParamResp.getLastResult(); //快递单号 diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java index ba9edb761..159955dd3 100644 --- a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressInfoServiceImpl.java @@ -10,7 +10,6 @@ import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; -//import com.google.gson.Gson; import com.kuaidi100.sdk.api.AutoNum; import com.kuaidi100.sdk.api.QueryTrack; import com.kuaidi100.sdk.core.IBaseClient; @@ -161,7 +160,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService queryTrackParam.setPhone(expressInfo.getPhone()); //获取快递信息 - //String param = new Gson().toJson(queryTrackParam); String param= JSONObject.toJSONString(queryTrackParam); QueryTrackReq queryTrackReq=new QueryTrackReq(); queryTrackReq.setParam(param); @@ -178,7 +176,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService } //将快递信息转化为QueryTrackResp对象 - //QueryTrackResp queryTrackResp = new Gson().fromJson(msg,QueryTrackResp.class); QueryTrackResp queryTrackResp= JSONObject.parseObject(msg,QueryTrackResp.class); //如果没有查到物流信息,则返回错误信息 diff --git a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressServiceImpl.java b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressServiceImpl.java index b67275717..5e547144f 100644 --- a/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressServiceImpl.java +++ b/box-bps/src/main/java/com/ruoyi/bps/service/impl/ExpressServiceImpl.java @@ -3,7 +3,6 @@ package com.ruoyi.bps.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -//import com.google.gson.Gson; import com.kuaidi100.sdk.api.QueryTrack; import com.kuaidi100.sdk.api.Subscribe; import com.kuaidi100.sdk.contant.ApiInfoConstant; @@ -42,7 +41,6 @@ public class ExpressServiceImpl implements IExpressService { for(QueryTrackParam queryTrackParam:list) { - //QueryTrackResp queryTrackResp = new Gson().fromJson(expressService.QueryTrackExpress(queryTrackParam),QueryTrackResp.class); QueryTrackResp queryTrackResp= JSONObject.parseObject(expressService.QueryTrackExpress(queryTrackParam),QueryTrackResp.class); qtList.add(queryTrackResp); } @@ -68,7 +66,6 @@ public class ExpressServiceImpl implements IExpressService { public String QueryTrackExpress(QueryTrackParam queryTrackParam) { String str=""; QueryTrackReq queryTrackReq = new QueryTrackReq(); - //String param = new Gson().toJson(queryTrackParam); String param = JSONObject.toJSONString(queryTrackParam); queryTrackReq.setParam(param); @@ -88,11 +85,9 @@ public class ExpressServiceImpl implements IExpressService { JSONObject jsonObject = JSON.parseObject(msg); if (jsonObject.containsKey("returnCode")){ - //QueryTrackResp queryTrackResp= new Gson().fromJson(msg,QueryTrackResp.class); QueryTrackResp queryTrackResp= JSONObject.parseObject(msg,QueryTrackResp.class); queryTrackResp.setStatus(queryTrackResp.getReturnCode()); queryTrackResp.setNu(queryTrackParam.getNum()); - //msg= new Gson().toJson(queryTrackResp); msg= JSONObject.toJSONString(queryTrackResp); } return msg; @@ -114,7 +109,6 @@ public class ExpressServiceImpl implements IExpressService { SubscribeReq subscribeReq = new SubscribeReq(); subscribeReq.setSchema(ApiInfoConstant.SUBSCRIBE_SCHEMA); //返回的数据格式,必须 - //subscribeReq.setParam(new Gson().toJson(subscribeParam)); subscribeReq.setParam(JSONObject.toJSONString(subscribeParam)); IBaseClient subscribe = new Subscribe(); diff --git a/box-test/pom.xml b/box-test/pom.xml index 09ee67155..e14e2e697 100644 --- a/box-test/pom.xml +++ b/box-test/pom.xml @@ -35,10 +35,6 @@ 20160810 compile - - com.google.code.gson - gson - com.ruoyi ruoyi-system diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 7eb8a88eb..77c2764df 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -22,10 +22,6 @@ com.ruoyi ruoyi-common - - com.google.code.gson - gson - diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 1bcd2f9ff..ff737a3c4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -368,10 +368,6 @@ public class SysDeptServiceImpl implements ISysDeptService Map dataMap= (Map) map.get("data"); JSONArray json = (JSONArray) dataMap.get("dataList"); List deptList = JSONArray.parseArray(json.toJSONString(), EcologyDept.class); - /*Map map = new Gson().fromJson(new Gson().toJson(mapResult.get("result")), HashMap.class); - Map dataMap= new Gson().fromJson(new Gson().toJson(map.get("data")),HashMap.class); - List deptList= new Gson().fromJson(new Gson().toJson(dataMap.get("dataList")), new TypeToken>(){}.getType());*/ - //清空部门表 deptMapper.truncateDept(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 5045313b8..4d91b94d8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -2,8 +2,6 @@ package com.ruoyi.system.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.AjaxResult; @@ -585,10 +583,6 @@ public class SysUserServiceImpl implements ISysUserService Map dataMap= (Map) map.get("data"); JSONArray json = (JSONArray) dataMap.get("dataList"); List ecologyUserList = JSONArray.parseArray(json.toJSONString(), EcologyUser.class); - /*Map map = new Gson().fromJson(new Gson().toJson(mapResult.get("result")), HashMap.class); - Map dataMap= new Gson().fromJson(new Gson().toJson(map.get("data")),HashMap.class); - List ecologyUserList= new Gson().fromJson(dataMap.get("dataList").toString(), new TypeToken>(){}.getType()); - */ //获取原同步的用户 SysUser oldSysUser=new SysUser(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WechatApiServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WechatApiServiceImpl.java index 52bad6719..4d0411e56 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WechatApiServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/WechatApiServiceImpl.java @@ -1,7 +1,6 @@ package com.ruoyi.system.service.impl; import com.alibaba.fastjson.JSONObject; -import com.google.gson.Gson; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.CacheUtils; import com.ruoyi.common.utils.DateUtils; @@ -145,7 +144,7 @@ public class WechatApiServiceImpl implements IWechatApiService { private WechatAccessToken getAccessTokenFromWechat(String corpId,String secret, String agentId){ String param ="corpid=" + corpId + "&corpsecret=" + secret; String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken"; - WechatAccessToken wechatAccessToken= new Gson().fromJson(HttpUtils.sendGet(url,param),WechatAccessToken.class); + WechatAccessToken wechatAccessToken = JSONObject.parseObject(HttpUtils.sendGet(url,param),WechatAccessToken.class); wechatAccessToken.setCorpId(corpId); wechatAccessToken.setSecret(secret); wechatAccessToken.setAgentId(agentId);