| | |
| | | |
| | | private final AiProductMapper aiProductMapper; |
| | | |
| | | @Override |
| | | public AiProduct getById(String id) { |
| | | return this.getById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProduct> getByCompanyId(String companyId) { |
| | | LambdaQueryWrapper<AiProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProduct::getCompanyId, companyId); |
| | | queryWrapper.orderByDesc(AiProduct::getSort); |
| | | queryWrapper.orderByDesc(AiProduct::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public AiProduct getByCode(String code) { |
| | | LambdaQueryWrapper<AiProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProduct::getCode, code); |
| | | return this.getOne(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProduct> getByName(String name) { |
| | | LambdaQueryWrapper<AiProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.like(AiProduct::getName, name); |
| | | queryWrapper.orderByDesc(AiProduct::getSort); |
| | | queryWrapper.orderByDesc(AiProduct::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProduct> getByProductCategoryId(String productCategoryId) { |
| | | LambdaQueryWrapper<AiProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProduct::getProductCategoryId, productCategoryId); |
| | | queryWrapper.orderByDesc(AiProduct::getSort); |
| | | queryWrapper.orderByDesc(AiProduct::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProduct> getByState(Integer state) { |
| | | LambdaQueryWrapper<AiProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProduct::getState, state); |
| | | queryWrapper.orderByDesc(AiProduct::getSort); |
| | | queryWrapper.orderByDesc(AiProduct::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProduct> getByHotState(Integer hotState) { |
| | | LambdaQueryWrapper<AiProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProduct::getHotState, hotState); |
| | | queryWrapper.orderByDesc(AiProduct::getSort); |
| | | queryWrapper.orderByDesc(AiProduct::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProduct> getByCompanyIdAndState(String companyId, Integer state) { |
| | | LambdaQueryWrapper<AiProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProduct::getCompanyId, companyId); |
| | | queryWrapper.eq(AiProduct::getState, state); |
| | | queryWrapper.orderByDesc(AiProduct::getSort); |
| | | queryWrapper.orderByDesc(AiProduct::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiProduct> getByCompanyIdAndHotState(String companyId, Integer hotState) { |
| | | LambdaQueryWrapper<AiProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProduct::getCompanyId, companyId); |
| | | queryWrapper.eq(AiProduct::getHotState, hotState); |
| | | queryWrapper.orderByDesc(AiProduct::getSort); |
| | | queryWrapper.orderByDesc(AiProduct::getCreatedTime); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveProduct(AiProduct aiProduct) { |
| | | try { |
| | | return this.save(aiProduct); |
| | | } catch (Exception e) { |
| | | log.error("保存AI产品失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveBatchProducts(List<AiProduct> products) { |
| | | try { |
| | | return this.saveBatch(products); |
| | | } catch (Exception e) { |
| | | log.error("批量保存AI产品失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateProduct(AiProduct aiProduct) { |
| | | try { |
| | | return this.updateById(aiProduct); |
| | | } 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<AiProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiProduct::getCompanyId, companyId); |
| | | return this.remove(queryWrapper); |
| | | } catch (Exception e) { |
| | | log.error("根据公司ID删除AI产品失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | } |