当前位置:网站首页>Project training of Software College of Shandong University - Innovation Training - network security shooting range experimental platform (6)
Project training of Software College of Shandong University - Innovation Training - network security shooting range experimental platform (6)
2022-04-23 19:40:00 【Scrambled eggs with tomatoes without eggs!】
Catalog
One 、 Encapsulation of front and rear end transmission data
1.3 Front end preprocessing of data
One 、 Encapsulation of front and rear end transmission data
In order to make the data interaction between the front and back ends more convenient and safe , I encapsulate the data from the front end and the data returned from the back end .
The specific implementation steps are as follows :
1.1 Result.java
The interface returns the wrapper class in a unified way
There are mainly three parts :
code: Status code , stay Contants.java Class defines common states
mag: Return message , If the login is successful , System error, etc
data: Return the data
/**
* The interface returns the wrapper class in a unified way
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
private String code;
private String msg;
private Object data;
public static Result success() {
return new Result(Constants.CODE_200, "", null);
}
public static Result success(Object data) {
return new Result(Constants.CODE_200, "", data);
}
public static Result error(String code, String msg) {
return new Result(code, msg, null);
}
public static Result error() {
return new Result(Constants.CODE_500, " System error ", null);
}
}
1.2 Contants.java
Common values of status codes :
public interface Constants {
String CODE_200 = "200"; // success
String CODE_401 = "401"; // Insufficient authority
String CODE_400 = "400"; // Parameter error
String CODE_500 = "500"; // System error
String CODE_600 = "600"; // Other business exceptions
String DICT_TYPE_ICON = "icon";
}
1.3 Front end preprocessing of data
Backend return Result Data of type , Front-end request.js To deal with
The processing code is as follows :
request.interceptors.response.use(
response => {
let res = response.data;
// If it is a returned file
if (response.config.responseType === 'blob') {
return res
}
// Compatible with the string data returned by the server
if (typeof res === 'string') {
res = res ? JSON.parse(res) : res
}
// Give a prompt when the permission verification fails
if (res.code === '401') {
// ElementUI.Message({
// message: res.msg,
// type: 'error'
// });
router.push("/login")
}
return res;
},
error => {
console.log('err' + error) // for debug
return Promise.reject(error)
}
Two 、 Forum function design
As a place for users to discuss and communicate, the forum is essential .
2.1 Interface
The design of the front end is as follows , Put each story on a card , With a title 、 Content 、 Author and publication time
2.2 ForumCard.vue
<template>
<div class="main">
<el-row>
<el-col :span="16">
<div>
<el-input
style="width: 60%"
placeholder=" Please enter keywords "
suffix-icon="el-icon-search"
v-model="search" />
</div>
</el-col>
<el-col :span="2">
<div>
<el-button type="info" @click="load" plain> Search for </el-button>
</div>
</el-col>
<el-col :span="2">
<div>
<el-button type="info" @click="goto_write" plain> Release </el-button>
</div>
</el-col>
<el-col :span="4"><div></div></el-col>
</el-row>
<el-space direction="vertical" style="text-align: left">
<el-card v-for="(forum,i) in forumlist" :key="i" class="box-card" style="width: 1200px;background-color: #99a9bf" shadow="hover">
<template #header>
<div class="card-header">
<span style="font-weight:bold">{
{ forum.title }}</span>
</div>
</template>
<div class="text item">
{
{ forum.content }}
</div>
<div class="text item" style="margin-top: 20px">
{
{ forum.username }}
</div>
<div class="text item" style="text-align: right">
{
{ forum.time }}
</div>
</el-card>
</el-space>
</div>
</template>
版权声明
本文为[Scrambled eggs with tomatoes without eggs!]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231929365715.html
边栏推荐
- 对普通bean进行Autowired字段注入
- 2021-2022-2 ACM training team weekly Programming Competition (8) problem solution
- Hot reload debugging
- 【h264】libvlc 老版本的 hevc h264 解析,帧率设定
- RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
- RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
- IIS数据转换问题16bit转24bit
- 山大网安靶场实验平台项目-个人记录(五)
- Codeworks round 783 (Div. 2) d problem solution
- Common SQL commands
猜你喜欢
JVM的类加载过程
【webrtc】Add x264 encoder for CEF/Chromium
Esp8266 - beginner level Chapter 1
Garbage collector and memory allocation strategy
NiO related Basics
Shanda Wangan shooting range experimental platform project - personal record (V)
Prefer composition to inheritance
Zero cost, zero foundation, build profitable film and television applet
Physical meaning of FFT: 1024 point FFT is 1024 real numbers. The actual input to FFT is 1024 complex numbers (imaginary part is 0), and the output is also 1024 complex numbers. The effective data is
Unity创建超写实三维场景的一般步骤
随机推荐
Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
PostgreSQL
Speculation on the way to realize the smooth drag preview of video editing software
【h264】libvlc 老版本的 hevc h264 解析,帧率设定
Kubernetes入门到精通-KtConnect(全称Kubernetes Toolkit Connect)是一款基于Kubernetes环境用于提高本地测试联调效率的小工具。
Distinction between pointer array and array pointer
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
What is a message queue
渤海期货这家公司怎么样。期货开户办理安全?
Why is PostgreSQL about to surpass SQL Server?
Class loading process of JVM
The usage of slice and the difference between slice and array
uIP1. 0 actively sent problem understanding
MySQL syntax collation (5) -- functions, stored procedures and triggers
Reflection on the performance of some OpenGL operations in the past
Openlayers 5.0 two centering methods
Strange problems in FrameLayout view hierarchy
Unity创建超写实三维场景的一般步骤
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
uIP1.0 主动发送的问题理解