015 品牌关联分类

news2024/10/8 10:40:19

文章目录

    • 后端
      • CategoryBrandEntity.java
      • CategoryBrandController.java
      • CategoryBrandServiceImpl.java
      • CategoryServiceImpl.java
      • BrandServiceImpl.java
      • 删除

npm install pubsub-js
npm install --save pubsub-js
这个错误是由于在尝试安装 pubsub-js 时,npm 发现了项目中存在依赖冲突。具体来说,是 sass-loader@6.0.6 需要 node-sass@^4.0.0(即 4.x 版本),但你的项目中实际安装的是 node-sass@1.77.8,这是一个较新的版本,不兼容 sass-loader@6.0.6。

要解决这个问题,你有几个选项:

更新 sass-loader: 检查是否有新版本的 sass-loader 兼容你当前安装的 node-sass 版本。如果有,更新 sass-loader 到这个版本。你可以在 npm 或者 GitHub 上查看 sass-loader 的最新版本和兼容性信息。
降级 node-sass: 如果没有可用的 sass-loader 更新,你可能需要将 node-sass 降级到 4.x 版本。你可以通过修改 package.json 文件中的依赖版本,然后运行 npm install 来实现。
使用 --legacy-peer-deps: 如果你不想改动依赖版本,可以在安装命令中添加 --legacy-peer-deps 选项,这将忽略 peer 依赖冲突。例如:
npm install pubsub-js --legacy-peer-deps
使用 --force: 这是一个更激进的选择,它将强制 npm 忽略所有冲突并继续安装。但这可能会导致不可预见的问题,因此建议谨慎使用:
npm install pubsub-js --force
清理 node_modules 和缓存: 有时候,清理现有的 node_modules 目录和 npm 缓存可以解决依赖问题。你可以尝试以下命令:
rm -rf node_modules  
npm cache clean --force  
npm install
建议首先尝试更新 sass-loader 或降级 node-sass,因为这些方法更可能保持项目的稳定性和兼容性。如果这些方法不可行,再考虑使用 --legacy-peer-deps 或 --force 选项。
命令 npm install --save pubsub-js 在 Node.js 和 npm (Node Package Manager) 环境中用于安装一个名为 pubsub-js 的包,并将其作为依赖项保存到项目的 package.json 文件中。下面是对这个命令的详细解释:

npm install: 这是 npm 的主要命令之一,用于安装 Node.js 包。这个命令会从 npm 仓库(或指定的其他源)下载包及其依赖,并将它们安装到当前项目的 node_modules 目录中。
--save: 这个选项告诉 npm 将安装的包作为一个依赖项添加到项目的 package.json 文件的 dependencies 部分。这样做的好处是,其他人(或你自己在其他地方)可以通过运行 npm install(不带任何参数)来自动安装所有列出的依赖项,从而更容易地复制和设置项目环境。在较新的 npm 版本中,--save 是默认行为,因此通常可以省略。
pubsub-js: 这是你要安装的包的名称。pubsub-js 是一个 JavaScript 的发布/订阅(Pub/Sub)模式的实现库,允许你在应用中实现松耦合的消息传递。
总结起来,运行 npm install --save pubsub-js 后,pubsub-js 包会被安装到你项目的 node_modules 目录下,并且你的 package.json 文件会被更新,包含对 pubsub-js 的依赖。这样,无论何时何人克隆你的项目或在其他环境中设置它,只需运行 npm install 就可以确保所有必要的依赖都被正确安装。

品牌分类关联

后端

CategoryBrandEntity.java

package com.xd.cubemall.product.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;
import lombok.Data;

/**
 * 分类品牌关系表
 * 
 * @author xuedong
 * @email email@gmail.com
 * @date 2024-08-13 01:36:04
 */
