class ElementsServiceImpl extends SonicServiceImpl<ElementsMapper, Elements> implements ElementsService {

    @Autowired
    private ElementsMapper elementsMapper;
    @Autowired
    private StepsService stepsService;
    @Autowired
    private TestCasesService testCasesService;
    @Autowired
    private StepsElementsMapper stepsElementsMapper;
    @Autowired
    private ModulesMapper modulesMapper;

    @Override
    public CommentPage<ElementsDTO> findAll(int projectId, String type, List<String> eleTypes, String name, String value, List<Integer> moduleIds, Page<Elements> pageable) {
        LambdaQueryChainWrapper<Elements> lambdaQuery = new LambdaQueryChainWrapper<>(elementsMapper);

        if (type != null && type.length() > 0) {
            switch (type) {
                case "normal" -> lambdaQuery.and(
                        l -> l.ne(Elements::getEleType, "point").ne(Elements::getEleType, "image").ne(Elements::getEleType, "poco")
                );
                case "poco" ->
                        lambdaQuery.and(i -> i.eq(Elements::getEleType, "poco").or().eq(Elements::getEleType, "xpath").or().eq(Elements::getEleType, "cssSelector"));
                case "point" -> lambdaQuery.eq(Elements::getEleType, "point");
                case "image" -> lambdaQuery.eq(Elements::getEleType, "image");
            }
        }

        lambdaQuery.eq(Elements::getProjectId, projectId)
                .in(eleTypes != null, Elements::getEleType, eleTypes)
                .in(moduleIds != null && moduleIds.size() > 0, Elements::getModuleId, moduleIds)
                .like(!StringUtils.isEmpty(name), Elements::getEleName, name)
                .like(!StringUtils.isEmpty(value), Elements::getEleValue, value)
                .orderByDesc(Elements::getId);

        //写入对应模块信息
        Page<Elements> page = lambdaQuery.page(pageable);
        List<ElementsDTO> elementsDTOS = page.getRecords()
                .stream().map(e -> findEleDetail(e)).collect(Collectors.toList());

        return CommentPage.convertFrom(page, elementsDTOS);
    }

    @Transactional
    private ElementsDTO findEleDetail(Elements elements) {
        if (elements.getModuleId() != null && elements.getModuleId() != 0) {
            Modules modules = modulesMapper.selectById(elements.getModuleId());
            if (modules != null) {
                return elements.convertTo().setModulesDTO(modules.convertTo());
            }
        }
        return elements.convertTo();
    }

    @Override
    public List<StepsDTO> findAllStepsByElementsId(int elementsId) {<FILL_FUNCTION_BODY>}

    @Override
    @Transactional(rollbackFor = Exception.class)
    public RespModel delete(int id) {
        if (existsById(id)) {
            new LambdaUpdateChainWrapper<StepsElements>(stepsElementsMapper).eq(StepsElements::getElementsId, id)
                    .set(StepsElements::getElementsId, 0).update();
            baseMapper.deleteById(id);
            return new RespModel<>(RespEnum.DELETE_OK);
        } else {
            return new RespModel<>(RespEnum.ID_NOT_FOUND);
        }
    }

    @Override
    public Elements findById(int id) {
        return baseMapper.selectById(id);
    }

    @Override
    public boolean deleteByProjectId(int projectId) {
        return baseMapper.delete(new LambdaQueryWrapper<Elements>().eq(Elements::getProjectId, projectId)) > 0;
    }


    /**
     * 复制控件元素
     *
     * @param id 元素id
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public RespModel<String> copy(int id) {
        Elements element = elementsMapper.selectById(id);
        element.setId(null).setEleName(element.getEleName() + "_copy");
        save(element);

        return new RespModel<>(RespEnum.COPY_OK);
    }

    @Override
    public Boolean newStepBeLinkedEle(StepsDTO stepsDTO, Steps step) {
        for (ElementsDTO elements : stepsDTO.getElements()) {
            stepsElementsMapper.insert(new StepsElements()
                    .setElementsId(elements.getId())
                    .setStepsId(step.getId()));
        }
        return true;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateEleModuleByModuleId(Integer module) {
        List<Elements> elements = lambdaQuery().eq(Elements::getModuleId, module).list();
        if (elements == null) {
            return true;
        }

        for (Elements element : elements) {
            save(element.setModuleId(0));
        }
        return true;
    }
}

        return stepsService.listStepsByElementsId(elementsId).stream().map(e -> {
            StepsDTO stepsDTO = e.convertTo();
            if (0 == stepsDTO.getCaseId()) {
                return stepsDTO.setTestCasesDTO(new TestCasesDTO().setId(0).setName("unknown"));
            }
            return stepsDTO.setTestCasesDTO(testCasesService.findById(stepsDTO.getCaseId()));
        }).collect(Collectors.toList());
    
<methods>public non-sealed void <init>() ,public boolean save(org.cloud.sonic.controller.models.domain.Elements) <variables>