| | |
| | | import cc.mrbird.febs.ai.entity.AiMemberRoleProduct; |
| | | import cc.mrbird.febs.ai.mapper.AiMemberRoleProductMapper; |
| | | import cc.mrbird.febs.ai.service.AiMemberRoleProductService; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | @Override |
| | | public AiMemberRoleProduct getById(String id) { |
| | | return this.getById(id); |
| | | |
| | | return aiMemberRoleProductMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiMemberRoleProduct> getByRoleId(String roleId) { |
| | | LambdaQueryWrapper<AiMemberRoleProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiMemberRoleProduct::getRoleId, roleId); |
| | | return this.list(queryWrapper); |
| | | public List<AiMemberRoleProduct> selectListByQuery(LambdaQueryWrapper<AiMemberRoleProduct> query) { |
| | | return aiMemberRoleProductMapper.selectList( query); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiMemberRoleProduct> getByProductId(String productId) { |
| | | LambdaQueryWrapper<AiMemberRoleProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiMemberRoleProduct::getProductId, productId); |
| | | return this.list(queryWrapper); |
| | | public void deleteByQuery(LambdaQueryWrapper<AiMemberRoleProduct> query) { |
| | | aiMemberRoleProductMapper.delete( query); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiMemberRoleProduct> getByCompanyId(String companyId) { |
| | | LambdaQueryWrapper<AiMemberRoleProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiMemberRoleProduct::getCompanyId, companyId); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<AiMemberRoleProduct> getByRoleIdAndProductId(String roleId, String productId) { |
| | | LambdaQueryWrapper<AiMemberRoleProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiMemberRoleProduct::getRoleId, roleId); |
| | | queryWrapper.eq(AiMemberRoleProduct::getProductId, productId); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveRoleProduct(AiMemberRoleProduct aiMemberRoleProduct) { |
| | | try { |
| | | return this.save(aiMemberRoleProduct); |
| | | } catch (Exception e) { |
| | | log.error("保存角色产品关联记录失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveBatchRoleProducts(List<AiMemberRoleProduct> roleProducts) { |
| | | try { |
| | | return this.saveBatch(roleProducts); |
| | | } catch (Exception e) { |
| | | log.error("批量保存角色产品关联记录失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateRoleProduct(AiMemberRoleProduct aiMemberRoleProduct) { |
| | | try { |
| | | return this.updateById(aiMemberRoleProduct); |
| | | } catch (Exception e) { |
| | | log.error("更新角色产品关联记录失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean deleteById(String id) { |
| | | try { |
| | | return this.removeById(id); |
| | | } catch (Exception e) { |
| | | log.error("删除角色产品关联记录失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean deleteByRoleId(String roleId) { |
| | | try { |
| | | LambdaQueryWrapper<AiMemberRoleProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiMemberRoleProduct::getRoleId, roleId); |
| | | return this.remove(queryWrapper); |
| | | } catch (Exception e) { |
| | | log.error("根据角色ID删除角色产品关联记录失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean deleteByProductId(String productId) { |
| | | try { |
| | | LambdaQueryWrapper<AiMemberRoleProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiMemberRoleProduct::getProductId, productId); |
| | | return this.remove(queryWrapper); |
| | | } catch (Exception e) { |
| | | log.error("根据产品ID删除角色产品关联记录失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean deleteByRoleIdAndProductId(String roleId, String productId) { |
| | | try { |
| | | LambdaQueryWrapper<AiMemberRoleProduct> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(AiMemberRoleProduct::getRoleId, roleId); |
| | | queryWrapper.eq(AiMemberRoleProduct::getProductId, productId); |
| | | return this.remove(queryWrapper); |
| | | } catch (Exception e) { |
| | | log.error("根据角色ID和产品ID删除角色产品关联记录失败: ", e); |
| | | return false; |
| | | } |
| | | } |
| | | } |