| | |
| | | package kr.wisestone.owl.service.impl; |
| | | |
| | | import kr.wisestone.owl.common.ExcelConditionCheck; |
| | | import kr.wisestone.owl.config.kafka.KafkaSender; |
| | | import kr.wisestone.owl.constant.Constants; |
| | | import kr.wisestone.owl.constant.MsgConstants; |
| | |
| | | import kr.wisestone.owl.repository.NoticeRepository; |
| | | import kr.wisestone.owl.service.NoticeService; |
| | | import kr.wisestone.owl.service.UserService; |
| | | import kr.wisestone.owl.service.WorkspaceService; |
| | | import kr.wisestone.owl.util.ConvertUtil; |
| | | import kr.wisestone.owl.vo.NoticeVo; |
| | | import kr.wisestone.owl.vo.ResPage; |
| | | import kr.wisestone.owl.vo.*; |
| | | import kr.wisestone.owl.web.condition.CompanyFieldCondition; |
| | | import kr.wisestone.owl.web.condition.NoticeCondition; |
| | | import kr.wisestone.owl.web.form.NoticeForm; |
| | | import kr.wisestone.owl.web.view.ExcelView; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | private NoticeRepository noticeRepository; |
| | | |
| | | @Autowired |
| | | private NoticeMapper noticeMapper; |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private KafkaSender kafkaSender; |
| | | private WorkspaceService workspaceService; |
| | | |
| | | @Autowired |
| | | private NoticeMapper noticeMapper; |
| | | private ExcelView excelView; |
| | | |
| | | @Autowired |
| | | private ExcelConditionCheck excelConditionCheck; |
| | | |
| | | @Autowired |
| | | private KafkaSender kafkaSender; |
| | | |
| | | @Override |
| | | protected JpaRepository<Notice, Long> getRepository() { |
| | |
| | | this.kafkaSender.send("common-topic", message); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ModelAndView downloadExcel(HttpServletRequest request, Model model) { |
| | | ModelAndView modelAndView = this.workspaceService.checkUseExcelDownload(model); |
| | | if (modelAndView != null) { |
| | | return modelAndView; |
| | | } |
| | | |
| | | Map<String, Object> conditions = new HashMap<>(); |
| | | // 엑셀 다운로드에 필요한 검색 조건 정보를 추출하고 검색 조건 추출에 오류가 발생하면 경고를 표시해준다. |
| | | modelAndView = this.excelConditionCheck.checkCondition(conditions, request, model); |
| | | if (modelAndView != null) { |
| | | return modelAndView; |
| | | } |
| | | |
| | | NoticeCondition noticeCondition = NoticeCondition.make(conditions); |
| | | List<Map<String, Object>> results = this.noticeMapper.find(noticeCondition); |
| | | List<NoticeVo> noticeVos = ConvertUtil.convertListToListClass(results, NoticeVo.class); |
| | | |
| | | // code_ko_KR 에 code명 설정 |
| | | ExportExcelVo excelInfo = new ExportExcelVo(); |
| | | excelInfo.setFileName(this.messageAccessor.message("공지사항 목록")); |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("title", this.messageAccessor.message("notice.title"), 6, ExportExcelAttrVo.ALIGN_CENTER)); |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("registerDate", this.messageAccessor.message("notice.registerDate"), 10, ExportExcelAttrVo.ALIGN_CENTER)); |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("registerId", this.messageAccessor.message("notice.registerId"), 10, ExportExcelAttrVo.ALIGN_CENTER)); |
| | | |
| | | excelInfo.setDatas(noticeVos); |
| | | |
| | | model.addAttribute(Constants.EXCEL, excelInfo); |
| | | return new ModelAndView(this.excelView); |
| | | } |
| | | } |