基於springboot vue的測試平台開發
一、前端Tree樹形控制項的append方法
在elementUI 樹控制項下有個append
方法,可以用來為Tree 中的一個節點追加一個子節點。
目前我們已經完成了樹列表的接口,可以在 append 方法中輸出一下傳入的 data 裡到底是什麼。
console.log('传入的node:' + JSON.stringify(data))
點擊頂層的預設節點,F12 檢視控制台,
@PostMapping("/add") public Result addNode(@RequestBody ApiModule node) { try { System.out.println(node); Long nodeId = apiModuleService.addNode(node); return Result.success(nodeId); } catch (Exception e) { return Result.fail(e.toString()); } }2. service 層
實作addNode 方法:
public Long addNode(ApiModule node) { node.setCreateTime(new Date()); node.setUpdateTime(new Date()); double pos = getNextLevelPos(node.getProjectId(), node.getLevel(), node.getId()); node.setPos(pos); node.setLevel(node.getLevel() + 1); node.setParentId(node.getId()); node.setName("ceshi111"); apiModuleDAO.insert(node); return node.getId(); }這裡就是依照上述想法來進行實現,setName 暫時用一個固定值代替,先看下新增介面是否可以正常實作。 這裡pos 處理稍微麻煩一點,這個是代表新增的這個節點處於的位置順序,所以抽出去新增了一個方法實作
getNextLevelPos:
private double getNextLevelPos(Long projectId, int level, Long nodeId) { // 查询项目下,同parentId下,所有节点 QueryWrapper<ApiModule> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("projectId", projectId) .eq("level", level + 1) .eq("parentId", nodeId) .orderByDesc("pos"); List<ApiModule> apiModules = apiModuleDAO.selectList(queryWrapper); if (!CollectionUtil.isEmpty(apiModules)) { // 不为空,获取最新的同级结点 pos 再加 1,作为下一个 return apiModules.get(0).getPos() + 1; } else { // 否则就是当前父节点里的第一个子结点,pos 直接为 1 return 1; } }查詢項目下,同parentId,所有節點數據,注意這裡的查詢條件。 .eq("level", level 1),當前層級1 作為子節點的層級.eq("parentId", nodeId),當前節點作為父節點#然後判斷查詢出來的結果,如果列表不為空,返回最新的一個子結點的pos 加上1,作為下一個子結點的位置。 否則,新增的節點就是目前父節點裡的第一個子節點,直接傳回 1 ,作為 pos 值。 三、前後端聯調前端寫好接口,然後頁面裡呼叫接口。
還有一個重要點,因為新增結點需要傳入 data,而現在實際進行新增操作的是handleNodeAdd
方法。所以需要在開啟對話框的時候,把 data 存下來。
於是,在return 裡新建一個字段currentNode: {}:
#在append 方法裡把data 賦值給currentNode:
這裡this.dialogStatus = 'create'就是顯示對話框。
2. 新增節點
在對話框裡輸入節點名稱,點選儲存,就好呼叫handleNodeAdd
方法來請求後端介面。
因為傳給後端的節點名稱是我們輸入的,所以這裡this.currentNode.name = this.form.nodeName即可。
要求成功後給個提示,然後清空表單,以免開啟對話方塊後顯示上一次的內容。
3.測試
測試一下功能是否正常,我把專案id=3 下的節點刪掉。
新增一個測試節點:
功能正常。
以上是springboot vue前後端介面測試樹結點新增功能的方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

JVM'SperformanceIsCompetitiveWithOtherRuntimes,operingabalanceOfspeed,安全性和生產性。 1)JVMUSESJITCOMPILATIONFORDYNAMICOPTIMIZAIZATIONS.2)c提供NativePernativePerformanceButlanceButlactsjvm'ssafetyFeatures.3)

JavaachievesPlatFormIndependencEthroughTheJavavIrtualMachine(JVM),允許CodeTorunonAnyPlatFormWithAjvm.1)codeisscompiledIntobytecode,notmachine-specificodificcode.2)bytecodeisisteredbytheybytheybytheybythejvm,enablingcross-platerssectectectectectross-eenablingcrossectectectectectection.2)

TheJVMisanabstractcomputingmachinecrucialforrunningJavaprogramsduetoitsplatform-independentarchitecture.Itincludes:1)ClassLoaderforloadingclasses,2)RuntimeDataAreafordatastorage,3)ExecutionEnginewithInterpreter,JITCompiler,andGarbageCollectorforbytec

JVMhasacloserelationshipwiththeOSasittranslatesJavabytecodeintomachine-specificinstructions,managesmemory,andhandlesgarbagecollection.ThisrelationshipallowsJavatorunonvariousOSenvironments,butitalsopresentschallengeslikedifferentJVMbehaviorsandOS-spe

Java實現“一次編寫,到處運行”通過編譯成字節碼並在Java虛擬機(JVM)上運行。 1)編寫Java代碼並編譯成字節碼。 2)字節碼在任何安裝了JVM的平台上運行。 3)使用Java原生接口(JNI)處理平台特定功能。儘管存在挑戰,如JVM一致性和平台特定庫的使用,但WORA大大提高了開發效率和部署靈活性。

JavaachievesPlatFormIndependencethroughTheJavavIrtualMachine(JVM),允許Codetorunondifferentoperatingsystemsswithoutmodification.thejvmcompilesjavacodeintoplatform-interploplatform-interpectentbybyteentbytybyteentbybytecode,whatittheninternterninterpretsandectectececutesoneonthepecificos,atrafficteyos,Afferctinginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginging

JavaispoperfulduetoitsplatFormitiondence,對象與偏見,RichstandardLibrary,PerformanceCapabilities和StrongsecurityFeatures.1)Platform-dimplighandependectionceallowsenceallowsenceallowsenceallowsencationSapplicationStornanyDevicesupportingJava.2)

Java的頂級功能包括:1)面向對象編程,支持多態性,提升代碼的靈活性和可維護性;2)異常處理機制,通過try-catch-finally塊提高代碼的魯棒性;3)垃圾回收,簡化內存管理;4)泛型,增強類型安全性;5)ambda表達式和函數式編程,使代碼更簡潔和表達性強;6)豐富的標準庫,提供優化過的數據結構和算法。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3 Linux新版
SublimeText3 Linux最新版

SublimeText3漢化版
中文版,非常好用

Dreamweaver CS6
視覺化網頁開發工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)