当前位置:网站首页>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
边栏推荐
- 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
- Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
- Kubernetes entry to mastery - bare metal loadbalance 80 443 port exposure precautions
- 指针数组与数组指针的区分
- Unity创建超写实三维场景的一般步骤
- 【h264】libvlc 老版本的 hevc h264 解析,帧率设定
- filebeat、logstash配置安装
- Distinction between pointer array and array pointer
- Esp8266 - beginner level Chapter 1
- MFC获取本机IP(网络通讯时用得多)
猜你喜欢
antd dropdown + modal + textarea导致的textarea光标不可被键盘控制问题
[报告] Microsoft :Application of deep learning methods in speech enhancement
Audio signal processing and coding - 2.5.3 the discrete cosine transform
@Mapperscan and @ mapper
Mfcc: Mel frequency cepstrum coefficient calculation of perceived frequency and actual frequency conversion
Why is PostgreSQL about to surpass SQL Server?
Esp8266 - beginner level Chapter 1
NiO related Basics
Reflection on the performance of some OpenGL operations in the past
深度学习——特征工程小总结
随机推荐
Golang timer
NiO related Basics
IIS data conversion problem: 16bit to 24bit
[report] Microsoft: application of deep learning methods in speech enhancement
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
Some ideas about time-consuming needs assessment
Shanda Wangan shooting range experimental platform project - personal record (IV)
What is a message queue
A brief explanation of golang's keyword "competence"
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
考试系统进入试卷优化思路
Speex维纳滤波与超几何分布的改写
Unity创建超写实三维场景的一般步骤
Gossip: on greed
Build intelligent garbage classification applet based on Zero
Common SQL commands
Openlayers 5.0 discrete aggregation points
TI DSP的 FFT与IFFT库函数的使用测试
[transfer] summary of new features of js-es6 (one picture)
MySQL syntax collation (3)