当前位置:网站首页>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
边栏推荐
- Command - sudo
- IIS data conversion problem: 16bit to 24bit
- ArcMap connecting ArcGIS Server
- uIP1. 0 actively sent problem understanding
- antd dropdown + modal + textarea导致的textarea光标不可被键盘控制问题
- Core concepts of rest
- 音频编辑生成软件
- [webrtc] add x264 encoder for CEF / Chromium
- Zero cost, zero foundation, build profitable film and television applet
- Inject Autowired fields into ordinary beans
猜你喜欢
MySQL syntax collation (3)
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
Common SQL commands
antd dropdown + modal + textarea导致的textarea光标不可被键盘控制问题
Zero cost, zero foundation, build profitable film and television applet
An idea of rendering pipeline based on FBO
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
MySQL lock
White screen processing method of fulter startup page
@MapperScan与@Mapper
随机推荐
MFC obtains local IP (used more in network communication)
Shanda Wangan shooting range experimental platform project - personal record (V)
Codeforces Round #783 (Div. 2) D题解
基于pytorch搭建GoogleNet神经网络用于花类识别
MySQL数据库 - 单表查询(一)
【webrtc】Add x264 encoder for CEF/Chromium
C学习完结
5 minutes to achieve wechat cloud applet payment function (including source code)
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
一个简单的(基于redisson的)分布式同步工具类封装
JVM的类加载过程
Main differences between go and PHP
渤海期货这家公司怎么样。期货开户办理安全?
Pit encountered using camera x_ When onpause, the camera is not released, resulting in a black screen when it comes back
ArcMap publishing slicing service
@Analysis of conditional on Web Application
Why is the hexadecimal printf output of C language sometimes with 0xff and sometimes not
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
Why is PostgreSQL about to surpass SQL Server?
What is a message queue