提交 67219d8a 编写于 作者: F fancy

自助打包增加删除华为HMS

上级 3035b6e7
......@@ -17,6 +17,9 @@ public class HuaweiPushConfig extends ConfigObject {
private static final String O2_app_id_default = "100016851";
private static final String O2_app_secret_default = "b3ad9287e8d1d16d0aad8fde66e59118";
// outer 包的 华为推送 appId和secret
private static final String O2_app_id_outer = "105181971";
private static final String O2_app_secret_outer = "59862104d3080cfda20bbe6881db88327f015e53646ae675d71358cc81918fc3";
// 获取accesssToken的url
private static final String huawei_get_token_url = "https://oauth-login.cloud.huawei.com/oauth2/v3/token";
// 华为推送消息接口url
......@@ -31,6 +34,17 @@ public class HuaweiPushConfig extends ConfigObject {
this.appSecret = O2_app_secret_default;
}
/**
* 外部包的时候使用的华为推送key
* @return
*/
public static HuaweiPushConfig outerPackInstance() {
HuaweiPushConfig config = new HuaweiPushConfig();
config.setAppId(O2_app_id_outer);
config.setAppSecret(O2_app_secret_outer);
return config;
}
@FieldDescribe("华为推送应用的appId")
......
......@@ -57,6 +57,7 @@ public class JpushConfig extends ConfigObject {
config.setAppKey(O2_app_key_outer);
config.setMasterSecret(O2_master_secret_outer);
config.setEnable(true);
config.setHuaweiPushConfig(HuaweiPushConfig.outerPackInstance());
return config;
}
......
......@@ -35,7 +35,7 @@ public class ActionAndroidPack extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionAndroidPack.class);
ActionResult<Wo> execute(String token, String appName, String o2ServerProtocol, String o2ServerHost,
String o2ServerPort, String o2ServerContext, String isPackAppIdOuter, String urlMapping,String appVersionName, String appBuildNo,
String o2ServerPort, String o2ServerContext, String isPackAppIdOuter, String urlMapping,String appVersionName, String appBuildNo, String deleteHuawei,
String fileName, byte[] bytes,
FormDataContentDisposition disposition) throws Exception {
ActionResult<Wo> result = new ActionResult<Wo>();
......@@ -81,7 +81,7 @@ public class ActionAndroidPack extends BaseAction {
if (!fileName.toLowerCase().endsWith("png")) {
throw new ExceptionFileNotPng();
}
String s = postFormData(token, appName, o2ServerProtocol, o2ServerHost, o2ServerPort, o2ServerContext, isPackAppIdOuter, urlMapping, appVersionName, appBuildNo, fileName,
String s = postFormData(token, appName, o2ServerProtocol, o2ServerHost, o2ServerPort, o2ServerContext, isPackAppIdOuter, urlMapping, appVersionName, appBuildNo, deleteHuawei, fileName,
bytes);
Type type = new TypeToken<AppPackResult<IdValue>>() {
}.getType();
......@@ -112,10 +112,10 @@ public class ActionAndroidPack extends BaseAction {
* @throws Exception
*/
private String postFormData(String token, String appName, String o2ServerProtocol, String o2ServerHost,
String o2ServerPort, String o2ServerContext, String isPackAppIdOuter, String urlMapping, String appVersionName, String appBuildNo,
String o2ServerPort, String o2ServerContext, String isPackAppIdOuter, String urlMapping, String appVersionName, String appBuildNo, String deleteHuawei,
String fileName, byte[] bytes) throws Exception {
logger.info("发起打包请求,form : " + token + " ," + appName + " ," + o2ServerProtocol + " ," + o2ServerHost + " ,"
+ o2ServerPort + " ," + o2ServerContext + " ," + isPackAppIdOuter + " ," + urlMapping +" ," + appVersionName +" ," + appBuildNo + " ," + fileName);
+ o2ServerPort + " ," + o2ServerContext + " ," + isPackAppIdOuter + " ," + urlMapping +" ," + appVersionName +" ," + appBuildNo + " ," + deleteHuawei + " ," + fileName);
String boundary = "abcdefghijk";
String end = "\r\n";
String twoHyphens = "--";
......@@ -158,6 +158,7 @@ public class ActionAndroidPack extends BaseAction {
writeFormProperties("urlMapping", urlMapping, boundary, end, twoHyphens, ds);
writeFormProperties("appVersionName", appVersionName, boundary, end, twoHyphens, ds);
writeFormProperties("appBuildNo", appBuildNo, boundary, end, twoHyphens, ds);
writeFormProperties("deleteHuawei", deleteHuawei, boundary, end, twoHyphens, ds);
writeFormProperties("collectName", Config.collect().getName(), boundary, end, twoHyphens, ds);
// file
ds.writeBytes(twoHyphens + boundary + end);
......
......@@ -125,10 +125,32 @@ public class ActionPackInfo extends BaseAction {
// 代理地址
private String urlMapping;
//错误信息
private String packErrorLogs;
// 2 表示要删除华为推送包,防止不是华为手机打开app需要安装HMS服务框架
private String deleteHuawei;
private AppPackApkFile appFile; // 关联的下载文件
public String getPackErrorLogs() {
return packErrorLogs;
}
public void setPackErrorLogs(String packErrorLogs) {
this.packErrorLogs = packErrorLogs;
}
public String getDeleteHuawei() {
return deleteHuawei;
}
public void setDeleteHuawei(String deleteHuawei) {
this.deleteHuawei = deleteHuawei;
}
public String getUrlMapping() {
return urlMapping;
}
......
......@@ -82,6 +82,7 @@ public class AppPackAction extends BaseAction {
@JaxrsParameterDescribe("o2ServerPort") @FormDataParam("o2ServerPort") String o2ServerPort,
@JaxrsParameterDescribe("o2ServerContext") @FormDataParam("o2ServerContext") String o2ServerContext,
@JaxrsParameterDescribe("isPackAppIdOuter") @FormDataParam("isPackAppIdOuter") String isPackAppIdOuter,
@JaxrsParameterDescribe("是否删除华为HMS") @FormDataParam("deleteHuawei") String deleteHuawei,
@JaxrsParameterDescribe("urlMapping") @FormDataParam("urlMapping") String urlMapping,
@JaxrsParameterDescribe("版本名称") @FormDataParam("appVersionName") String appVersionName,
@JaxrsParameterDescribe("版本编号") @FormDataParam("appBuildNo") String appBuildNo,
......@@ -91,7 +92,7 @@ public class AppPackAction extends BaseAction {
ActionResult<ActionAndroidPack.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionAndroidPack().execute(token, appName, o2ServerProtocol, o2ServerHost, o2ServerPort, o2ServerContext, isPackAppIdOuter, urlMapping, appVersionName, appBuildNo, fileName, bytes, disposition);
result = new ActionAndroidPack().execute(token, appName, o2ServerProtocol, o2ServerHost, o2ServerPort, o2ServerContext, isPackAppIdOuter, urlMapping, appVersionName, appBuildNo, deleteHuawei, fileName, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
......
......@@ -85,6 +85,18 @@
<p class="pack-form-tips">{{$.lp.mobile_apppack_form_appBuildNo_tip}}</p>
</div>
</div>
<div class="pack-form-group">
<label class="pack-form-label">{{$.lp.mobile_apppack_form_urlMapping}}</label>
<div class="pack-form-controls">
<span class="pack-form-box">
<input class="pack-form-input" type="text" data-o2-element="apppackUrlMappingInputNode"/>
</span>
<p class="pack-form-tips">{{$.lp.mobile_apppack_form_urlMapping_tip}}</p>
</div>
</div>
<div class="pack-form-group">
<label class="pack-form-label">{{$.lp.mobile_apppack_form_enable_outer_package}}</label>
<div class="pack-form-controls">
......@@ -96,12 +108,12 @@
</div>
<div class="pack-form-group">
<label class="pack-form-label">{{$.lp.mobile_apppack_form_urlMapping}}</label>
<label class="pack-form-label">{{$.lp.mobile_apppack_form_enable_delete_hms}}</label>
<div class="pack-form-controls">
<span class="pack-form-box">
<input class="pack-form-input" type="text" data-o2-element="apppackUrlMappingInputNode"/>
<input type="checkbox" data-o2-element="apppackIsDeleteHmsInputNode"/>
</span>
<p class="pack-form-tips">{{$.lp.mobile_apppack_form_urlMapping_tip}}</p>
<p class="pack-form-tips">{{$.lp.mobile_apppack_form_enable_delete_hms_tips}}</p>
</div>
</div>
......@@ -181,6 +193,15 @@
</span>
</div>
</div>
<div class="pack-form-group">
<label class="pack-form-label">{{$.lp.mobile_apppack_form_urlMapping}}</label>
<div class="pack-form-controls">
<span class="pack-form-box" data-o2-element="apppackUrlMappingShowNode">
</span>
</div>
</div>
<!-- 外部包名 -->
<div class="pack-form-group">
<label class="pack-form-label">{{$.lp.mobile_apppack_form_enable_outer_package}}</label>
<div class="pack-form-controls">
......@@ -188,10 +209,11 @@
</span>
</div>
</div>
<!-- 是否删除华为HMS -->
<div class="pack-form-group">
<label class="pack-form-label">{{$.lp.mobile_apppack_form_urlMapping}}</label>
<label class="pack-form-label">{{$.lp.mobile_apppack_form_enable_delete_hms}}</label>
<div class="pack-form-controls">
<span class="pack-form-box" data-o2-element="apppackUrlMappingShowNode">
<span class="pack-form-box" data-o2-element="apppackIsDeleteHmsShowNode">
</span>
</div>
</div>
......
......@@ -229,6 +229,11 @@ MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
isPackAppIdOuter = this.lp.mobile_apppack_form_enable_outer_status_yes;
}
this.apppackIsPackAppIdOuterShowNode.set("text", isPackAppIdOuter);
var deleteHms = this.lp.mobile_apppack_form_enable_delete_hms_status_no;
if (this.packInfo.deleteHuawei && this.packInfo.deleteHuawei === "2") {
deleteHms = this.lp.mobile_apppack_form_enable_delete_hms_status_yes;
}
this.apppackIsDeleteHmsShowNode.set("text", deleteHms);
this.apppackLogoShowImgNode.set("src", this.packServerUrl + this.packInfo.appLogoPath + "?token=" + this.token);
var status = ""
if (this.packInfo.packStatus === "0") {
......@@ -389,14 +394,19 @@ MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
this.apppackPortInputNode.set("value", this.packInfo.o2ServerPort);
this.apppackContextInputNode.set("value", this.packInfo.o2ServerContext);
this.apppackAppNameInputNode.set("value", this.packInfo.appName);
this.apppackAppVersionNameInputNode.set("value", this.packInfo.versionName);
this.apppackAppBuildNoInputNode.set("value", this.packInfo.buildNo);
this.apppackAppVersionNameInputNode.set("value", ""); // 重新填写 版本号清空
this.apppackAppBuildNoInputNode.set("value", ""); // 重新填写 版本号清空
this.apppackUrlMappingInputNode.set("value", this.packInfo.urlMapping);
var isPackAppIdOuter = false;
if (this.packInfo.isPackAppIdOuter && this.packInfo.isPackAppIdOuter === "2") {
isPackAppIdOuter = true;
}
this.apppackIsPackAppIdOuterInputNode.set("checked", isPackAppIdOuter);
var deleteHms = false;
if (this.packInfo.deleteHuawei && this.packInfo.deleteHuawei === "2") {
deleteHms = true;
}
this.apppackIsDeleteHmsInputNode.set("checked", deleteHms);
}
this.showForm();
},
......@@ -500,6 +510,7 @@ MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
var appVersionName = this.apppackAppVersionNameInputNode.get("value");
var appBuildNo = this.apppackAppBuildNoInputNode.get("value");
var isPackAppIdOuter = this.apppackIsPackAppIdOuterInputNode.checked ? "2" : "1";
var deleteHms = this.apppackIsDeleteHmsInputNode.checked ? "2" : "1";
var urlMapping = this.apppackUrlMappingInputNode.get("value");
this.confirm(this.lp.alert, this.lp.mobile_apppack_message_alert_submit, function() {
this.showLoading();
......@@ -514,6 +525,7 @@ MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
formData.append('appVersionName', appVersionName);
formData.append('appBuildNo', appBuildNo);
formData.append('isPackAppIdOuter', isPackAppIdOuter);
formData.append('deleteHuawei', deleteHms);
formData.append('urlMapping', urlMapping);
formData.append('token', this.token);
......
......@@ -285,7 +285,11 @@ MWF.xApplication.Setting.LP = {
"mobile_apppack_form_enable_outer_status_no": "Not Enabled",
"mobile_apppack_form_enable_outer_status_yes": "Enabled",
"mobile_apppack_form_enable_outer_package": "Enable external package name",
"mobile_apppack_form_enable_delete_hms": "Enable Delete HMS",
"mobile_apppack_form_enable_outer_tips": "Enabling external package names can prevent conflicts and overwrites with officially released apps",
"mobile_apppack_form_enable_delete_hms_status_no": "No",
"mobile_apppack_form_enable_delete_hms_status_yes": "Yes",
"mobile_apppack_form_enable_delete_hms_tips": "Enabling external package names can prevent conflicts and overwrites with officially released apps",
"mobile_apppack_form_download_publish_btn": "Download and publish to local",
"mobile_apppack_message_confirm_publish": "The app has been packaged. Download it and publish it to the local server immediately. You can scan the code and install it directly!",
"mobile_apppack_publish_status_doing": "In release ...",
......
......@@ -286,7 +286,11 @@ MWF.xApplication.Setting.LP = {
"mobile_apppack_form_enable_outer_status_no": "未启用",
"mobile_apppack_form_enable_outer_status_yes": "已启用",
"mobile_apppack_form_enable_outer_package": "是否启用外部包名",
"mobile_apppack_form_enable_delete_hms": "是否删除HMS",
"mobile_apppack_form_enable_outer_tips": "启用外部包名可以防止和官方发布的APP冲突覆盖",
"mobile_apppack_form_enable_delete_hms_tips": "删除HMS无法使用华为推送,请谨慎操作",
"mobile_apppack_form_enable_delete_hms_status_no": "",
"mobile_apppack_form_enable_delete_hms_status_yes": "",
"mobile_apppack_form_download_publish_btn": "下载发布到本地",
"mobile_apppack_message_confirm_publish": "app已经打包完成,马上下载发布到本地服务器就可以直接扫码安装!",
"mobile_apppack_publish_status_doing": "发布中...",
......
......@@ -1666,7 +1666,6 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class(
} else {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('dingtalk') >= 0) {
this.addMessage("dingtalk");
this.form.workAction.getAttachmentUrl(att.data.id, this.form.businessData.work.id, function (url) {
var xtoken = Cookie.read(o2.tokenName);
window.location = o2.filterUrl(url + "?"+o2.tokenName+"=" + xtoken);
......@@ -1700,7 +1699,6 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class(
} else {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('dingtalk') >= 0) {
this.addMessage("dingtalk");
this.form.workAction.getAttachmentWorkcompletedUrl(att.data.id, this.form.businessData.workCompleted.id, function (url) {
var xtoken = Cookie.read(o2.tokenName);
window.location = o2.filterUrl(url + "?"+o2.tokenName+"=" + xtoken);
......@@ -1738,7 +1736,6 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class(
// 钉钉客户端
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('dingtalk') >= 0) {
this.addMessage("dingtalk");
this.form.workAction.getAttachmentUrl(att.data.id, this.form.businessData.work.id, function (url) {
var xtoken = Cookie.read(o2.tokenName);
window.location = o2.filterUrl(url + "?"+o2.tokenName+"=" + xtoken);
......@@ -1774,7 +1771,6 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class(
// 钉钉客户端
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('dingtalk') >= 0) {
this.addMessage("dingtalk");
this.form.workAction.getAttachmentWorkcompletedUrl(att.data.id, ((this.form.businessData.workCompleted) ? this.form.businessData.workCompleted.id : this.form.businessData.work.id), function (url) {
var xtoken = Cookie.read(o2.tokenName);
window.location = o2.filterUrl(url + "?"+o2.tokenName+"=" + xtoken);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册