Bladeren bron

更新!

TRX 1 jaar geleden
bovenliggende
commit
9024387be8

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/httpRequest/conf/IotCenterAPIConfig.java

@@ -21,7 +21,7 @@ public class IotCenterAPIConfig {
     // 项目同步
     public static final String syncFromFullCardProjects = "/projectSync/free/syncFromFullCardProjects";
 
-    public static final String openAPISendMessage = "/openAPI/manager/sendIotMessage";
+    public static final String openAPISendMessage = "/oitOpenAPI/manager/sendIotMessage";
 
     public static final HashMap<String, ApiConfParam> map = new HashMap<>();
 

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DevicePermissIotService.java

@@ -130,7 +130,7 @@ public class DevicePermissIotService {
                 }
                 IotSendParam param = new IotSendParam();
                 param.setDeviceId(deviceId);
-                param.setIdentifier("permissionChange");
+                param.setIdentifier("permissionNotice");
 
                 PermissionChange change = new PermissionChange();
                 change.setTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/openAPI/OpenAPIRegisterService.java

@@ -31,7 +31,7 @@ public class OpenAPIRegisterService {
 
     public ResultContent initRegisterPAIS() {
         String str = restTemplate.getForObject("http://" + serviceId + "/v3/api-docs", String.class);
-        List<OpenApiInfo> openAPIS = OpenAPIScan.scanAPI(str, "一卡通");
+        List<OpenApiInfo> openAPIS = OpenAPIScan.scanAPI(str, "一卡通", "openAPI");
         RefreshApiParam param = new RefreshApiParam();
         param.setServerName(serviceId.toLowerCase());
         param.setPredicateArgs("/openAPI/**");

+ 3 - 110
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/openAPI/OpenApiRequestService.java

@@ -73,127 +73,18 @@ public class OpenApiRequestService extends SuperService {
             return ResultContent.buildFail("projectOid为空");
         }
         ProjectIotInfo projectIotInfo = projectIotInfoDao.findTopByProjectOid(projectOid);
-        projectIotInfo = new ProjectIotInfo();
-        projectIotInfo.setUrl("http://192.168.32.113:9601");
-        projectIotInfo.setAk("");
-        projectIotInfo.setSk("");
-
         if (ObjectUtils.isEmpty(projectIotInfo)) {
             return ResultContent.buildFail(String.format("项目未配置物联网AK/SK信息", projectOid));
         }
         APIResponseModel responseModel = requestAPI(projectIotInfo.getUrl(), apiName,
                 projectIotInfo.getAk(), projectIotInfo.getSk(), param);
         if (responseModel.isFailed()) {
+            log.error("{}", responseModel.getMsg());
             return ResultContent.buildFail(responseModel.getMsg());
         }
         return ResultContent.buildSuccess(responseModel);
     }
 
-//    /**
-//     * 银联请求
-//     *
-//     * @param url
-//     * @param data
-//     * @param tClass
-//     * @return
-//     */
-//    public SuperResponseModel requestUnionAPI(String url,
-//            Object data,
-//            Class<? extends SuperResponseModel> tClass) {
-//        RequestInfoSaveParam param = new RequestInfoSaveParam();
-//        param.setParam(data);
-//        param.setApiParam(url);
-//        param.setUserId(getCurrentUserId());
-//        SuperResponseModel responseModel = null;
-//        try {
-//            responseModel = tClass.newInstance();
-//            ApiConfParam apiConfParam = new ApiConfParam();
-//            apiConfParam.setApiName(url);
-//            apiConfParam.setMethodType(MethodType.Json);
-//            String dataJsonStr = JSONUtil.toJsonStr(data);
-//            String sign = AesUtils.signData(dataJsonStr);
-//            // 请求时间记时
-//            StopWatch stopWatch = new StopWatch();
-//            stopWatch.start();
-//
-//            String timestamp = DateUtils.paresTime(System.currentTimeMillis(), DateUtils.unionAuth);
-//            String nonce = CommonUtil.UUID();
-//            String c = String.format("%s%s%s%s", payConfig.getAppId(), timestamp, nonce, sign);
-//
-//            String signature = AesUtils.signMacSHA256(c, payConfig.getAppKey());
-//            String authorization = "OPEN-BODY-SIG AppId=" + "\"" + payConfig.getAppId() + "\""
-//                    + ",Timestamp=" + "\"" + timestamp + "\""
-//                    + ",Nonce=" + "\"" + nonce + "\""
-//                    + ",Signature=" + "\"" + signature + "\"";
-//
-//
-//            String response = "";
-//            PrintWriter out = null;
-//            BufferedReader in = null;
-//            int code = 400;
-//            try {
-//                URL realUrl = new URL(url);
-//                URLConnection conn = realUrl.openConnection();
-//                HttpURLConnection httpUrlConnection = (HttpURLConnection) conn;
-//                httpUrlConnection.setRequestProperty("Content-Type", "application/json");
-//                httpUrlConnection.setRequestProperty("authorization", authorization);
-//                httpUrlConnection.setDoOutput(true);
-//                httpUrlConnection.setDoInput(true);
-//                out = new PrintWriter(httpUrlConnection.getOutputStream());
-//                out.write(dataJsonStr);
-//                out.flush();
-//                httpUrlConnection.connect();
-//                code = httpUrlConnection.getResponseCode();
-//                in = new BufferedReader(new InputStreamReader(httpUrlConnection.getInputStream()));
-//                String line;
-//                while ((line = in.readLine()) != null) {
-//                    response += line;
-//                }
-//                log.info("response: {}", response);
-//                responseModel = jsonHelper.toObject(response, tClass);
-//            } catch (Exception e) {
-//                e.printStackTrace();
-//                responseModel.setCode(code);
-//                responseModel.setMsg(e.getMessage());
-//            } finally {
-//                try {
-//                    if (out != null) {
-//                        out.close();
-//                    }
-//                    if (in != null) {
-//                        in.close();
-//                    }
-//                } catch (Exception ex) {
-//                    ex.printStackTrace();
-//                }
-//            }
-//            String errMsg = responseModel.getErrMsg();
-//            if (StringUtils.isNotEmpty(errMsg) && !errMsg.equals("success")) {
-//                code = 400;
-//            }
-//            log.info("response: {} {}", responseModel.getErrCode(), code);
-//            responseModel.setCode(code);
-//            if (code == 504) {
-//                responseModel.setErrMsg("银联服务无法访问");
-//            }
-//            stopWatch.stop();
-//            responseModel.setMillis(stopWatch.getTotalTimeMillis());
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//            responseModel.setFailed(String.format("请求出错:%s", e.getMessage()));
-//            return responseModel;
-//        }
-//        param.setMillis(responseModel.getMillis());
-//        param.setIsSuccess(responseModel.isSuccess);
-//        param.setMsg(responseModel.getMsg());
-//        param.setResponse(responseModel);
-//        param.setRequestType(RequestType.UnionFrictionlessPay);
-//        // 请求日志
-//        requestInfoService.saveRequestInfo(param);
-//        return responseModel;
-//    }
-
-
     public APIResponseModel requestAPI(
             String url,
             String apiName,
@@ -203,6 +94,8 @@ public class OpenApiRequestService extends SuperService {
             String authorization = SignUtil.sign(JSONUtil.toJsonStr(data), ak, sk);
             HashMap<String, Object> headers = new HashMap<>();
             headers.put("Authorization", authorization);
+            headers.put("appId", ak);
+
             ApiConfParam apiConfParam = new ApiConfParam();
             apiConfParam.setApiName(url);
             StopWatch stopWatch = new StopWatch();

+ 9 - 4
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/openAPI/OpenAppManagerService.java

@@ -1,16 +1,19 @@
 package com.zhongshu.card.server.core.service.openAPI;
 
 import com.github.microservice.auth.security.helper.AuthHelper;
+import com.github.microservice.net.ResultContent;
 import com.zhongshu.opengateway.client.model.param.SignParam;
 import com.zhongshu.opengateway.client.service.OpenApiService;
 import com.zhongshu.opengateway.client.service.SignService;
 import com.zhongshu.opengateway.client.type.AppState;
 import com.zhongshu.opengateway.client.type.AppType;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
+@Slf4j
 @Service
 public class OpenAppManagerService {
 
@@ -29,28 +32,30 @@ public class OpenAppManagerService {
     /**
      * 添加应用
      */
-    public Object add(SignParam param){
+    public Object add(SignParam param) {
+        var ret = restTemplate.postForEntity("http://openapiserver-wjf/manager/app/add", param, ResultContent.class);
+        log.error("ret {}", ret);
         return signService.add(param);
     }
 
     /**
      * 删除应用
      */
-    public Object delete(String appId){
+    public Object delete(String appId) {
         return signService.delete(appId);
     }
 
     /**
      * 禁用/启用
      */
-    public Object disable(String appId, AppState appState){
+    public Object disable(String appId, AppState appState) {
         return signService.disable(appId, appState);
     }
 
     /**
      * 分页获取该项目下的app列表
      */
-    public Object page(String businessId, AppType appType, AppState appState, String appName, Pageable pageable){
+    public Object page(String businessId, AppType appType, AppState appState, String appName, Pageable pageable) {
         return signService.pageByBusinessId(businessId, appType, appState, appName, pageable);
     }
 }