| | |
| | | |
| | | private final AiProductQuestionMapper aiProductQuestionMapper; |
| | | |
| | | @Override |
| | | public AiProductQuestion getById(String id) { |
| | | return this.getById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> getByCompanyId(String companyId) { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductQuestion::getCompanyId, companyId); |
| | | queryWrapper.orderByDesc(AiProductQuestion::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> getByProductCategoryId(String productCategoryId) { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductQuestion::getProductCategoryId, productCategoryId); |
| | | queryWrapper.orderByDesc(AiProductQuestion::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> getByTitle(String title) { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.like(AiProductQuestion::getTitle, title); |
| | | queryWrapper.orderByDesc(AiProductQuestion::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> getByParentId(String parentId) { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductQuestion::getParentId, parentId); |
| | | queryWrapper.orderByAsc(AiProductQuestion::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> getByDifficulty(Integer difficulty) { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductQuestion::getDifficulty, difficulty); |
| | | queryWrapper.orderByDesc(AiProductQuestion::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> getByState(Integer state) { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductQuestion::getState, state); |
| | | queryWrapper.orderByDesc(AiProductQuestion::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> getByCorrectAnswer(Integer correctAnswer) { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductQuestion::getCorrectAnswer, correctAnswer); |
| | | queryWrapper.orderByDesc(AiProductQuestion::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> getByCompanyIdAndState(String companyId, Integer state) { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductQuestion::getCompanyId, companyId); |
| | | queryWrapper.eq(AiProductQuestion::getState, state); |
| | | queryWrapper.orderByDesc(AiProductQuestion::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductQuestion> getByParentIdAndState(String parentId, Integer state) { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductQuestion::getParentId, parentId); |
| | | queryWrapper.eq(AiProductQuestion::getState, state); |
| | | queryWrapper.orderByAsc(AiProductQuestion::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveProductQuestion(AiProductQuestion aiProductQuestion) { |
| | | try { |
| | | return this.save(aiProductQuestion); |
| | | } catch (Exception e) { |
| | | log.error("保存AI产品题目失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveBatchProductQuestions(List<AiProductQuestion> productQuestions) { |
| | | try { |
| | | return this.saveBatch(productQuestions); |
| | | } catch (Exception e) { |
| | | log.error("批量保存AI产品题目失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateProductQuestion(AiProductQuestion aiProductQuestion) { |
| | | try { |
| | | return this.updateById(aiProductQuestion); |
| | | } catch (Exception e) { |
| | | log.error("更新AI产品题目失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean deleteById(String id) { |
| | | try { |
| | | return this.removeById(id); |
| | | } catch (Exception e) { |
| | | log.error("删除AI产品题目失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean deleteByParentId(String parentId) { |
| | | try { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductQuestion::getParentId, parentId); |
| | | return this.remove(queryWrapper); |
| | | } catch (Exception e) { |
| | | log.error("根据父ID删除AI产品题目失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean deleteByCompanyId(String companyId) { |
| | | try { |
| | | LambdaQueryWrapper<AiProductQuestion> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductQuestion::getCompanyId, companyId); |
| | | return this.remove(queryWrapper); |
| | | } catch (Exception e) { |
| | | log.error("根据公司ID删除AI产品题目失败: ", e); |
| | | return false; |
| | | } |
| | | public List<AiProductQuestion> getListByQuery(LambdaQueryWrapper<AiProductQuestion> questionLambdaQueryWrapper) { |
| | | return aiProductQuestionMapper.selectList(questionLambdaQueryWrapper); |
| | | } |
| | | } |