public void saveAppDiff(AppDiff entity) { if (StringUtils.isEmpty(entity.getId())) { initEntity(entity); } // save apk if (entity.getDiffAttachment() != null && StringUtils.isNotEmpty(entity.getDiffAttachment().getFileName())) { try { String distPath = "/attachment/content/" + new SimpleDateFormat("yyyy/MM").format(new Date()); File distFile = new File(explodedPath + distPath); if (!distFile.exists()) { FileUtils.forceMkdir(distFile); } entity.setDiff( distPath + "/" + entity.getDiffAttachment().getTempFileName() + "." + FilenameUtils.getExtension(entity.getDiffAttachment().getFileName())); entity.setDiffFilename(entity.getDiffAttachment().getFileName()); FileUtils.copyFile( new File(tempPath + "/" + entity.getDiffAttachment().getTempFileName()), new File(explodedPath + entity.getDiff())); } catch (IOException e) { e.printStackTrace(); } } appDiffDao.save(entity); }
public JSONObject checkUpdate(String clientVersionName) { // 服务器上 app 最新版本号 String currentVersionName = getCurrentVersionName(); // 若客户端已经是最新版本,则不需要更新 if (currentVersionName.equals(clientVersionName)) { JSONObject result = new JSONObject(); result.put("needUpdate", false); return result; } // 获取对应的差分包地址 AppDiff appDiff = appDiffDao.findOneByVersionNameAndClientVersionNameAndDeleteFlag( currentVersionName, clientVersionName, 0); JSONObject result = new JSONObject(); result.put("needUpdate", true); result.put("diff", appDiff.getDiff()); String apkPath = explodedPath + File.separator + "app.apk"; File apk = new File(apkPath); String md5Sign = MD5Utils.getMd5ByFile(apk); result.put("md5Sign", md5Sign); return result; }
public void deleteAppDiff(String id) { AppDiff appDiff = getAppDiff(id); appDiff.setDeleteFlag(1); appDiffDao.save(appDiff); }
public Page<AppDiff> getAppDiff(Map<String, Object> searchParams, int pageNo, int pageSize) { PageRequest pageRequest = buildPageRequest(pageNo, pageSize); Specification<AppDiff> spec = buildSpecification(searchParams); return appDiffDao.findAll(spec, pageRequest); }
public AppDiff getAppDiff(String id) { return appDiffDao.findOne(id); }
private String getCurrentVersionName() { return appDiffDao.findVersionNameList().get(0); }