How to implement springboot vue interface test definition editing function
1. Backend
The backend needs to add 2 interfaces: query and update the interface according to the interface ID.
1. Query interface
@GetMapping("/getApi") public Result getApiById(Long id) { return Result.success(apiDefinitionService.getApi(id)); }
mybatis-plus has a direct query method using idselectById
:
public ApiDefinition getApi(Long id) { return apiDefinitionDAO.selectById(id); }
This query interface is not behind the path The splicing parameters are just used for debugging of my later functions.
2. Update the interface
ApiDefinitionController Continue to add the editing request processing method:
@PostMapping("/update") public Result update(@RequestBody ApiDefinition request) { try { apiDefinitionService.update(request); return Result.success(); } catch (Exception e) { return Result.fail(e.toString()); } }
Then implement it in the ApiDefinitionService:
public void update(ApiDefinition request) { QueryWrapper<ApiDefinition> wrapper = new QueryWrapper<>(); wrapper.eq("id", request.getId()); request.setUpdateTime(new Date()); apiDefinitionDAO.update(request, wrapper); }
First use the passed in id to query the data, and then update apiDefinitionDAO.update(request, wrapper)
.
2. Front-end
1. Implement editing display
Click the [Edit] button in the interface list to open the dialog box and display the data of the interface.
Add a binding event method handleApiUpdate
on the [Edit] button of the interface list.
# Also don’t forget to add the query interface you want to request. I won’t go into details about this subsequent step.
In the handleApiUpdate
method, explicit display is implemented.
#But a problem was discovered when assigning the request returned by the interface to the page. Because there are 3 tabs, I need to know which tab is returned by the backend.
Decided to add a fieldrequestType
:Parameter type (0:query, 1:rest,2:body)
.
The corresponding request parameters of the new interface must also be added:
So where does the value of this field come from? Coming?
There is an event in the component, which will be triggered when the tab is clicked, then assign the value in this method That’s it.
checkRequestNull Used to check whether the value in the current tab is empty:
here domains[0].keyJudge? Because there is an empty node by default, and the length of the data is also 1 when not filled in, so I changed it to judge the respective keys.
saveApiSave the request method of the interface, add the above request parameter judgment, pay attention to the position:
this.activeName, you can display the corresponding tab. Look at the above, there is a new field
id, which is used to save the interface id returned by the interface. It needs to be passed to the backend when editing. interface.
apiDefinitionDialogStatus, when clicked, it is judged whether to call a new interface or an edit interface. The default is
create.
This field has been used in the handleApiUpdate
method of clicking [Edit], open the dialog box, and then assign the value to update
:
Then modify the click event of the save button of the dialog box. When the value is equal to create
, call saveApi()
, otherwise call updateApi()
.
Implement the updateApi
method to perform update operations.
Before this, I need to add a field to the request object, which is the interface id, because the backend needs to use the id to query this data in the library.
Correspondingly, in the request parameter processing method, the assignment of id
also needs to be added.
is to assign the id
obtained during display to the request parameter body.
Finally, before requesting the interface, you also need to check whether there are parameters under the current tab. If it passes, then request the backend to update the interface:
Test it Function:
The function is completed, but one thing is missing, a reset is missing. Otherwise, if you click the [Create Interface] button, you will always see the last opened interface. content.
Add a new methodresetApiForm
to reset the fields in the form:
Used when clicking the [Create Interface] button , let’s modify it here. Previously, we changed the status of a dialog box, but now we put it into a method:
Call in the method:
The above is the detailed content of How to implement springboot vue interface test definition editing function. For more information, please follow other related articles on the PHP Chinese website!

Java is widely used in enterprise-level applications because of its platform independence. 1) Platform independence is implemented through Java virtual machine (JVM), so that the code can run on any platform that supports Java. 2) It simplifies cross-platform deployment and development processes, providing greater flexibility and scalability. 3) However, it is necessary to pay attention to performance differences and third-party library compatibility and adopt best practices such as using pure Java code and cross-platform testing.

JavaplaysasignificantroleinIoTduetoitsplatformindependence.1)Itallowscodetobewrittenonceandrunonvariousdevices.2)Java'secosystemprovidesusefullibrariesforIoT.3)ItssecurityfeaturesenhanceIoTsystemsafety.However,developersmustaddressmemoryandstartuptim

ThesolutiontohandlefilepathsacrossWindowsandLinuxinJavaistousePaths.get()fromthejava.nio.filepackage.1)UsePaths.get()withSystem.getProperty("user.dir")andtherelativepathtoconstructthefilepath.2)ConverttheresultingPathobjecttoaFileobjectifne

Java'splatformindependenceissignificantbecauseitallowsdeveloperstowritecodeonceandrunitonanyplatformwithaJVM.This"writeonce,runanywhere"(WORA)approachoffers:1)Cross-platformcompatibility,enablingdeploymentacrossdifferentOSwithoutissues;2)Re

Java is suitable for developing cross-server web applications. 1) Java's "write once, run everywhere" philosophy makes its code run on any platform that supports JVM. 2) Java has a rich ecosystem, including tools such as Spring and Hibernate, to simplify the development process. 3) Java performs excellently in performance and security, providing efficient memory management and strong security guarantees.

JVM implements the WORA features of Java through bytecode interpretation, platform-independent APIs and dynamic class loading: 1. Bytecode is interpreted as machine code to ensure cross-platform operation; 2. Standard API abstract operating system differences; 3. Classes are loaded dynamically at runtime to ensure consistency.

The latest version of Java effectively solves platform-specific problems through JVM optimization, standard library improvements and third-party library support. 1) JVM optimization, such as Java11's ZGC improves garbage collection performance. 2) Standard library improvements, such as Java9's module system reducing platform-related problems. 3) Third-party libraries provide platform-optimized versions, such as OpenCV.

The JVM's bytecode verification process includes four key steps: 1) Check whether the class file format complies with the specifications, 2) Verify the validity and correctness of the bytecode instructions, 3) Perform data flow analysis to ensure type safety, and 4) Balancing the thoroughness and performance of verification. Through these steps, the JVM ensures that only secure, correct bytecode is executed, thereby protecting the integrity and security of the program.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
