|
@@ -5,6 +5,7 @@ import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.backendsys.exception.CustException;
|
|
|
+import com.backendsys.modules.sdk.baidu.yunapp.entity.AppOperateParams;
|
|
|
import com.backendsys.modules.sdk.baidu.yunapp.entity.ExecuteScriptParams;
|
|
|
import com.backendsys.modules.sdk.baidu.yunapp.entity.ScreenshotParams;
|
|
|
import com.backendsys.modules.sdk.baidu.yunapp.entity.YuappSign;
|
|
@@ -124,7 +125,6 @@ public class YunappServiceImpl implements YunappService {
|
|
|
} catch (Exception e) {
|
|
|
throw new CustException(e.getMessage());
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -158,4 +158,41 @@ public class YunappServiceImpl implements YunappService {
|
|
|
throw new CustException(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 应用启停
|
|
|
+ * https://yunapp.baidu.com/console/bgs/doc/?d=bgs-phone&p=PHONE_API_base_app_start_and_stop
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public JSONArray appOperate(AppOperateParams appOperateParams) {
|
|
|
+ // 签名
|
|
|
+ YuappSign signEntity = yunappUtil.getSign();
|
|
|
+
|
|
|
+ // 接口参数
|
|
|
+ Map<String, Object> params = new LinkedHashMap<>();
|
|
|
+ params.put("padCodes", appOperateParams.getPad_codes());
|
|
|
+ params.put("operateType", appOperateParams.getOperate_type());
|
|
|
+ params.put("packageName", appOperateParams.getPackage_name());
|
|
|
+ params.put("createTime", signEntity.getNonce());
|
|
|
+ params.put("msg", yunappUtil.getMsg(JSONUtil.toJsonStr(params), signEntity.getNonce()));
|
|
|
+
|
|
|
+ String url = "https://platform.armvm.com/command/apps/app-operate.html" + signEntity.toParams();
|
|
|
+ System.out.println("url = " + url);
|
|
|
+ System.out.println("params = " + params);
|
|
|
+ System.out.println("paramsStr = " + JSONUtil.toJsonStr(params));
|
|
|
+
|
|
|
+ // 发起请求
|
|
|
+ try(HttpResponse response = HttpUtil.createPost(url)
|
|
|
+ .body(JSONUtil.toJsonStr(params))
|
|
|
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ .execute()
|
|
|
+ ) {
|
|
|
+ System.out.println("response = " + response.body());
|
|
|
+ return yunappUtil.getResponseJSONArray(response.body());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new CustException(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|