vue3配置代理实现axios请求本地接口返回PG库数据【前后端实操】

news/2025/3/25 23:23:13/

前端编写

安装 axios

如果当前未安装axios,可以执行如下指令安装

npm install axios

配置代理

当前为基于Vite构建的项目,在 vite.config.ts 中配置代理,在defineConfig中新增server配置,主要关注两个点:
一、需要代理的url开头,此处为/asset
二、代理的目标IP以及端口号,此处为http://localhost:8888

typescript">// vite.config.ts
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';export default defineConfig({plugins: [vue()],server: {proxy: {'/asset': { // 以 '/asset' 开头的请求会被代理target: 'http://localhost:8888', // 后端服务器地址changeOrigin: true, // 允许跨域rewrite: (path) => path.replace(/^\/asset/, '') // 重写路径,去掉 '/asset'}}}
});

如果你的项目基于Vue CLI构建,可在vue.config.js添加

javascript">// vue.config.js
const { defineConfig } = require('@vue/cli-service');module.exports = defineConfig({devServer: {proxy: {'/asset': {  // 以 '/asset' 开头的请求会被代理target: 'http://localhost:8888',  // 后端服务器地址changeOrigin: true,  // 允许跨域pathRewrite: {'^/asset': ''  // 重写路径,去掉 '/asset'}}}}
});

前端代码编写

此处使用ts&vue3写法,由于使用原生axios写法,没有封装通用的请求js(后续博客完善),导致此处解析响应会比较绕
const assetInfoList = result?.data?.data?.assetInfoList

<script setup lang="ts">javascript">
import { ref } from 'vue'
import axios from 'axios'const isUseLocalFlag = ref(true)
const setTabData = async function () {if (isUseLocalFlag.value) {const bizId = '0777c40218114c35a29b0d4d84355668'await axios.post(`/asset/assetInfo/${bizId}/byBizId`).then(result => {if (result.status === 200) {const assetInfoList = result?.data?.data?.assetInfoListconsole.log('assetInfoList', assetInfoList)}})} else {// 请求mock数据}
}
</script><template><div>数据源选择:</div><el-switchv-model="isUseLocalFlag"active-text="使用本地服务数据"inactive-text="使用mock数据"/><el-button @click="setTabData" style="margin-left: 10px;">给tab赋值</el-button>
</template><style scoped></style>

后端编写

pgsql建表&测试数据填充

-- 资产信息表创建
CREATE TABLE IF NOT EXISTS t_asset_info (asset_number varchar(100) COLLATE pg_catalog.default NOT NULL,asset_status varchar(10) COLLATE pg_catalog.default,use_dept_code varchar(100) COLLATE pg_catalog.default,create_time timestamp(0),create_by_uuid varchar(32) COLLATE pg_catalog.default,create_by_account varchar(32) COLLATE pg_catalog.default,create_by_name varchar(100) COLLATE pg_catalog.default,last_update_time timestamp(0),last_update_uuid varchar(32) COLLATE pg_catalog.default,last_update_account varchar(32) COLLATE pg_catalog.default,last_update_name varchar(100) COLLATE pg_catalog.default,ext_attribute1 varchar(255) COLLATE pg_catalog.default,ext_attribute2 varchar(255) COLLATE pg_catalog.default,ext_attribute3 varchar(255) COLLATE pg_catalog.default,ext_attribute4 varchar(255) COLLATE pg_catalog.default,ext_attribute5 varchar(255) COLLATE pg_catalog.default,ext_attribute6 varchar(255) COLLATE pg_catalog.default,ext_attribute7 varchar(255) COLLATE pg_catalog.default,ext_attribute8 varchar(255) COLLATE pg_catalog.default,ext_attribute9 varchar(255) COLLATE pg_catalog.default,ext_attribute10 varchar(255) COLLATE pg_catalog.default,ext_attribute11 varchar(255) COLLATE pg_catalog.default,ext_attribute12 varchar(255) COLLATE pg_catalog.default,ext_attribute13 varchar(255) COLLATE pg_catalog.default,ext_attribute14 varchar(255) COLLATE pg_catalog.default,ext_attribute15 varchar(255) COLLATE pg_catalog.default,ext_attribute16 varchar(255) COLLATE pg_catalog.default,ext_attribute17 varchar(255) COLLATE pg_catalog.default,ext_attribute18 varchar(255) COLLATE pg_catalog.default,ext_attribute19 varchar(255) COLLATE pg_catalog.default,ext_attribute20 varchar(255) COLLATE pg_catalog.default,biz_id varchar(32) COLLATE pg_catalog.default DEFAULT ''::character varying,CONSTRAINT asset_info_pkey PRIMARY KEY (asset_number)
)
;ALTER TABLE t_asset_info OWNER TO postgres;COMMENT ON COLUMN t_asset_info.asset_number IS '资产编号';COMMENT ON COLUMN t_asset_info.asset_status IS '资产状态
10:正常
20:使用
30:闲置
40:报废
50:封存
60:盘点中
70:在途';COMMENT ON COLUMN t_asset_info.use_dept_code IS '使用部门名称';COMMENT ON COLUMN t_asset_info.create_time IS '创建时间';COMMENT ON COLUMN t_asset_info.create_by_uuid IS '创建人uuid';COMMENT ON COLUMN t_asset_info.create_by_account IS '创建人账号';COMMENT ON COLUMN t_asset_info.create_by_name IS '创建人名称';COMMENT ON COLUMN t_asset_info.last_update_time IS '最后更新时间';COMMENT ON COLUMN t_asset_info.last_update_uuid IS '最后跟新人uuid';COMMENT ON COLUMN t_asset_info.last_update_account IS '最后更新人账号';COMMENT ON COLUMN t_asset_info.last_update_name IS '最后更新人名称';COMMENT ON COLUMN t_asset_info.ext_attribute1 IS '拓展属性1';COMMENT ON COLUMN t_asset_info.ext_attribute2 IS '拓展属性2';COMMENT ON COLUMN t_asset_info.ext_attribute3 IS '拓展属性3';COMMENT ON COLUMN t_asset_info.ext_attribute4 IS '拓展属性4';COMMENT ON COLUMN t_asset_info.ext_attribute5 IS '拓展属性5';COMMENT ON COLUMN t_asset_info.ext_attribute6 IS '拓展属性6';COMMENT ON COLUMN t_asset_info.ext_attribute7 IS '拓展属性7';COMMENT ON COLUMN t_asset_info.ext_attribute8 IS '拓展属性8';COMMENT ON COLUMN t_asset_info.ext_attribute9 IS '拓展属性9';COMMENT ON COLUMN t_asset_info.ext_attribute10 IS '拓展属性10';COMMENT ON COLUMN t_asset_info.ext_attribute11 IS '拓展属性11';COMMENT ON COLUMN t_asset_info.ext_attribute12 IS '拓展属性12';COMMENT ON COLUMN t_asset_info.ext_attribute13 IS '拓展属性13';COMMENT ON COLUMN t_asset_info.ext_attribute14 IS '拓展属性14';COMMENT ON COLUMN t_asset_info.ext_attribute15 IS '拓展属性15';COMMENT ON COLUMN t_asset_info.ext_attribute16 IS '拓展属性16';COMMENT ON COLUMN t_asset_info.ext_attribute17 IS '拓展属性17';COMMENT ON COLUMN t_asset_info.ext_attribute18 IS '拓展属性18';COMMENT ON COLUMN t_asset_info.ext_attribute19 IS '拓展属性19';COMMENT ON COLUMN t_asset_info.ext_attribute20 IS '拓展属性20';COMMENT ON COLUMN t_asset_info.biz_id IS '业务ID';COMMENT ON TABLE t_asset_info IS '资产信息表';
-- 资产信息表插入测试数据
INSERT INTO t_asset_info (asset_number, asset_status, use_dept_code, create_time, create_by_uuid, create_by_account, create_by_name, last_update_time, last_update_uuid, last_update_account, last_update_name, ext_attribute1, ext_attribute2, ext_attribute3, ext_attribute4, ext_attribute5, ext_attribute6, ext_attribute7, ext_attribute8, ext_attribute9, ext_attribute10, ext_attribute11, ext_attribute12, ext_attribute13, ext_attribute14, ext_attribute15, ext_attribute16, ext_attribute17, ext_attribute18, ext_attribute19, ext_attribute20, biz_id) VALUES ('03f7744cb08fbf23c5e3a49038b741d9', '60', '00-dept-34', '2025-02-16 21:55:22', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', '2025-02-17 22:29:29', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', 'ext_attribute1', 'ext_attribute2', 'ext_attribute3', 'ext_attribute4', 'ext_attribute5', 'ext_attribute6', 'ext_attribute7', 'ext_attribute8', 'ext_attribute9', 'ext_attribute10', 'ext_attribute11', 'ext_attribute12', 'ext_attribute13', 'ext_attribute14', 'ext_attribute15', 'ext_attribute16', 'ext_attribute17', 'ext_attribute18', 'ext_attribute19', 'ext_attribute20', '0777c40218114c35a29b0d4d84355668');
INSERT INTO t_asset_info (asset_number, asset_status, use_dept_code, create_time, create_by_uuid, create_by_account, create_by_name, last_update_time, last_update_uuid, last_update_account, last_update_name, ext_attribute1, ext_attribute2, ext_attribute3, ext_attribute4, ext_attribute5, ext_attribute6, ext_attribute7, ext_attribute8, ext_attribute9, ext_attribute10, ext_attribute11, ext_attribute12, ext_attribute13, ext_attribute14, ext_attribute15, ext_attribute16, ext_attribute17, ext_attribute18, ext_attribute19, ext_attribute20, biz_id) VALUES ('0777c40218114c35a29b0d4d8435520e', '10', '00-dept-36', '2025-02-16 21:55:22', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', '2025-02-17 22:29:29', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', 'ext_attribute1', 'ext_attribute2', 'ext_attribute3', 'ext_attribute4', 'ext_attribute5', 'ext_attribute6', 'ext_attribute7', 'ext_attribute8', 'ext_attribute9', 'ext_attribute10', 'ext_attribute11', 'ext_attribute12', 'ext_attribute13', 'ext_attribute14', 'ext_attribute15', 'ext_attribute16', 'ext_attribute17', 'ext_attribute18', 'ext_attribute19', 'ext_attribute20', '0777c40218114c35a29b0d4d84355668');
INSERT INTO t_asset_info (asset_number, asset_status, use_dept_code, create_time, create_by_uuid, create_by_account, create_by_name, last_update_time, last_update_uuid, last_update_account, last_update_name, ext_attribute1, ext_attribute2, ext_attribute3, ext_attribute4, ext_attribute5, ext_attribute6, ext_attribute7, ext_attribute8, ext_attribute9, ext_attribute10, ext_attribute11, ext_attribute12, ext_attribute13, ext_attribute14, ext_attribute15, ext_attribute16, ext_attribute17, ext_attribute18, ext_attribute19, ext_attribute20, biz_id) VALUES ('2d72bf99ebcad018297aed761b5dee8d', '10', '00-dept-29', '2025-02-16 21:55:22', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', '2025-02-17 22:29:29', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', 'ext_attribute1', 'ext_attribute2', 'ext_attribute3', 'ext_attribute4', 'ext_attribute5', 'ext_attribute6', 'ext_attribute7', 'ext_attribute8', 'ext_attribute9', 'ext_attribute10', 'ext_attribute11', 'ext_attribute12', 'ext_attribute13', 'ext_attribute14', 'ext_attribute15', 'ext_attribute16', 'ext_attribute17', 'ext_attribute18', 'ext_attribute19', 'ext_attribute20', '0777c40218114c35a29b0d4d84355668');
INSERT INTO t_asset_info (asset_number, asset_status, use_dept_code, create_time, create_by_uuid, create_by_account, create_by_name, last_update_time, last_update_uuid, last_update_account, last_update_name, ext_attribute1, ext_attribute2, ext_attribute3, ext_attribute4, ext_attribute5, ext_attribute6, ext_attribute7, ext_attribute8, ext_attribute9, ext_attribute10, ext_attribute11, ext_attribute12, ext_attribute13, ext_attribute14, ext_attribute15, ext_attribute16, ext_attribute17, ext_attribute18, ext_attribute19, ext_attribute20, biz_id) VALUES ('3d4c487a1679c70f61b0aa3dd5a1733a', '60', '00-dept-27', '2025-02-16 21:55:22', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', '2025-02-17 22:29:29', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', 'ext_attribute1', 'ext_attribute2', 'ext_attribute3', 'ext_attribute4', 'ext_attribute5', 'ext_attribute6', 'ext_attribute7', 'ext_attribute8', 'ext_attribute9', 'ext_attribute10', 'ext_attribute11', 'ext_attribute12', 'ext_attribute13', 'ext_attribute14', 'ext_attribute15', 'ext_attribute16', 'ext_attribute17', 'ext_attribute18', 'ext_attribute19', 'ext_attribute20', '0777c40218114c35a29b0d4d84355668');
INSERT INTO t_asset_info (asset_number, asset_status, use_dept_code, create_time, create_by_uuid, create_by_account, create_by_name, last_update_time, last_update_uuid, last_update_account, last_update_name, ext_attribute1, ext_attribute2, ext_attribute3, ext_attribute4, ext_attribute5, ext_attribute6, ext_attribute7, ext_attribute8, ext_attribute9, ext_attribute10, ext_attribute11, ext_attribute12, ext_attribute13, ext_attribute14, ext_attribute15, ext_attribute16, ext_attribute17, ext_attribute18, ext_attribute19, ext_attribute20, biz_id) VALUES ('4f22a0a4fe1a8ccc5916718cd1049241', '70', '00-dept-28', '2025-02-16 21:55:22', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', '2025-02-17 22:29:29', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', 'ext_attribute1', 'ext_attribute2', 'ext_attribute3', 'ext_attribute4', 'ext_attribute5', 'ext_attribute6', 'ext_attribute7', 'ext_attribute8', 'ext_attribute9', 'ext_attribute10', 'ext_attribute11', 'ext_attribute12', 'ext_attribute13', 'ext_attribute14', 'ext_attribute15', 'ext_attribute16', 'ext_attribute17', 'ext_attribute18', 'ext_attribute19', 'ext_attribute20', '0777c40218114c35a29b0d4d84355668');
INSERT INTO t_asset_info (asset_number, asset_status, use_dept_code, create_time, create_by_uuid, create_by_account, create_by_name, last_update_time, last_update_uuid, last_update_account, last_update_name, ext_attribute1, ext_attribute2, ext_attribute3, ext_attribute4, ext_attribute5, ext_attribute6, ext_attribute7, ext_attribute8, ext_attribute9, ext_attribute10, ext_attribute11, ext_attribute12, ext_attribute13, ext_attribute14, ext_attribute15, ext_attribute16, ext_attribute17, ext_attribute18, ext_attribute19, ext_attribute20, biz_id) VALUES ('6ac629baf0e5af838433f7d48751cbbc', '50', '00-dept-33', '2025-02-16 21:55:22', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', '2025-02-17 22:29:29', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', 'ext_attribute1', 'ext_attribute2', 'ext_attribute3', 'ext_attribute4', 'ext_attribute5', 'ext_attribute6', 'ext_attribute7', 'ext_attribute8', 'ext_attribute9', 'ext_attribute10', 'ext_attribute11', 'ext_attribute12', 'ext_attribute13', 'ext_attribute14', 'ext_attribute15', 'ext_attribute16', 'ext_attribute17', 'ext_attribute18', 'ext_attribute19', 'ext_attribute20', '0777c40218114c35a29b0d4d84355668');
INSERT INTO t_asset_info (asset_number, asset_status, use_dept_code, create_time, create_by_uuid, create_by_account, create_by_name, last_update_time, last_update_uuid, last_update_account, last_update_name, ext_attribute1, ext_attribute2, ext_attribute3, ext_attribute4, ext_attribute5, ext_attribute6, ext_attribute7, ext_attribute8, ext_attribute9, ext_attribute10, ext_attribute11, ext_attribute12, ext_attribute13, ext_attribute14, ext_attribute15, ext_attribute16, ext_attribute17, ext_attribute18, ext_attribute19, ext_attribute20, biz_id) VALUES ('7396d84b53bc253123ce149aae367227', '30', '00-dept-31', '2025-02-16 21:55:22', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', '2025-02-17 22:29:29', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', 'ext_attribute1', 'ext_attribute2', 'ext_attribute3', 'ext_attribute4', 'ext_attribute5', 'ext_attribute6', 'ext_attribute7', 'ext_attribute8', 'ext_attribute9', 'ext_attribute10', 'ext_attribute11', 'ext_attribute12', 'ext_attribute13', 'ext_attribute14', 'ext_attribute15', 'ext_attribute16', 'ext_attribute17', 'ext_attribute18', 'ext_attribute19', 'ext_attribute20', '0777c40218114c35a29b0d4d84355668');
INSERT INTO t_asset_info (asset_number, asset_status, use_dept_code, create_time, create_by_uuid, create_by_account, create_by_name, last_update_time, last_update_uuid, last_update_account, last_update_name, ext_attribute1, ext_attribute2, ext_attribute3, ext_attribute4, ext_attribute5, ext_attribute6, ext_attribute7, ext_attribute8, ext_attribute9, ext_attribute10, ext_attribute11, ext_attribute12, ext_attribute13, ext_attribute14, ext_attribute15, ext_attribute16, ext_attribute17, ext_attribute18, ext_attribute19, ext_attribute20, biz_id) VALUES ('74fd3149eb6b63b4a05974644b12b9f7', '20', '00-dept-30', '2025-02-16 21:55:22', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', '2025-02-17 22:29:29', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', 'ext_attribute1', 'ext_attribute2', 'ext_attribute3', 'ext_attribute4', 'ext_attribute5', 'ext_attribute6', 'ext_attribute7', 'ext_attribute8', 'ext_attribute9', 'ext_attribute10', 'ext_attribute11', 'ext_attribute12', 'ext_attribute13', 'ext_attribute14', 'ext_attribute15', 'ext_attribute16', 'ext_attribute17', 'ext_attribute18', 'ext_attribute19', 'ext_attribute20', '0777c40218114c35a29b0d4d84355668');
INSERT INTO t_asset_info (asset_number, asset_status, use_dept_code, create_time, create_by_uuid, create_by_account, create_by_name, last_update_time, last_update_uuid, last_update_account, last_update_name, ext_attribute1, ext_attribute2, ext_attribute3, ext_attribute4, ext_attribute5, ext_attribute6, ext_attribute7, ext_attribute8, ext_attribute9, ext_attribute10, ext_attribute11, ext_attribute12, ext_attribute13, ext_attribute14, ext_attribute15, ext_attribute16, ext_attribute17, ext_attribute18, ext_attribute19, ext_attribute20, biz_id) VALUES ('a33fa6930899ca9b30ff93a95dedd11e', '70', '00-dept-35', '2025-02-16 21:55:22', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', '2025-02-17 22:29:29', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', 'ext_attribute1', 'ext_attribute2', 'ext_attribute3', 'ext_attribute4', 'ext_attribute5', 'ext_attribute6', 'ext_attribute7', 'ext_attribute8', 'ext_attribute9', 'ext_attribute10', 'ext_attribute11', 'ext_attribute12', 'ext_attribute13', 'ext_attribute14', 'ext_attribute15', 'ext_attribute16', 'ext_attribute17', 'ext_attribute18', 'ext_attribute19', 'ext_attribute20', '0777c40218114c35a29b0d4d84355668');
INSERT INTO t_asset_info (asset_number, asset_status, use_dept_code, create_time, create_by_uuid, create_by_account, create_by_name, last_update_time, last_update_uuid, last_update_account, last_update_name, ext_attribute1, ext_attribute2, ext_attribute3, ext_attribute4, ext_attribute5, ext_attribute6, ext_attribute7, ext_attribute8, ext_attribute9, ext_attribute10, ext_attribute11, ext_attribute12, ext_attribute13, ext_attribute14, ext_attribute15, ext_attribute16, ext_attribute17, ext_attribute18, ext_attribute19, ext_attribute20, biz_id) VALUES ('db06878e60b8db82c4412d11ff793d18', '40', '00-dept-32', '2025-02-16 21:55:22', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', '2025-02-17 22:29:29', 'pine_tree_uuid', 'pine_tree_account', 'pine_tree_name', 'ext_attribute1', 'ext_attribute2', 'ext_attribute3', 'ext_attribute4', 'ext_attribute5', 'ext_attribute6', 'ext_attribute7', 'ext_attribute8', 'ext_attribute9', 'ext_attribute10', 'ext_attribute11', 'ext_attribute12', 'ext_attribute13', 'ext_attribute14', 'ext_attribute15', 'ext_attribute16', 'ext_attribute17', 'ext_attribute18', 'ext_attribute19', 'ext_attribute20', '0777c40218114c35a29b0d4d84355668');

实体类新增

java">/*** <p>* 资产信息表* </p>** @author PineTree* @since 2025-02-16*/
@TableName("t_asset_info")
@ApiModel(value = "AssetInfo对象", description = "资产信息表")
@Data
public class AssetInfoDTO implements Serializable {private static final long serialVersionUID = 1L;@ApiModelProperty("资产编号")@TableId(value = "asset_number", type = IdType.ASSIGN_UUID)private String assetNumber;@ApiModelProperty("资产状态	10:正常	20:使用	30:闲置	40:报废	50:封存	60:盘点中	70:在途")private String assetStatus;@ApiModelProperty("使用部门名称")private String useDeptCode;@ApiModelProperty("创建时间")private LocalDateTime createTime;@ApiModelProperty("创建人uuid")private String createByUuid;@ApiModelProperty("创建人账号")private String createByAccount;@ApiModelProperty("创建人名称")private String createByName;@ApiModelProperty("最后更新时间")private LocalDateTime lastUpdateTime;@ApiModelProperty("最后跟新人uuid")private String lastUpdateUuid;@ApiModelProperty("最后更新人账号")private String lastUpdateAccount;@ApiModelProperty("最后更新人名称")private String lastUpdateName;@ApiModelProperty("拓展属性1")private String extAttribute1;@ApiModelProperty("拓展属性2")private String extAttribute2;@ApiModelProperty("拓展属性3")private String extAttribute3;@ApiModelProperty("拓展属性4")private String extAttribute4;@ApiModelProperty("拓展属性5")private String extAttribute5;@ApiModelProperty("拓展属性6")private String extAttribute6;@ApiModelProperty("拓展属性7")private String extAttribute7;@ApiModelProperty("拓展属性8")private String extAttribute8;@ApiModelProperty("拓展属性9")private String extAttribute9;@ApiModelProperty("拓展属性10")private String extAttribute10;@ApiModelProperty("拓展属性11")private String extAttribute11;@ApiModelProperty("拓展属性12")private String extAttribute12;@ApiModelProperty("拓展属性13")private String extAttribute13;@ApiModelProperty("拓展属性14")private String extAttribute14;@ApiModelProperty("拓展属性15")private String extAttribute15;@ApiModelProperty("拓展属性16")private String extAttribute16;@ApiModelProperty("拓展属性17")private String extAttribute17;@ApiModelProperty("拓展属性18")private String extAttribute18;@ApiModelProperty("拓展属性19")private String extAttribute19;@ApiModelProperty("拓展属性20")private String extAttribute20;@ApiModelProperty("业务ID")private String bizId;}

controller层代码编写

由于使用了mybatis-plus,调用了通用service查询逻辑,只需编写controller即可

java">/*** <p>* 资产信息表 前端控制器* </p>** @author PineTree* @since 2025-02-16*/
@RestController
@RequestMapping("/assetInfo")
public class AssetInfoController {@Resourceprivate IAssetInfoService assetInfoService;@PostMapping("{bizId}/byBizId")public Result getAssetInfoByBizId(@PathVariable("bizId") String bizId) {if (StringUtils.isEmpty(bizId)) {return Result.ok();}QueryWrapper<AssetInfoDTO> queryWrapper = new QueryWrapper<>();queryWrapper.eq("biz_id", bizId);List<AssetInfoDTO> assetInfoList = assetInfoService.list(queryWrapper);return Result.ok().data("assetInfoList", assetInfoList);}
}

postMan接口测试

启动本地后端,base_url为api collection维度的全局环境变量,此处设置为本地8888端口,可方便后续切换
在这里插入图片描述

联调

点击tab按钮,可以观察到成功从前端5173端口代理到8888并获取到了响应数据
在这里插入图片描述

代码仓

前端代码

https://gitee.com/pinetree-cpu/hello_vue3
master分支

后端代码

https://gitee.com/pinetree-cpu/parent-demon
pine_tree_dev分支

欢迎评论区留言&讨论


http://www.ppmy.cn/news/1582565.html

相关文章

IS-IS原理与配置

一、IS-IS概述 IS-IS&#xff08;Intermediate System to Intermediate System&#xff0c;中间系统到中间系统&#xff09;是ISO&#xff08;International Organization for Standardization&#xff0c;国际标准化组织&#xff09;为它的CLNP&#xff08;ConnectionLessNet…

2025年3月GESP八级真题解析

第一题——上学 题目描述 C 城可以视为由 n n n 个结点与 m m m 条边组成的无向图。这些结点依次以 1 , 2 , … , n 1,2,…,n 1,2,…,n 标号&#xff0c;边依次以 1 , 2 , … , m 1,2,…,m 1,2,…,m 标号。第 i i i 条边&#xff08; 1 ≤ i ≤ m 1≤i≤m 1≤i≤m&#…

深入理解 Redis SDS:高效字符串存储的秘密

目录 1. 引言 1.1 Redis 中字符串的广泛应用 2. SDS 结构定义 2.1 Redis 3.2 之前的 SDS 结构 2.2 Redis 3.2 及之后的 SDS 结构 3. SDS 与传统 C 字符串的比较 3.1 获取字符串长度 3.2 缓冲区溢出问题 3.3 二进制安全性 3.4 内存分配次数 4. SDS 的内存分配策略 4.…

Spring Boot分布式项目异常处理实战:从崩溃边缘到优雅恢复

当单体应用拆分成分布式系统&#xff0c;异常就像被打开的潘多拉魔盒&#xff1a;RPC调用超时、分布式事务雪崩、第三方接口突然罢工…在最近的电商大促中&#xff0c;我们的系统就经历了这样的至暗时刻。本文将用真实代码示例&#xff0c;展示如何构建分布式异常处理体系。 一…

路由Vue Router基本用法

路由的作用是根据URL来匹配对应的组件&#xff0c;并且无刷新切换模板的内容。vue.js中&#xff0c;可使用Vue Router来管理路由&#xff0c;让构建单页应用更加简单。 一、效果 二、实现 1.项目中安装Vue Router插件 pnpm install vue-routerlastest 2.main.js import { …

数据结构:二叉树(二)·(重点)

前言 文章结尾有彩蛋哦~~ 前面我们已经知道了什么是树&#xff0c;树是⼀种⾮线性的数据结构&#xff0c;它是由 n &#xff08; n>0 &#xff09; 个有限结点组成⼀个具有层次关系的集合。 那么这篇文章就让我们来了解一下什么是二叉树吧&#xff01; 二叉树的概念与结…

2025年01月02日浙江鼎永前端面试

目录 webpack 和 vite 区别react fiber 架构vue diff 算法react diff 算法hooks 源码垂直水平布局项目介绍单点登录大文件上传微前端 1. webpack 和 vite 区别 Webpack 和 Vite 是两种不同的前端构建工具&#xff0c;它们在设计理念、性能表现和使用场景上存在显著差异。以下…

最近比突出的DeepSeek与ChatGPT的详细比较分析

引言 随着人工智能技术的快速发展&#xff0c;自然语言处理&#xff08;NLP&#xff09;领域涌现出了许多强大的模型和工具。DeepSeek和ChatGPT作为其中的代表&#xff0c;各自在特定领域和应用场景中展现了卓越的性能。本文将从多个维度对DeepSeek和ChatGPT进行比较分析&…