@Data
@TableName("tb_category_brand")
public class CategoryBrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 主键ID
	 */
	@TableId
	private Integer id;
	/**
	 * 分类ID
	 */
	private Integer categoryId;
	/**
	 * 品牌ID
	 */
	private Integer brandId;

	@TableField(exist = false)
	private String categoryName;

	@TableField(exist = false)
	private String brandName;

}

CategoryBrandController.java

package com.xd.cubemall.product.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xd.cubemall.common.utils.PageUtils;
import com.xd.cubemall.common.utils.R;
import com.xd.cubemall.product.service.BrandService;
import com.xd.cubemall.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xd.cubemall.product.entity.CategoryBrandEntity;
import com.xd.cubemall.product.service.CategoryBrandService;




/**
 * 分类品牌关系表
 *
 * @author xuedong
 * @email email@gmail.com
 * @date 2024-08-13 07:57:20
 */
@RestController
@RequestMapping("product/categorybrand")
public class CategoryBrandController {
    @Autowired
    private CategoryBrandService categoryBrandService;

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private BrandService brandService;

    /**
     * 列表
     */
    @RequestMapping("/category/list")
    //@RequiresPermissions("product:categorybrand:list")
    public R list(@RequestParam("brandId") Long brandid){
        List<CategoryBrandEntity> data = categoryBrandService.list(
                new QueryWrapper<CategoryBrandEntity>().eq("brand_id", brandid)
        );
        data.forEach(categoryBrandEntity -> {
            categoryBrandEntity.setCategoryName(categoryService.getById(categoryBrandEntity.getCategoryId()).getName());
            categoryBrandEntity.setBrandName(brandService.getById(categoryBrandEntity.getBrandId()).getName());
        });

        return R.ok().put("data", data);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("product:categorybrand:info")
    public R info(@PathVariable("id") Integer id){
		CategoryBrandEntity categoryBrand = categoryBrandService.getById(id);

        return R.ok().put("categoryBrand", categoryBrand);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("product:categorybrand:save")
    public R save(@RequestBody CategoryBrandEntity categoryBrand){
		categoryBrandService.save(categoryBrand);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("product:categorybrand:update")
    public R update(@RequestBody CategoryBrandEntity categoryBrand){
		categoryBrandService.updateById(categoryBrand);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("product:categorybrand:delete")
    public R delete(@RequestBody Integer[] ids){
		categoryBrandService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}

CategoryBrandServiceImpl.java

package com.xd.cubemall.product.service.impl;

import com.xd.cubemall.common.utils.PageUtils;
import com.xd.cubemall.common.utils.Query;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.xd.cubemall.product.dao.CategoryBrandDao;
import com.xd.cubemall.product.entity.CategoryBrandEntity;
import com.xd.cubemall.product.service.CategoryBrandService;


@Service("categoryBrandService")
public class CategoryBrandServiceImpl extends ServiceImpl<CategoryBrandDao, CategoryBrandEntity> implements CategoryBrandService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CategoryBrandEntity> page = this.page(
                new Query<CategoryBrandEntity>().getPage(params),
                new QueryWrapper<CategoryBrandEntity>()
        );

        return new PageUtils(page);
    }

}

CategoryServiceImpl.java

package com.xd.cubemall.product.service.impl;

import com.xd.cubemall.common.utils.PageUtils;
import com.xd.cubemall.common.utils.Query;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.xd.cubemall.product.dao.CategoryDao;
import com.xd.cubemall.product.entity.CategoryEntity;
import com.xd.cubemall.product.service.CategoryService;


@Service("categoryService")
public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity> implements CategoryService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CategoryEntity> page = this.page(
                new Query<CategoryEntity>().getPage(params),
                new QueryWrapper<CategoryEntity>()
        );

        return new PageUtils(page);
    }


    /**
     * 查询所有分类
     * @return
     */
    @Override
    public List<CategoryEntity> listWithTree() {
        //1.查询所有分类
        List<CategoryEntity> entities = baseMapper.selectList(null);

        //2.组装成父子的树形结构
        //2.1 找到所有的一级分类
        List<CategoryEntity> levelOneMenus = entities.stream().filter(
            //过滤出一级分类,parentId==0,根据这个条件构建出所有一级分类的数据
                categoryEntity -> categoryEntity.getParentId() == 0

        ).map((menu)->{
            //出现递归操作,关联出子分类(2,3级分类)
            menu.setChildrens(getChildrens(menu,entities));
            return menu;
        }).collect(Collectors.toList());
        return levelOneMenus;
    }

    /**
     * 递归查找指定分类的所有子分类(所有菜单的子菜单)
     * @param currentMenu
     * @param entities
     * @return
     */
    private List<CategoryEntity> getChildrens(CategoryEntity currentMenu, List<CategoryEntity> entities) {
        List<CategoryEntity> childrens = entities.stream().filter(
            //过滤出 当前菜单的所有匹配的子菜单 currentMenu.id == categoryEntity.parentId
                categoryEntity -> currentMenu.getId().equals(categoryEntity.getParentId())

        ).map((menu)->{
            //找到子分类
            menu.setChildrens(getChildrens(menu,entities));
            return menu;
        }).collect(Collectors.toList());

        return childrens;
    }

    /**
     * 逻辑删除菜单
     * @param asList
     */
    @Override
    public void removeMenuByIds(List<Integer> asList) {
        //TODO 检查当前要删除的菜单是否被别的地方引用
        //逻辑删除
        baseMapper.deleteBatchIds(asList);
    }

    /**
     * 收集三级菜单id
     * @param categoryId
     * @return [558, 559, 560]
     */
    @Override
    public Long[] findCategoryPath(Integer categoryId) {
        List<Long> paths = new ArrayList<>();
        //通过递归查询到 把当前分类id与父分类id 添加到paths集合中
        List<Long> parentPath = findParentPath(categoryId, paths);

        Collections.reverse(parentPath);
        return parentPath.toArray(new Long[parentPath.size()]);
    }


    /**
     * 递归收集菜单id
     * @param categoryId
     * @param paths
     * @return [560, 559, 558]
     */
    private List<Long> findParentPath(Integer categoryId, List<Long> paths) {
        //收集当前分类id到集合中
        paths.add(categoryId.longValue());
        CategoryEntity categoryEntity = this.getById(categoryId);
        if (categoryEntity.getParentId() != 0){
            findParentPath(categoryEntity.getParentId(), paths);
        }
        return paths;
    }
}

BrandServiceImpl.java

package com.xd.cubemall.product.service.impl;

import com.xd.cubemall.common.utils.PageUtils;
import com.xd.cubemall.common.utils.Query;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.xd.cubemall.product.dao.BrandDao;
import com.xd.cubemall.product.entity.BrandEntity;
import com.xd.cubemall.product.service.BrandService;


@Service("brandService")
public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> implements BrandService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        //编写条件查询的条件
        String key = (String) params.get("key");
        QueryWrapper<BrandEntity> queryWrapper = new QueryWrapper<>();
        //封装查询条件
        if(!StringUtils.isEmpty(key)) {
            queryWrapper.eq("id",key).or().like("name",key);
        }

