use of io.choerodon.agile.infra.dto.QuickFilterDTO in project agile-service by open-hand.
the class QuickFilterServiceImpl method checkNameUpdate.
private Boolean checkNameUpdate(Long projectId, Long filterId, String quickFilterName) {
QuickFilterDTO quickFilterDTO = quickFilterMapper.selectByPrimaryKey(filterId);
if (quickFilterName.equals(quickFilterDTO.getName())) {
return false;
}
QuickFilterDTO check = new QuickFilterDTO();
check.setProjectId(projectId);
check.setName(quickFilterName);
List<QuickFilterDTO> quickFilterDTOList = quickFilterMapper.select(check);
return quickFilterDTOList != null && !quickFilterDTOList.isEmpty();
}
use of io.choerodon.agile.infra.dto.QuickFilterDTO in project agile-service by open-hand.
the class QuickFilterServiceImpl method listByProjectId.
@Override
public Page<QuickFilterVO> listByProjectId(Long projectId, QuickFilterSearchVO quickFilterSearchVO, PageRequest pageRequest) {
boolean isFirstPage = (pageRequest.getPage() == 0);
List<Long> topIds = quickFilterSearchVO.getQuickFilterIds();
List<QuickFilterDTO> list = new ArrayList<>();
if (isFirstPage && !ObjectUtils.isEmpty(topIds)) {
QuickFilterSearchVO search = new QuickFilterSearchVO();
search.setQuickFilterIds(topIds);
list.addAll(quickFilterMapper.queryFiltersByProjectId(projectId, search));
}
quickFilterSearchVO.setQuickFilterIds(null);
quickFilterSearchVO.setIgnoredQuickFilterIds(topIds);
Page<QuickFilterDTO> page = PageHelper.doPageAndSort(pageRequest, () -> quickFilterMapper.queryFiltersByProjectId(projectId, quickFilterSearchVO));
list.addAll(page.getContent());
list.forEach(v -> v.setDescription(handlerFilterDescription(v.getDescription(), true)));
if (list.isEmpty()) {
return PageUtil.emptyPage(pageRequest.getPage(), pageRequest.getSize());
}
List<QuickFilterVO> result = modelMapper.map(list, new TypeToken<List<QuickFilterVO>>() {
}.getType());
return PageUtil.buildPageInfoWithPageInfoList(page, result);
}
use of io.choerodon.agile.infra.dto.QuickFilterDTO in project agile-service by open-hand.
the class QuickFilterServiceImpl method deleteById.
@Override
public void deleteById(Long projectId, Long filterId) {
QuickFilterDTO quickFilterDTO = quickFilterMapper.selectByPrimaryKey(filterId);
if (quickFilterDTO == null) {
throw new CommonException("error.quickFilter.get");
}
if (quickFilterMapper.deleteByPrimaryKey(filterId) != 1) {
throw new CommonException("error.quickFilter.delete");
}
deleteBoardQuickFilterRel(projectId, filterId);
}
use of io.choerodon.agile.infra.dto.QuickFilterDTO in project agile-service by open-hand.
the class QuickFilterServiceImpl method create.
@Override
public QuickFilterVO create(Long projectId, QuickFilterVO quickFilterVO) {
if (!projectId.equals(quickFilterVO.getProjectId())) {
throw new CommonException("error.projectId.notEqual");
}
if (Boolean.TRUE.equals(checkName(projectId, quickFilterVO.getName()))) {
throw new CommonException("error.quickFilterName.exist");
}
Optional.ofNullable(quickFilterVO.getQuickFilterValueVOList()).orElse(Collections.emptyList()).forEach(this::decryptValueList);
String sqlQuery = getSqlQuery(quickFilterVO, projectId);
QuickFilterDTO quickFilterDTO = modelMapper.map(quickFilterVO, QuickFilterDTO.class);
String description = quickFilterDTO.getDescription();
quickFilterDTO.setDescription(handlerFilterDescription(description, false));
quickFilterDTO.setSqlQuery(sqlQuery);
// 设置编号
Integer sequence = quickFilterMapper.queryMaxSequenceByProject(projectId);
quickFilterDTO.setSequence(sequence == null ? 0 : sequence + 1);
if (quickFilterMapper.insert(quickFilterDTO) != 1) {
throw new CommonException("error.quickFilter.insert");
}
return modelMapper.map(quickFilterMapper.selectByPrimaryKey(quickFilterDTO.getFilterId()), QuickFilterVO.class);
}
use of io.choerodon.agile.infra.dto.QuickFilterDTO in project agile-service by open-hand.
the class QuickFilterServiceImpl method dragFilter.
@Override
public QuickFilterVO dragFilter(Long projectId, QuickFilterSequenceVO quickFilterSequenceVO) {
if (quickFilterSequenceVO.getAfterSequence() == null && quickFilterSequenceVO.getBeforeSequence() == null) {
throw new CommonException("error.dragFilter.noSequence");
}
QuickFilterDTO quickFilterDTO = modelMapper.map(quickFilterMapper.selectByPrimaryKey(quickFilterSequenceVO.getFilterId()), QuickFilterDTO.class);
if (quickFilterDTO == null) {
throw new CommonException(NOT_FOUND);
} else {
if (quickFilterSequenceVO.getAfterSequence() == null) {
Integer maxSequence = quickFilterMapper.queryMaxAfterSequence(quickFilterSequenceVO.getBeforeSequence(), projectId);
quickFilterSequenceVO.setAfterSequence(maxSequence);
} else if (quickFilterSequenceVO.getBeforeSequence() == null) {
Integer minSequence = quickFilterMapper.queryMinBeforeSequence(quickFilterSequenceVO.getAfterSequence(), projectId);
quickFilterSequenceVO.setBeforeSequence(minSequence);
}
handleSequence(quickFilterSequenceVO, projectId, quickFilterDTO);
}
return modelMapper.map(quickFilterMapper.selectByPrimaryKey(quickFilterSequenceVO.getFilterId()), QuickFilterVO.class);
}
Aggregations