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

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

parent 3fb7c06e
...@@ -23,100 +23,111 @@ import org.springframework.util.Assert; ...@@ -23,100 +23,111 @@ import org.springframework.util.Assert;
@Component @Component
public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallRest { public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallRest {
@Resource @Resource
private AgentApplicationMallService agentApplicationMallService; private AgentApplicationMallService agentApplicationMallService;
@Resource @Resource
private BizMemberAgentApplicationCollectService bizMemberAgentApplicationCollectService; private BizMemberAgentApplicationCollectService bizMemberAgentApplicationCollectService;
@Resource @Resource
private BizAgentApplicationPublishService bizAgentApplicationPublishService; private BizAgentApplicationPublishService bizAgentApplicationPublishService;
@Resource @Resource
private BizAgentApplicationMallService bizAgentApplicationMallService; private BizAgentApplicationMallService bizAgentApplicationMallService;
@Override @Override
public void publishAgentToMall(BizAgentApplicationMallDto dto) throws Exception { public void publishAgentToMall(BizAgentApplicationMallDto dto) throws Exception {
Assert.notNull(dto); Assert.notNull(dto);
Assert.notNull(dto.getAgentPublishId()); Assert.notNull(dto.getAgentPublishId());
Assert.notNull(dto.getAgentType()); Assert.notNull(dto.getAgentType());
Assert.notNull(dto.getIsCopy()); Assert.notNull(dto.getIsCopy());
BizAgentApplicationPublishEntity publishEntity = bizAgentApplicationPublishService.get(dto.getAgentPublishId()); BizAgentApplicationPublishEntity publishEntity = bizAgentApplicationPublishService.get(dto.getAgentPublishId());
if(publishEntity == null){ if (publishEntity == null) {
throw new BusinessException("应用未发布"); throw new BusinessException("应用未发布");
} }
dto.setIsSale(CommonConstant.IsDeleted.Y); dto.setIsSale(CommonConstant.IsDeleted.Y);
// 判断当前应用之前是否上架了 // 判断当前应用之前是否上架了
BizAgentApplicationMallEntity mallEntity = bizAgentApplicationMallService.getByAgentPublishId(dto.getAgentPublishId()); BizAgentApplicationMallEntity mallEntity = bizAgentApplicationMallService.getByAgentPublishId(dto.getAgentPublishId());
if(mallEntity != null){
mallEntity.setIsSale(CommonConstant.IsDeleted.Y);
mallEntity.setAgentType(dto.getAgentType()); // 查询当前应用的收藏情况
mallEntity.setIsCopy(dto.getIsCopy()); BizMemberAgentApplicationCollectEntity collectEntity = new BizMemberAgentApplicationCollectEntity();
// 如果上架过,则update操作 collectEntity.setAgentId(publishEntity.getAgentId());
bizAgentApplicationMallService.update(mallEntity); collectEntity.setIsCollect(CommonConstant.YOrN.Y);
}else{ collectEntity.setIsDeleted(CommonConstant.IsDeleted.N);
// 如果没上架过,则save操作 List<BizMemberAgentApplicationCollectEntity> collectEntities = bizMemberAgentApplicationCollectService.findByExample(collectEntity, null);
// 把应用存入应用市场表中
bizAgentApplicationMallService.save(BizAgentApplicationMallConvert.dtoToEntity(dto)); if (mallEntity != null) {
} mallEntity.setIsSale(CommonConstant.IsDeleted.Y);
} mallEntity.setAgentType(dto.getAgentType());
mallEntity.setIsCopy(dto.getIsCopy());
public BizAgentApplicationMallDto getById(java.lang.Integer id) throws Exception{ mallEntity.setCollectNumber(collectEntities.size());
Assert.notNull(id); // 如果上架过,则update操作
return BizAgentApplicationMallConvert.entityToDto(bizAgentApplicationMallService.get(id)); bizAgentApplicationMallService.update(mallEntity);
} } else {
// 如果没上架过,则save操作
@Override // 把应用存入应用市场表中
public List<BizAgentApplicationMallDto> getListByExample(BizAgentApplicationMallDto example, PagingInfo pagingInfo) throws Exception { mallEntity.setCollectNumber(collectEntities.size());
return null; bizAgentApplicationMallService.save(BizAgentApplicationMallConvert.dtoToEntity(dto));
} }
}
public List<BizAgentApplicationMallDto> getList(PagingInfo pagingInfo) throws Exception{
List<BizAgentApplicationMallDto> resultList = new ArrayList<>(); public BizAgentApplicationMallDto getById(java.lang.Integer id) throws Exception {
List<BizAgentApplicationMallEntity> byExample = bizAgentApplicationMallService.findByExample(pagingInfo); Assert.notNull(id);
for(BizAgentApplicationMallEntity entity : byExample){ return BizAgentApplicationMallConvert.entityToDto(bizAgentApplicationMallService.get(id));
BizAgentApplicationMallDto mallDto = BizAgentApplicationMallConvert.entityToDto(entity); }
// 如果应用上架了
if(CommonConstant.IsDeleted.Y.equals(mallDto.getIsSale())){ @Override
// 设置当前用户是否收藏了 public List<BizAgentApplicationMallDto> getListByExample(BizAgentApplicationMallDto example, PagingInfo pagingInfo) throws Exception {
if(mallDto.getBaseInfo() != null){ return null;
BizMemberAgentApplicationCollectEntity collect = bizMemberAgentApplicationCollectService.getByAgentId(mallDto.getBaseInfo().getAgentId()); }
if(collect != null){
mallDto.setIsCollect(collect.getIsCollect()); public List<BizAgentApplicationMallDto> getList(PagingInfo pagingInfo) throws Exception {
}else { List<BizAgentApplicationMallDto> resultList = new ArrayList<>();
mallDto.setIsCollect(CommonConstant.IsDeleted.N); List<BizAgentApplicationMallEntity> byExample = bizAgentApplicationMallService.findByExample(pagingInfo);
} for (BizAgentApplicationMallEntity entity : byExample) {
} BizAgentApplicationMallDto mallDto = BizAgentApplicationMallConvert.entityToDto(entity);
resultList.add(mallDto); // 如果应用上架了
} if (CommonConstant.IsDeleted.Y.equals(mallDto.getIsSale())) {
} // 设置当前用户是否收藏了
return resultList; if (mallDto.getBaseInfo() != null) {
} BizMemberAgentApplicationCollectEntity collect = bizMemberAgentApplicationCollectService.getByAgentId(mallDto.getBaseInfo().getAgentId());
if (collect != null) {
public BizAgentApplicationMallDto update(BizAgentApplicationMallDto dto) throws Exception{ mallDto.setIsCollect(collect.getIsCollect());
Assert.notNull(dto); } else {
BizAgentApplicationMallEntity entity = BizAgentApplicationMallConvert.dtoToEntity(dto); mallDto.setIsCollect(CommonConstant.IsDeleted.N);
return BizAgentApplicationMallConvert.entityToDto(bizAgentApplicationMallService.update(entity)); }
} }
resultList.add(mallDto);
public void deletedById(java.lang.Integer id) throws Exception{ }
Assert.notNull(id); }
bizAgentApplicationMallService.deletedById(id); return resultList;
} }
@Override public BizAgentApplicationMallDto update(BizAgentApplicationMallDto dto) throws Exception {
public void collectOrCancelAgentInMall(Integer id) throws Exception { Assert.notNull(dto);
Assert.notNull(id); BizAgentApplicationMallEntity entity = BizAgentApplicationMallConvert.dtoToEntity(dto);
agentApplicationMallService.collectOrCancelAgentInMall(id); return BizAgentApplicationMallConvert.entityToDto(bizAgentApplicationMallService.update(entity));
} }
@Override public void deletedById(java.lang.Integer id) throws Exception {
public void unSaleAgentInMall(Integer agentPublishId) throws Exception { Assert.notNull(id);
Assert.notNull(agentPublishId); bizAgentApplicationMallService.deletedById(id);
BizAgentApplicationMallEntity mallEntity = bizAgentApplicationMallService.getByAgentPublishId(agentPublishId); }
mallEntity.setIsSale(CommonConstant.IsDeleted.N);
bizAgentApplicationMallService.update(mallEntity); @Override
} public void collectOrCancelAgentInMall(Integer id) throws Exception {
Assert.notNull(id);
agentApplicationMallService.collectOrCancelAgentInMall(id);
}
@Override
public void unSaleAgentInMall(Integer agentPublishId) throws Exception {
Assert.notNull(agentPublishId);
BizAgentApplicationMallEntity mallEntity = bizAgentApplicationMallService.getByAgentPublishId(agentPublishId);
mallEntity.setIsSale(CommonConstant.IsDeleted.N);
bizAgentApplicationMallService.update(mallEntity);
}
} }
\ No newline at end of file
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