Search in sources :

Example 1 with QuickFilterDTO

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();
}
Also used : QuickFilterDTO(io.choerodon.agile.infra.dto.QuickFilterDTO)

Example 2 with QuickFilterDTO

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);
}
Also used : QuickFilterDTO(io.choerodon.agile.infra.dto.QuickFilterDTO) TypeToken(org.modelmapper.TypeToken) QuickFilterSearchVO(io.choerodon.agile.api.vo.QuickFilterSearchVO) QuickFilterVO(io.choerodon.agile.api.vo.QuickFilterVO)

Example 3 with QuickFilterDTO

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);
}
Also used : QuickFilterDTO(io.choerodon.agile.infra.dto.QuickFilterDTO) CommonException(io.choerodon.core.exception.CommonException)

Example 4 with QuickFilterDTO

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);
}
Also used : QuickFilterDTO(io.choerodon.agile.infra.dto.QuickFilterDTO) CommonException(io.choerodon.core.exception.CommonException)

Example 5 with QuickFilterDTO

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);
}
Also used : QuickFilterDTO(io.choerodon.agile.infra.dto.QuickFilterDTO) CommonException(io.choerodon.core.exception.CommonException)

Aggregations

QuickFilterDTO (io.choerodon.agile.infra.dto.QuickFilterDTO)8 CommonException (io.choerodon.core.exception.CommonException)5 QuickFilterSearchVO (io.choerodon.agile.api.vo.QuickFilterSearchVO)1 QuickFilterVO (io.choerodon.agile.api.vo.QuickFilterVO)1 TypeToken (org.modelmapper.TypeToken)1