三级分类
三级分类对应的表
controller
service
serviceImpl
获取到数据
过滤器筛选一级标题
@RequestMapping("/list/tree")
//@RequiresPermissions("product:category:list")
public R list(){
List entities = categoryService.listWithTree();
//过滤器 得到一级标题 parent_cid == 0
List level1Menus = entities.stream().filter((categoryEntity) -> {
return categoryEntity.getParentCid() == 0;
}).collect(Collectors.toList());
return R.ok().put("data", level1Menus);
}
筛选子类
在CategoryEnity里添加子类的属性
@TableField(exist = false)//子类在数据库中不存在 private List2.配置网关路由和路径重写 (1).前端页面编写children;
启动前后端,在后台管理系统的 系统管理-> 菜单管理中 添加商品菜单及其分类
在moudles下新建product文件夹新建procuct.vue
成功
(2).修改路径,访问网关测试验证码
登录时的验证码是请求renrnefast模块的,所以需要将renrenfast注册到注册中心中
注册成功
设置路由
(3).跨域解决方法:
- nginx
- 配置响应头
在网关中配置允许跨域
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
@Configuration
public class MyCrosConfig {
@Bean
public CorsWebFilter CorsWebFilter(){
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration corsConfiguration = new CorsConfiguration();
// 这里配置跨域
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.setAllowCredentials(true);
source.registerCorsConfiguration("
@Override
public boolean isValid(Integer value, ConstraintValidatorContext context) {
return set.contains(value);
}
}
注解绑定校验器



