Commit 8a9b0f75 authored by alex yao's avatar alex yao

fix: 修复 Agent应用上架应用广场后,应用收藏计数。

parent 3fb7c06e
......@@ -44,26 +44,37 @@ public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallR
Assert.notNull(dto.getAgentType());
Assert.notNull(dto.getIsCopy());
BizAgentApplicationPublishEntity publishEntity = bizAgentApplicationPublishService.get(dto.getAgentPublishId());
if(publishEntity == null){
if (publishEntity == null) {
throw new BusinessException("应用未发布");
}
dto.setIsSale(CommonConstant.IsDeleted.Y);
// 判断当前应用之前是否上架了
BizAgentApplicationMallEntity mallEntity = bizAgentApplicationMallService.getByAgentPublishId(dto.getAgentPublishId());
if(mallEntity != null){
// 查询当前应用的收藏情况
BizMemberAgentApplicationCollectEntity collectEntity = new BizMemberAgentApplicationCollectEntity();
collectEntity.setAgentId(publishEntity.getAgentId());
collectEntity.setIsCollect(CommonConstant.YOrN.Y);
collectEntity.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizMemberAgentApplicationCollectEntity> collectEntities = bizMemberAgentApplicationCollectService.findByExample(collectEntity, null);
if (mallEntity != null) {
mallEntity.setIsSale(CommonConstant.IsDeleted.Y);
mallEntity.setAgentType(dto.getAgentType());
mallEntity.setIsCopy(dto.getIsCopy());
mallEntity.setCollectNumber(collectEntities.size());
// 如果上架过,则update操作
bizAgentApplicationMallService.update(mallEntity);
}else{
} else {
// 如果没上架过,则save操作
// 把应用存入应用市场表中
mallEntity.setCollectNumber(collectEntities.size());
bizAgentApplicationMallService.save(BizAgentApplicationMallConvert.dtoToEntity(dto));
}
}
public BizAgentApplicationMallDto getById(java.lang.Integer id) throws Exception{
public BizAgentApplicationMallDto getById(java.lang.Integer id) throws Exception {
Assert.notNull(id);
return BizAgentApplicationMallConvert.entityToDto(bizAgentApplicationMallService.get(id));
}
......@@ -73,19 +84,19 @@ public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallR
return null;
}
public List<BizAgentApplicationMallDto> getList(PagingInfo pagingInfo) throws Exception{
public List<BizAgentApplicationMallDto> getList(PagingInfo pagingInfo) throws Exception {
List<BizAgentApplicationMallDto> resultList = new ArrayList<>();
List<BizAgentApplicationMallEntity> byExample = bizAgentApplicationMallService.findByExample(pagingInfo);
for(BizAgentApplicationMallEntity entity : byExample){
for (BizAgentApplicationMallEntity entity : byExample) {
BizAgentApplicationMallDto mallDto = BizAgentApplicationMallConvert.entityToDto(entity);
// 如果应用上架了
if(CommonConstant.IsDeleted.Y.equals(mallDto.getIsSale())){
if (CommonConstant.IsDeleted.Y.equals(mallDto.getIsSale())) {
// 设置当前用户是否收藏了
if(mallDto.getBaseInfo() != null){
if (mallDto.getBaseInfo() != null) {
BizMemberAgentApplicationCollectEntity collect = bizMemberAgentApplicationCollectService.getByAgentId(mallDto.getBaseInfo().getAgentId());
if(collect != null){
if (collect != null) {
mallDto.setIsCollect(collect.getIsCollect());
}else {
} else {
mallDto.setIsCollect(CommonConstant.IsDeleted.N);
}
}
......@@ -95,13 +106,13 @@ public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallR
return resultList;
}
public BizAgentApplicationMallDto update(BizAgentApplicationMallDto dto) throws Exception{
public BizAgentApplicationMallDto update(BizAgentApplicationMallDto dto) throws Exception {
Assert.notNull(dto);
BizAgentApplicationMallEntity entity = BizAgentApplicationMallConvert.dtoToEntity(dto);
return BizAgentApplicationMallConvert.entityToDto(bizAgentApplicationMallService.update(entity));
}
public void deletedById(java.lang.Integer id) throws Exception{
public void deletedById(java.lang.Integer id) throws Exception {
Assert.notNull(id);
bizAgentApplicationMallService.deletedById(id);
}
......
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