1.网关路由配置 application.yml
(1) 遇到问题配置网关路由完成后,访问路径200但是没有数据
解决办法:将pom.xml中引用的common去掉,重新写nacos依赖。
spring:
cloud:
gateway:
routes:
# - id: test_route
# uri: https://www.baidu.com
# predicates:
# - Query=url,baidu
#
# - id: qq_route
# uri: https://www.qq.com
# predicates:
# - Query=url,qq
#更精确的网关路由放在前面
- id: product-route
uri: lb://gulimall-product
predicates:
- Path=/api/product/**
filters:
- RewritePath=/api/(?<segment>.*),/$\{segment}
- id: admin_route
uri: lb://renren-fast
predicates:
- Path=/api/**
filters:
- RewritePath=/api/(?<segment>.*), /renren-fast/$\{segment}
# predicates:
# - Path=/api/**
# filters:
# - RewritePath=/api/(?<segment>.*), /renren-fast/$\{segment}
#lb:负载均衡 rewritePath 重写路径
#前端项目 /api
#http://localhost:88/api/captcha.jpg 网关转成了 http:renren-fast:8080/api/captcha.jpg
# 真正能访问的是: http://localhost:8080/renren-fast/captcha.jpg
2.前端 删除
(1)前端访问商品分类菜单不跳转
解决方法:不适用vscode自动生成的vue模板,按照已有的模板写就可以了
<template>
<el-tree
show-checkbox
node-key="id"
:expand-on-click-node="false"
:default-expanded-keys="expandedKeys"
:data="menus"
:props="defaultProps"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>{{ node.label }}</span>
<span>
<el-button
v-if="node.level <= 2"
type="text"
size="mini"
@click="() => append(data)"
>
Append
</el-button>
<el-button
v-if="node.childNodes.length == 0"
type="text"
size="mini"
@click="() => remove(node, data)"
>
Delete
</el-button>
</span>
</span>
</el-tree>
</template>
<script>
export default {
components: {},
data() {
return {
expandedKeys: [],
menus: [],
defaultProps: {
children: "children",
label: "name",
},
};
},
methods: {
getMenus() {
this.$http({
url: this.$http.adornUrl("/product/category/list"),
method: "get",
}).then(({ data }) => {
console.log("成功获取到菜单数据", data.data);
this.menus = data.data;
});
},
append(data) {
console.log("appen", data);
},
remove(node, data) {
console.log("remove1", node, data);
//消息提示
this.$confirm(`确定删除【${data.name}】`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
// 定义数组传ids
var ids = [data.id];
this.$http({
url: this.$http.adornUrl("/product/category/delete"),
method: "post",
data: this.$http.adornData(ids, false),
}).then(({ data }) => {
//提示消息删除成功
this.$message({
message: "菜单删除成功",
type: "success",
});
//要默认打开之前的id
this.getMenus();
this.expandedKeys = [node.data.parentId];
});
})
.catch(() => {});
},
},
created() {
this.getMenus();
},
mounted() {},
watch: {},
computed: {},
};
</script>
<!-- 这里或采用lang="less" -->
<style lang="scss">
</style>
3.mybatis-plus逻辑删除
yml
mybatis-plus:
global-config:
db-config:
logic-delete-value: 1
logic-not-delete-value: 0
实体类中 逻辑删除字段
@TableLogic(value = "1",delval ="0")