| | |
| | | import com.tcm.training.admin.common.PageResponse; |
| | | import com.tcm.training.admin.system.dto.ActivityNoticeCreateRequest; |
| | | import com.tcm.training.admin.system.entity.ActivityNotice; |
| | | import com.tcm.training.admin.system.event.ActivityNoticeCreatedEvent; |
| | | import com.tcm.training.admin.system.mapper.ActivityNoticeMapper; |
| | | import com.tcm.training.admin.system.vo.ActivityNoticeListItemVO; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | public class ActivityNoticeAppService { |
| | | |
| | | private final ActivityNoticeMapper activityNoticeMapper; |
| | | private final ActivityNoticeDispatchService activityNoticeDispatchService; |
| | | private final ApplicationEventPublisher applicationEventPublisher; |
| | | |
| | | public ActivityNoticeAppService(ActivityNoticeMapper activityNoticeMapper) { |
| | | public ActivityNoticeAppService(ActivityNoticeMapper activityNoticeMapper, |
| | | ActivityNoticeDispatchService activityNoticeDispatchService, |
| | | ApplicationEventPublisher applicationEventPublisher) { |
| | | this.activityNoticeMapper = activityNoticeMapper; |
| | | this.activityNoticeDispatchService = activityNoticeDispatchService; |
| | | this.applicationEventPublisher = applicationEventPublisher; |
| | | } |
| | | |
| | | public PageResponse<ActivityNoticeListItemVO> page(int page, int pageSize, String title) { |
| | |
| | | item.setContentHtml(normalizeContent(request.getContentHtml())); |
| | | item.setDeleted(0); |
| | | activityNoticeMapper.insert(item); |
| | | applicationEventPublisher.publishEvent(new ActivityNoticeCreatedEvent(item.getId())); |
| | | return toListItem(requireItem(item.getId())); |
| | | } |
| | | |
| | | @Transactional |
| | | public void delete(Long id) { |
| | | requireItem(id); |
| | | activityNoticeDispatchService.hideDistributedRecords(id); |
| | | activityNoticeMapper.deleteById(id); |
| | | } |
| | | |