最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue3配置代理實現(xiàn)axios請求本地接口返回PG庫數(shù)據(jù)

 更新時間:2025年03月23日 11:45:25   作者:松樹戈  
這篇文章主要為大家詳細介紹了vue3配置代理實現(xiàn)axios請求本地接口返回PG庫數(shù)據(jù)的相關(guān)知識,文中的示例代碼講解詳細,感興趣的小伙伴可以了解下

前端編寫

安裝 axios

如果當前未安裝axios,可以執(zhí)行如下指令安裝

npm install axios

配置代理

當前為基于Vite構(gòu)建的項目,在 vite.config.ts 中配置代理,在defineConfig中新增server配置,主要關(guān)注兩個點:

一、需要代理的url開頭,此處為/asset

二、代理的目標IP以及端口號,此處為http://localhost:8888

// 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構(gòu)建,可在vue.config.js添加

// 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(后續(xù)博客完善),導致此處解析響應會比較繞

const assetInfoList = result?.data?.data?.assetInfoList

<script setup lang="ts">
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?.assetInfoList
        console.log('assetInfoList', assetInfoList)
      }
    })
  } else {
    // 請求mock數(shù)據(jù)
  }
}
</script>

<template>
  <div>
    數(shù)據(jù)源選擇:
  </div>
  <el-switch
      v-model="isUseLocalFlag"
      active-text="使用本地服務數(shù)據(jù)"
      inactive-text="使用mock數(shù)據(jù)"
  />
  <el-button @click="setTabData" style="margin-left: 10px;">給tab賦值</el-button>
</template>

<style scoped>

</style>

后端編寫

pgsql建表&測試數(shù)據(jù)填充

-- 資產(chǎn)信息表創(chuàng)建
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 '資產(chǎn)編號';

COMMENT ON COLUMN t_asset_info.asset_status IS '資產(chǎn)狀態(tài)
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 '創(chuàng)建時間';

COMMENT ON COLUMN t_asset_info.create_by_uuid IS '創(chuàng)建人uuid';

COMMENT ON COLUMN t_asset_info.create_by_account IS '創(chuàng)建人賬號';

COMMENT ON COLUMN t_asset_info.create_by_name IS '創(chuàng)建人名稱';

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 '業(yè)務ID';

COMMENT ON TABLE t_asset_info IS '資產(chǎn)信息表';
-- 資產(chǎn)信息表插入測試數(shù)據(jù)
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');

實體類新增

/**
 * <p>
 * 資產(chǎn)信息表
 * </p>
 *
 * @author PineTree
 * @since 2025-02-16
 */
@TableName("t_asset_info")
@ApiModel(value = "AssetInfo對象", description = "資產(chǎn)信息表")
@Data
public class AssetInfoDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("資產(chǎn)編號")
    @TableId(value = "asset_number", type = IdType.ASSIGN_UUID)
    private String assetNumber;

    @ApiModelProperty("資產(chǎn)狀態(tài)	10:正常	20:使用	30:閑置	40:報廢	50:封存	60:盤點中	70:在途")
    private String assetStatus;

    @ApiModelProperty("使用部門名稱")
    private String useDeptCode;

    @ApiModelProperty("創(chuàng)建時間")
    private LocalDateTime createTime;

    @ApiModelProperty("創(chuàng)建人uuid")
    private String createByUuid;

    @ApiModelProperty("創(chuàng)建人賬號")
    private String createByAccount;

    @ApiModelProperty("創(chuàng)建人名稱")
    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("業(yè)務ID")
    private String bizId;

}

controller層代碼編寫

由于使用了mybatis-plus,調(diào)用了通用service查詢邏輯,只需編寫controller即可

/**
 * <p>
 * 資產(chǎn)信息表 前端控制器
 * </p>
 *
 * @author PineTree
 * @since 2025-02-16
 */