        IPage<BrandEntity> page = this.page(
                new Query<BrandEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}

删除

CategoryBrandController

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("product:categorybrand:delete")
    public R delete(@RequestBody CategoryBrandEntity categoryBrandEntity){
		//categoryBrandService.removeByIds(Arrays.asList(ids));

        categoryBrandService.remove(
                new QueryWrapper<CategoryBrandEntity>().eq("brand_id",categoryBrandEntity.getBrandId()).eq("category_id",categoryBrandEntity.getCategoryId())
        );
        return R.ok();
    }

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2196147.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Python 如何使用 multiprocessing 模块创建进程池

Python 如何使用 multiprocessing 模块创建进程池 一、简介 在现代计算中&#xff0c;提升程序性能的一个关键方法是并行处理&#xff0c;尤其是当处理大量数据或计算密集型任务时&#xff0c;单线程可能不够高效。Python 提供了多个模块来支持并行计算&#xff0c;其中最常用…

爬虫案例——爬取长沙房产网租房信息

需求&#xff1a; 1.爬取长沙房产网租房信息&#xff08;长沙租房信息_长沙出租房源|房屋出租价格【长沙贝壳租房】 包括租房标题、标题链接&#xff0c;价格和地址 2.实现翻页爬取 3.使用bs4解析数据 分析 1.抓取正确的数据包——看响应内容 找到正确的后&#xff0c;复…

大模型之RAG-关键字检索的认识与实战(混合检索进阶储备)

前言 按照我们之前的分享&#xff08;大模型应用RAG系列3-1从0搭建一个RAG&#xff1a;做好文档切分&#xff09;&#xff1a; RAG系统搭建的基本流程 准备对应的垂域资料文档的读取解析&#xff0c;进行文档切分将分割好的文本灌入检索引擎&#xff08;向量数据库&#xff…

如何使用ssm实现新冠病毒校园监控平台的设计与实现+vue

TOC ssm812新冠病毒校园监控平台的设计与实现vue 绪论 课题背景 身处网络时代&#xff0c;随着网络系统体系发展的不断成熟和完善&#xff0c;人们的生活也随之发生了很大的变化。目前&#xff0c;人们在追求较高物质生活的同时&#xff0c;也在想着如何使自身的精神内涵得…

python画图|曲线动态输出基础教程

在前述学习过程中&#xff0c;已经掌握基本的曲线图像画法&#xff0c;并尝试探索过3D动画基础教程。 相关文章可以通过下述链接直达&#xff1a; python画三角函数图|小白入门级教程_正余弦函数画图python-CSDN博客 python动画教程|Animations using Matplotlib-官网教程程…

Hallo部署指南

一、介绍 Hallo是由复旦大学、百度公司、苏黎世联邦理工学院和南京大学的研究人员共同提出的一个AI对口型肖像图像动画技术&#xff0c;可基于语音音频输入来驱动生成逼真且动态的肖像图像视频。 该框架采用了基于扩散的生成模型和分层音频驱动视觉合成模块&#xff0c;提高了…

Linux实践|设置静态 IP 地址

引言 如果您是 Linux 系统管理员&#xff0c;那么您将需要在系统上配置网络。与可以使用动态 IP 地址的台式机不同&#xff0c;在服务器基础设施上&#xff0c;您需要设置静态 IP 地址&#xff08;至少在大多数情况下&#xff09;。 本文[1]旨在向您展示如何在最常用的 Linux 发…

TBD62783AFG的强大性能:高性能应用的可靠解决方案

在当今竞争激烈的电子市场中&#xff0c;工程师们始终在寻找能够提供可靠性、效率和多功能性的组件&#xff0c;尤其是在处理复杂、高性能系统时。东芝的TBD62783AFG 8通道源型DMOS晶体管阵列就是这样一个元件。凭借其独特的功能组合&#xff0c;使其成为从小型电机到感性设备的…

SpringCloud学习记录|day3

学习材料 2024最新SpringCloud微服务开发与实战&#xff0c;java黑马商城项目微服务实战开发&#xff08;涵盖MybatisPlus、Docker、MQ、ES、Redis高级等&#xff09; 微服务 1.单体架构 2.JMeter 这其实在redis还是什么教程里面用过&#xff0c;不过忘记得差不多了。 复习…

【重学 MySQL】六十、空间类型

【重学 MySQL】六十、空间类型 空间数据类型的分类空间数据类型的属性空间数据的表示方式空间数据的操作应用场景 在MySQL中&#xff0c;空间类型&#xff08;Spatial Types&#xff09;主要用于支持地理特征的生成、存储和分析。这些地理特征可以表示世界上具有位置的任何东西…

全是细节|大模型SFT的100个关键点

这篇文章介绍一下大模型的 sft 如何去做。我会默认读者们都知道 sft 是做什么的以及如何去做一些简单的 sft 微调工作&#xff0c;我主要是分享一些经验技巧和 debug 的分析思路。 背景篇 这里先普及一些 sft 涉及到的基础概念&#xff0c;方便新人同学理解后续内容&#xff0…

从0开始linux(6)——gcc

欢迎来到博主的专栏&#xff1a;从0开始linux 博主ID&#xff1a;代码小豪、 文章目录 gccgcc的文件风格预处理编译汇编链接 gcc gcc是linux系统下常用的C语言编译器&#xff0c;随着后续的扩展&#xff0c;gcc支持了c&#xff0c;并推出了g编译器&#xff0c;现在的gcc可以支…

C++(异常)

目录 C语言传统的处理错误的方式 传统的错误处理机制 C异常概念 异常的使用 异常的抛出和捕获 异常的抛出和匹配原则 在函数调用链中异常栈展开匹配原则 异常的重新抛出 异常安全 异常规范 自定义异常体系 C标准库的异常体系 异常的优缺点 C异常的优点 C异常的缺…

基于Python的美术馆预约系统【附源码】

效果如下&#xff1a; 系统首页界面 系统注册页面 美术馆详细页面 公告信息详细页面 后台登录界面 管理员主界面 美术馆管理界面 预约参观管理界面 研究背景 随着文化娱乐活动的日益丰富&#xff0c;美术馆作为展示艺术作品、传播文化的重要场所&#xff0c;其管理和服务模式…

大语言模型入门(四)——检索增强生成(RAG)

一、什么是检索增强生成 检索增强生成&#xff08;Retrieval-Augmented Generation&#xff0c;RAG&#xff09;由Facebook AI Research&#xff08;FAIR&#xff09;团队于2020年首次提出&#xff0c;这是一种结合了信息检索技术与语言生成模型的人工智能技术。它通过从外部知…

局域网内探测在线好友是如何做到的?

一、前言 随着局域网&#xff08;LAN&#xff09;应用的广泛使用&#xff0c;网络通信已经成为软件设计中不可或缺的一部分。局域网聊天软件作为一种常见的网络应用&#xff0c;可以实现多个用户之间的实时通信&#xff0c;广泛应用于企业内部沟通和小型网络环境中。本项目设计…

‌视频尺寸修改与批量剪辑技巧

在当今这个数字化时代&#xff0c;视频内容已成为人们获取信息、娱乐和社交的重要方式。然而&#xff0c;面对海量的视频素材&#xff0c;如何高效地管理和编辑它们成为了一个挑战。 1打开视频剪辑高手软件&#xff0c;切换功能到“批量剪辑视频” 2把需要剪辑的视频导入到表格…

希尔排序和直接插入排序

因为排序这些比较复杂点我就分几期给大家来讲~~~ 直接插入排序 直接插入排序是一种简单的排序算法&#xff0c;主要用于对少量数据进行排序。其基本思想是将待排序的元素逐个插入到已经排好序的部分中&#xff0c;从而形成一个有序序列。 具体步骤如下&#xff1a; 初始化&…

基于32单片机的博物馆安全监控系统设计

目录 一、主要功能 二、硬件资源 三、程序编程 四、实现现象 一、主要功能 检测 分别是温湿度 光照 PM2.5、烟雾、红外&#xff0c;然后用OLED屏幕显示&#xff0c; 红外超过阈值则蜂鸣器报警&#xff0c;这是防盗报警&#xff1b;温度或烟雾超过阈值&#xff0c;则蜂鸣器…

【目标检测】木制地板缺陷破损数据集338张6类VOC+YOLO格式

数据集格式&#xff1a;Pascal VOC格式YOLO格式(不包含分割路径的txt文件&#xff0c;仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数)&#xff1a;3383 标注数量(xml文件个数)&#xff1a;3383 标注数量(txt文件个数)&#xff1a;3383 标注…