Commit 76775986 authored by 赵啸非's avatar 赵啸非

修改应用版本更新

parent 06a78601
...@@ -390,6 +390,8 @@ public class AppServiceImpl extends AbstractCRUDCacheServiceImpl<AppDao, AppEnti ...@@ -390,6 +390,8 @@ public class AppServiceImpl extends AbstractCRUDCacheServiceImpl<AppDao, AppEnti
@Override @Override
public AppEntity update(AppEntity entity, Context context) throws AppException { public AppEntity update(AppEntity entity, Context context) throws AppException {
this.updateBefore(entity, context); this.updateBefore(entity, context);
AppEntity appEntity = this.get(entity.getId(), context);
String originFilePath = appEntity.getFilePath();
String filePath = entity.getFilePath(); String filePath = entity.getFilePath();
String fileName = entity.getFileName(); String fileName = entity.getFileName();
entity.setFilePath(null); entity.setFilePath(null);
...@@ -408,11 +410,42 @@ public class AppServiceImpl extends AbstractCRUDCacheServiceImpl<AppDao, AppEnti ...@@ -408,11 +410,42 @@ public class AppServiceImpl extends AbstractCRUDCacheServiceImpl<AppDao, AppEnti
entity.setFileName(fileName); entity.setFileName(fileName);
entity.setFilePath(filePath); entity.setFilePath(filePath);
this.updateAfter(entity, context); this.updateAfter(entity, context);
//判断只有附件地址不等时候,才更新版本
if (!ObjectUtils.isEmpty(originFilePath) && !originFilePath.equals(filePath)) {
AppVersionQuery appVersionQuery = new AppVersionQuery();
appVersionQuery.setAppId(entity.getId());
List<OrderCol> orderColList = new ArrayList<>();
orderColList.add(new OrderCol("version", OrderCol.DESCENDING));
appVersionQuery.setOrderColList(orderColList);
List<AppVersionEntity> appVersionEntities = appVersionService.find(appVersionQuery, context);
//获取最大版本号
if (!ObjectUtils.isEmpty(appVersionEntities)) {
AppVersionEntity curAppVersionEntity = appVersionEntities.get(0);
// String versionNum = StrUtil.subAfter(curAppVersionEntity.getVersion(), Constant.VERSION_PREFIX, false);
Integer versionNum = curAppVersionEntity.getVersion();
Integer newVersionNum = ++versionNum;
AppVersionEntity appVersionEntity = new AppVersionEntity();
appVersionEntity.initAttrValue();
AppVersionEntity versionEntity = new AppVersionEntity();
versionEntity.initAttrValue();
versionEntity.setAppId(entity.getId());
versionEntity.setAppName(entity.getAppName());
versionEntity.setVersion(newVersionNum);
versionEntity.setNotes(entity.getNotes());
versionEntity.setFileName(entity.getFileName());
versionEntity.setFilePath(entity.getFilePath());
versionEntity.setDistributeFilePath(entity.getDistributeFilePath());
versionEntity.setCreateTime(new Date());
versionEntity.setCreateUserId(this.getContextUserId(context));
appVersionService.save(versionEntity, context);
}
}
return entity; return entity;
} }
}
}
/*
@Override @Override
protected void updateAfter(AppEntity entity, Context context) throws AppException { protected void updateAfter(AppEntity entity, Context context) throws AppException {
...@@ -445,7 +478,7 @@ public class AppServiceImpl extends AbstractCRUDCacheServiceImpl<AppDao, AppEnti ...@@ -445,7 +478,7 @@ public class AppServiceImpl extends AbstractCRUDCacheServiceImpl<AppDao, AppEnti
} }
super.updateAfter(entity, context); super.updateAfter(entity, context);
} }*/
@Override @Override
protected void removeAfter(Long[] ids, Context context, int result) throws AppException { protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment