| | |
| | | |
| | | private final AiProductCategoryMapper aiProductCategoryMapper; |
| | | |
| | | @Override |
| | | public AiProductCategory getById(String id) { |
| | | return this.getById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductCategory> getByCompanyId(String companyId) { |
| | | LambdaQueryWrapper<AiProductCategory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductCategory::getCompanyId, companyId); |
| | | queryWrapper.orderByAsc(AiProductCategory::getSort); |
| | | queryWrapper.orderByDesc(AiProductCategory::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public AiProductCategory getByCode(String code) { |
| | | LambdaQueryWrapper<AiProductCategory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductCategory::getCode, code); |
| | | return this.getOne(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductCategory> getByName(String name) { |
| | | LambdaQueryWrapper<AiProductCategory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.like(AiProductCategory::getName, name); |
| | | queryWrapper.orderByAsc(AiProductCategory::getSort); |
| | | queryWrapper.orderByDesc(AiProductCategory::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductCategory> getByState(Integer state) { |
| | | LambdaQueryWrapper<AiProductCategory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductCategory::getState, state); |
| | | queryWrapper.orderByAsc(AiProductCategory::getSort); |
| | | queryWrapper.orderByDesc(AiProductCategory::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductCategory> getByHotState(Integer hotState) { |
| | | LambdaQueryWrapper<AiProductCategory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductCategory::getHotState, hotState); |
| | | queryWrapper.orderByAsc(AiProductCategory::getSort); |
| | | queryWrapper.orderByDesc(AiProductCategory::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductCategory> getByCompanyIdAndState(String companyId, Integer state) { |
| | | LambdaQueryWrapper<AiProductCategory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductCategory::getCompanyId, companyId); |
| | | queryWrapper.eq(AiProductCategory::getState, state); |
| | | queryWrapper.orderByAsc(AiProductCategory::getSort); |
| | | queryWrapper.orderByDesc(AiProductCategory::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductCategory> getByCompanyIdAndHotState(String companyId, Integer hotState) { |
| | | LambdaQueryWrapper<AiProductCategory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductCategory::getCompanyId, companyId); |
| | | queryWrapper.eq(AiProductCategory::getHotState, hotState); |
| | | queryWrapper.orderByAsc(AiProductCategory::getSort); |
| | | queryWrapper.orderByDesc(AiProductCategory::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProductCategory> getEnabledCategories() { |
| | | LambdaQueryWrapper<AiProductCategory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductCategory::getState, 1); // 1-启用 |
| | | queryWrapper.orderByAsc(AiProductCategory::getSort); |
| | | queryWrapper.orderByDesc(AiProductCategory::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveProductCategory(AiProductCategory aiProductCategory) { |
| | | try { |
| | | return this.save(aiProductCategory); |
| | | } catch (Exception e) { |
| | | log.error("保存AI产品类别失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveBatchProductCategories(List<AiProductCategory> productCategories) { |
| | | try { |
| | | return this.saveBatch(productCategories); |
| | | } catch (Exception e) { |
| | | log.error("批量保存AI产品类别失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateProductCategory(AiProductCategory aiProductCategory) { |
| | | try { |
| | | return this.updateById(aiProductCategory); |
| | | } 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 deleteByCompanyId(String companyId) { |
| | | try { |
| | | LambdaQueryWrapper<AiProductCategory> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProductCategory::getCompanyId, companyId); |
| | | return this.remove(queryWrapper); |
| | | } catch (Exception e) { |
| | | log.error("根据公司ID删除AI产品类别失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | } |