递归调用获取树形结构 (45集)
使用springgateway进行统一的接受请求(第46集)
1、springgateway注册到注册中心里去
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- 配置中心来做配置管理-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
2、 修改路由规则
- id: admin_route
uri: lb://renren-fast
predicates:
- Path=/api/**
filters:
- RewritePath=/api/(?<segment>.*),/renren-fast/$\{segment}
客户端改为请求http://localhost:88/api/captcha.jpg?uuid=959c3c92-9afa-48b6-88b4-49575eeb7f94
经过springgateway处理后变为:http://localhost:8080/renren-fast/captcha.jpg?uuid=959c3c92-9afa-48b6-88b4-49575eeb7f94
解决跨域问题(第47集)
跨域引起的原因,老师讲的有点复杂,可以参考这位博主的博客:什么是跨域? 出现原因及解决方法-CSDN博客
在gateway中添加跨域
idea快捷键:双击shift可以进入全局搜索
idea快捷键 crtl+H可以看到当前接口的实现类
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 GulimallCorsConfiguration {
@Bean
public CorsWebFilter corsWebFilter(){
UrlBasedCorsConfigurationSource Source=new UrlBasedCorsConfigurationSource;
CorsConfiguration corsConfiguration=new CorsConfiguration();
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedMethod("*");
corsConfiguration.setAllowCredentials(true);
Source.registerCorsConfiguration("/**",corsConfiguration);
return new CorsWebFilter(Source);
}
}
第48集:将商品服务加入nacos中,修改前端代码(简单省略)
第49集:修改前端代码,省略
第50集:
@RequestBody需要获取请求体,只有post请求才有请求体
//TODO 语句可以在idea中定位查看
配置逻辑删除 在DAO层(CategoryEntity)配置注解
@TableLogic(value = "1",delval = "0")
开启debug数据库日志打印到终端的配置
logging:
level:
com.buu.gulimall: debug
第51删除数据,简单 跳过
第52集 增加数据 ,简单 跳过
第53集配置前端edit 回显数据,简单 跳过
第54,55集 纯前端配置拖拽功能
第56集 前端配置拖拽功能 Arrays.asList() 数组转集合
第57集 纯前端,实现批量拖拽效果
第58集 批量删除 纯前端省略
第59集 纯前端,如果前端代码直接用老师的会有报错,意思就是缺少两个文件category-cascader,singleUpload 。(../common/category-cascader)(components/upload/singleUpload )这两个是路径,所以把这两的文件所在的文件夹放入就正确了。
1、../common/category-cascader in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/views/modules/product/brand.vue
2、 @/components/upload/singleUpload
第60集 纯前端 省略