个人笔记谷粒商城项目---(45集~60集)

递归调用获取树形结构 (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集 纯前端 省略

  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值