use of com.actionworks.flashsale.domain.model.entity.FlashActivity in project flash-sale by ThoughtsBeta.
the class FlashActivityDomainServiceImpl method onlineActivity.
@Override
public void onlineActivity(Long userId, Long activityId) {
logger.info("activityOnline|上线秒杀活动|{},{}", userId, activityId);
if (StringUtils.isEmpty(userId) || activityId == null) {
throw new DomainException(PARAMS_INVALID);
}
Optional<FlashActivity> flashActivityOptional = flashActivityRepository.findById(activityId);
if (!flashActivityOptional.isPresent()) {
throw new DomainException(FLASH_ACTIVITY_DOES_NOT_EXIST);
}
FlashActivity flashActivity = flashActivityOptional.get();
if (FlashActivityStatus.isOnline(flashActivity.getStatus())) {
return;
}
flashActivity.setStatus(FlashActivityStatus.ONLINE.getCode());
flashActivityRepository.save(flashActivity);
logger.info("activityOnline|活动已上线|{},{}", userId, flashActivity.getId());
FlashActivityEvent flashActivityEvent = new FlashActivityEvent();
flashActivityEvent.setEventType(FlashActivityEventType.ONLINE);
flashActivityEvent.setFlashActivity(flashActivity);
domainEventPublisher.publish(flashActivityEvent);
logger.info("activityOnline|活动上线事件已发布|{}", JSON.toJSON(flashActivityEvent));
}
use of com.actionworks.flashsale.domain.model.entity.FlashActivity in project flash-sale by ThoughtsBeta.
the class FlashActivityRepositoryImpl method findById.
@Override
public Optional<FlashActivity> findById(Long activityId) {
FlashActivityDO flashActivityDO = flashActivityMapper.getById(activityId);
if (flashActivityDO == null) {
return Optional.empty();
}
FlashActivity flashActivity = FlashActivityBuilder.toDomainObject(flashActivityDO);
return Optional.of(flashActivity);
}
Aggregations