mirror of
https://gitee.com/shuto-github/intranet_app_manager.git
synced 2026-05-27 00:00:14 +08:00
添加设备列表
This commit is contained in:
@@ -48,6 +48,19 @@ public class PackageController {
|
||||
return "install";
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备列表
|
||||
* @param id
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/devices/{id}")
|
||||
public String devices(@PathVariable("id") String id, HttpServletRequest request) {
|
||||
PackageViewModel viewModel= this.packageService.findById(id);
|
||||
request.setAttribute("app", viewModel);
|
||||
return "devices";
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传包
|
||||
* @param file
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.yzr.model;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.yzr.model;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.ManyToAny;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@@ -41,5 +39,9 @@ public class Package {
|
||||
@ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name="appId")
|
||||
private App app;
|
||||
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
// Provision 文件
|
||||
@JoinColumn(name = "provisionId",referencedColumnName = "id")
|
||||
private Provision provision;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.yzr.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="tb_provision")
|
||||
@Setter
|
||||
@Getter
|
||||
public class Provision {
|
||||
// 主键
|
||||
@Id
|
||||
@GeneratedValue(generator = "system-uuid")
|
||||
@GenericGenerator(name = "system-uuid", strategy = "uuid")
|
||||
@Column(length = 32)
|
||||
private String id;
|
||||
private String teamName;
|
||||
private String teamID;
|
||||
private Date createDate;
|
||||
private Date expirationDate;
|
||||
private String UUID;
|
||||
@Column(length = 80000)
|
||||
private String[] devices;
|
||||
private int deviceCount;
|
||||
private String type;
|
||||
private boolean isEnterprise;
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.yzr.utils.ipa;
|
||||
|
||||
import com.dd.plist.NSArray;
|
||||
import com.dd.plist.NSDictionary;
|
||||
import com.dd.plist.NSObject;
|
||||
import com.dd.plist.PropertyListParser;
|
||||
import com.dd.plist.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -81,18 +78,26 @@ public class Plist {
|
||||
}
|
||||
|
||||
public List<String> arrayValueForPath(String path) {
|
||||
List<String> devices = new ArrayList<>();
|
||||
Object object = valueForKeyPath(path);
|
||||
if (object != null) {
|
||||
NSArray deviceArray = (NSArray)object;
|
||||
List<String> devices = new ArrayList<>();
|
||||
if (deviceArray != null && deviceArray.count() > 0) {
|
||||
for (int i = 0; i < deviceArray.count(); i++) {
|
||||
devices.add(deviceArray.objectAtIndex(i).toString());
|
||||
}
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
return null;
|
||||
return devices;
|
||||
}
|
||||
|
||||
public boolean boolValueForPath(String keyPath) {
|
||||
Object object = valueForKeyPath(keyPath);
|
||||
if (object instanceof NSNumber) {
|
||||
NSNumber number = (NSNumber)object;
|
||||
return number.boolValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package org.yzr.utils.ipa;
|
||||
|
||||
import com.dd.plist.NSDate;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public class Provision {
|
||||
private String teamName;
|
||||
private String teamID;
|
||||
private Date createDate;
|
||||
private Date expirationDate;
|
||||
private String UUID;
|
||||
private List<String> devices;
|
||||
private int deviceCount;
|
||||
private String type;
|
||||
|
||||
public Provision(String appPath) {
|
||||
String profile = appPath + File.separator + "embedded.mobileprovision";
|
||||
try {
|
||||
boolean started = false;
|
||||
boolean ended = false;
|
||||
BufferedReader reader = new BufferedReader(new FileReader(profile));
|
||||
StringBuffer plist = new StringBuffer();
|
||||
String str = null;
|
||||
while ((str = reader.readLine()) != null) {
|
||||
if (str.contains("</plist>")) {
|
||||
ended = true;
|
||||
plist.append("</plist>").append("\n");
|
||||
} else if (started && !ended) {
|
||||
plist.append(str).append("\n");
|
||||
} else if (str.contains("<?xml")) {
|
||||
started = true;
|
||||
plist.append(str.substring(str.indexOf("<?xml"))).append("\n");
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
Plist provisionFile = Plist.parseWithString(plist.toString());
|
||||
this.devices = provisionFile.arrayValueForPath("ProvisionedDevices");
|
||||
this.deviceCount = this.devices.size();
|
||||
this.teamName = provisionFile.stringValueForPath("TeamName");
|
||||
this.teamID = provisionFile.arrayValueForPath("TeamIdentifier").get(0);
|
||||
this.createDate = ((NSDate)provisionFile.valueForKeyPath("CreationDate")).getDate();
|
||||
this.expirationDate = ((NSDate)provisionFile.valueForKeyPath("ExpirationDate")).getDate();
|
||||
this.UUID = provisionFile.stringValueForPath("UUID");
|
||||
this.type = this.deviceCount > 0 ? "Ad-hoc" : "Release";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,19 @@
|
||||
package org.yzr.utils.parser;
|
||||
|
||||
import com.dd.plist.NSDate;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.yzr.model.Package;
|
||||
import org.yzr.utils.PNGConverter;
|
||||
import org.yzr.utils.PathManager;
|
||||
import org.yzr.utils.ZipUtils;
|
||||
import org.yzr.utils.ipa.Plist;
|
||||
import org.yzr.utils.ipa.Provision;
|
||||
import org.yzr.model.Provision;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class IPAParser implements PackageParser {
|
||||
@@ -49,7 +51,7 @@ public class IPAParser implements PackageParser {
|
||||
PNGConverter.convert(iconPath, iconTempPath);
|
||||
|
||||
// 解析 Provision
|
||||
Provision provision = new Provision(appPath);
|
||||
aPackage.setProvision(getProvision(appPath));
|
||||
|
||||
// 清除目录
|
||||
FileUtils.deleteDirectory(new File(targetPath));
|
||||
@@ -100,4 +102,44 @@ public class IPAParser implements PackageParser {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Provision getProvision(String appPath) {
|
||||
Provision provision = new Provision();
|
||||
String profile = appPath + File.separator + "embedded.mobileprovision";
|
||||
try {
|
||||
boolean started = false;
|
||||
boolean ended = false;
|
||||
BufferedReader reader = new BufferedReader(new FileReader(profile));
|
||||
StringBuffer plist = new StringBuffer();
|
||||
String str = null;
|
||||
while ((str = reader.readLine()) != null) {
|
||||
if (str.contains("</plist>")) {
|
||||
ended = true;
|
||||
plist.append("</plist>").append("\n");
|
||||
} else if (started && !ended) {
|
||||
plist.append(str).append("\n");
|
||||
} else if (str.contains("<?xml")) {
|
||||
started = true;
|
||||
plist.append(str.substring(str.indexOf("<?xml"))).append("\n");
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
Plist provisionFile = Plist.parseWithString(plist.toString());
|
||||
provision.setEnterprise(provisionFile.boolValueForPath("ProvisionsAllDevices"));
|
||||
List<String> provisionedDevices = provisionFile.arrayValueForPath("ProvisionedDevices");
|
||||
String[] devices = new String[provisionedDevices.size()];
|
||||
devices = provisionedDevices.toArray(devices);
|
||||
provision.setDevices(devices);
|
||||
provision.setDeviceCount(devices.length);
|
||||
provision.setTeamName(provisionFile.stringValueForPath("TeamName"));
|
||||
provision.setTeamID(provisionFile.arrayValueForPath("TeamIdentifier").get(0));
|
||||
provision.setCreateDate(((NSDate)provisionFile.valueForKeyPath("CreationDate")).getDate());
|
||||
provision.setExpirationDate(((NSDate)provisionFile.valueForKeyPath("ExpirationDate")).getDate());
|
||||
provision.setUUID(provisionFile.stringValueForPath("UUID"));
|
||||
provision.setType(provision.getDeviceCount() > 0 ? "AdHoc" : "Release");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return provision;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,10 @@ import org.yzr.model.Package;
|
||||
import org.yzr.utils.PathManager;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Getter
|
||||
@@ -25,6 +28,9 @@ public class PackageViewModel {
|
||||
private String displaySize;
|
||||
private String displayTime;
|
||||
private boolean iOS;
|
||||
private String type;
|
||||
private List<String> devices;
|
||||
private int deviceCount;
|
||||
|
||||
public PackageViewModel(Package aPackage, PathManager pathManager) {
|
||||
this.downloadURL = pathManager.getBaseURL(false) + "p/" + aPackage.getId();
|
||||
@@ -51,6 +57,27 @@ public class PackageViewModel {
|
||||
this.installURL = pathManager.getPackageResourceURL(aPackage, false) + aPackage.getFileName();
|
||||
}
|
||||
this.previewURL = pathManager.getBaseURL(false) + "s/" + aPackage.getApp().getShortCode() + "?id=" + aPackage.getId();
|
||||
if (this.isIOS()) {
|
||||
if (aPackage.getProvision() == null) {
|
||||
this.type = "内测版";
|
||||
} else {
|
||||
if (aPackage.getProvision().isEnterprise()) {
|
||||
this.type = "企业版";
|
||||
} else {
|
||||
if ("AdHoc".equalsIgnoreCase(aPackage.getProvision().getType())) {
|
||||
this.type = "内测版";
|
||||
} else {
|
||||
this.type = "商店版";
|
||||
}
|
||||
this.deviceCount = aPackage.getProvision().getDeviceCount();
|
||||
if (aPackage.getProvision().getDeviceCount() > 0) {
|
||||
this.devices = Arrays.asList(aPackage.getProvision().getDevices());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.type = "内测版";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,4 +41,4 @@ server.ssl.key-alias=1
|
||||
server.port=443
|
||||
server.http.port=80
|
||||
config.debug=debug
|
||||
server.domain=192.168.0.108
|
||||
server.domain=127.0.0.1
|
||||
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="x-ua-compatible" content="IE=edge">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta name="viewport"
|
||||
content="minimal-ui,width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
|
||||
|
||||
<title>-设备列表</title>
|
||||
<link rel="icon" type="image/x-icon" th:href="@{/images/favicon.ico}" />
|
||||
<link rel="stylesheet" th:href="@{/css/bootstrap.css}">
|
||||
</head>
|
||||
<body>
|
||||
<div class="card container">
|
||||
<div class="list-group text-center">
|
||||
<a href="#" class="list-group-item active">
|
||||
<h4 class="list-group-item-heading">
|
||||
设备ID
|
||||
</h4>
|
||||
</a>
|
||||
<a class="list-group-item" href="#" th:each="device,appStat : ${app.devices}">
|
||||
[[${device}]]
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -42,7 +42,7 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p class="release-type wrapper">内测版</p>
|
||||
<p class="release-type wrapper">[[${app.currentPackage.type}]]</p>
|
||||
|
||||
<h1 class="name wrapper">
|
||||
<span class="icon-warp">
|
||||
@@ -54,7 +54,7 @@
|
||||
<p class="scan-tips">扫描二维码下载<br>或用手机浏览器输入这个网址: <span
|
||||
class="text-black">[[${app.installPath}]]</span></p>
|
||||
<div class="release-info">
|
||||
<p>内测版 -
|
||||
<p>[[${app.currentPackage.type}]] -
|
||||
<span itemprop="softwareVersion">[[${app.version}]] (Build [[${app.buildVersion}]]) -
|
||||
[[${app.currentPackage.displaySize}]]</span></p>
|
||||
<p>更新于: <span itemprop="datePublished">[[${app.currentPackage.displayTime}]]</span></p>
|
||||
@@ -69,6 +69,10 @@
|
||||
<div class="action-animate-text" id="installCRT">安装证书</div>
|
||||
<div class="action-animate-active"></div>
|
||||
</div>
|
||||
<div class="action-animate" th:if="${app.currentPackage.deviceCount > 0}">
|
||||
<a th:href="'/devices/' + ${app.currentPackage.id}" class="action-animate-text ng-binding" target="_blank">查看设备列表</a>
|
||||
<div class="action-animate-active"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
<small>
|
||||
<i class="icon-calendar"></i>
|
||||
<span class="ng-binding">[[${app.displayTime}]]</span></small> ·
|
||||
<small class="ng-scope">内测版</small>
|
||||
<small class="ng-scope">[[${app.type}]]</small>
|
||||
<i class="ng-hide"> · </i>
|
||||
<small class="ng-binding ng-hide"></small>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user