@RestController
@RequestMapping("/assetInfo")
public class AssetInfoController {

???????    @Resource
    private 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維度的全局環(huán)境變量,此處設置為本地8888端口,可方便后續(xù)切換

聯(lián)調(diào)

點擊tab按鈕,可以觀察到成功從前端5173端口代理到8888并獲取到了響應數(shù)據(jù)

到此這篇關(guān)于vue3配置代理實現(xiàn)axios請求本地接口返回PG庫數(shù)據(jù)的文章就介紹到這了,更多相關(guān)vue3 axios請求本地接口內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 關(guān)于vue雙向綁定帶來的問題及解決

    關(guān)于vue雙向綁定帶來的問題及解決

    這篇文章主要介紹了關(guān)于vue雙向綁定帶來的問題及解決,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • vue腳手架創(chuàng)建項目時報catch錯誤及解決

    vue腳手架創(chuàng)建項目時報catch錯誤及解決

    這篇文章主要介紹了vue腳手架創(chuàng)建項目時報catch錯誤及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-01-01
  • vue中使用rem布局代碼詳解

    vue中使用rem布局代碼詳解

    在本篇文章里小編給大家整理的是關(guān)于vue中使用rem布局代碼詳解知識點,需要的朋友們參考下。
    2019-10-10
  • vue3頁面query參數(shù)變化并重新加載頁面數(shù)據(jù)方式

    vue3頁面query參數(shù)變化并重新加載頁面數(shù)據(jù)方式

    在Web開發(fā)中,頁面間的跳轉(zhuǎn)及數(shù)據(jù)刷新是常見問題,通過使用$router.push和$router.replace方法,可以控制頁面跳轉(zhuǎn)的行為,具體操作時,若發(fā)現(xiàn)頁面ID變更后數(shù)據(jù)未刷新,可通過給router-view標簽添加key值解決,若使用keep-alive
    2024-10-10
  • Vue 動態(tài)組件與 v-once 指令的實現(xiàn)

    Vue 動態(tài)組件與 v-once 指令的實現(xiàn)

    這篇文章主要介紹了Vue 動態(tài)組件與 v-once 指令的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-02-02
  • vuex的核心概念和基本使用詳解

    vuex的核心概念和基本使用詳解

    這篇文章主要為大家介紹了vuex的核心概念和基本使用,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2021-12-12
  • vue中使用axios固定url請求前綴

    vue中使用axios固定url請求前綴

    這篇文章主要介紹了vue中使用axios固定url請求前綴的實現(xiàn)方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • vue 項目中的this.$get,this.$post等$的用法案例詳解

    vue 項目中的this.$get,this.$post等$的用法案例詳解

    vue.js的插件應該暴露一個install方法。這個方法的第一個參數(shù)是vue構(gòu)造器,第二個參數(shù)是一個可選的選項對象,首頁要安裝axios,本文結(jié)合案例代碼給大家詳細講解vue 中的this.$get,this.$post等$的用法,一起學習下吧
    2022-12-12
  • vue對象復制方式(深拷貝,多層對象拷貝方式在后面)

    vue對象復制方式(深拷貝,多層對象拷貝方式在后面)

    這篇文章主要介紹了vue對象復制方式(深拷貝,多層對象拷貝方式在后面),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • Vue跳轉(zhuǎn)頁面的幾種常用方法總結(jié)

    Vue跳轉(zhuǎn)頁面的幾種常用方法總結(jié)

    在Vue.js中,頁面跳轉(zhuǎn)是構(gòu)建單頁面應用(SPA)的基本操作之一,本文將介紹Vue中實現(xiàn)頁面跳轉(zhuǎn)的幾種方法,并通過實例代碼幫助理解每種方法的用法,需要的朋友可以參考下
    2024-09-09

最新評論

青铜峡市| 临海市| 垫江县| 东方市| 邻水| 搜索| 永川市| 离岛区| 吉安县| 新龙县| 玉门市| 长葛市| 蛟河市| 雷山县| 黄冈市| 沙坪坝区| 巴中市| 新野县| 开阳县| 望城县| 开鲁县| 科技| 莎车县| 双柏县| 肃南| 当雄县| 海门市| 屯留县| 苍山县| 远安县| 宁晋县| 太谷县| 上虞市| 子洲县| 天水市| 大冶市| 丹棱县| 新野县| 莱西市| 乐平市| 英超|