First Assignment 832202201 Qinye Ding 丁钦烨
目录
1.3 Documentation and Submission
3 Presentation of the Finished Product
4 Design and Implementation Process
4.3 Project Implementation Process
5.1.2 TypeScript scripting section
6 Personal Journey and Learnings
| Course for this Assignment | EE308 |
|---|---|
| Where are the requirement for this assigment | First assignment-- front-end and back-end separation contacts programming |
| Name and student ID | 丁钦烨(Qinye Ding) 832202201 |
| The objective of this assignment | 1. Front-end and Back-end Separation;2. Deployment and Functionality;3. Code Quality and Documentation |
| Front-end repository on GitHub | https://github.com/A-Piao-ovo/- |
| Back-end repository on GitHub | https://github.com/A-Piao-ovo/houduan |
-
1 Assignment
-
For this assignment, students are required to create a contact list using a front-end and back-end separation technology and meet the following basic requirements.
1.1 Basic Functions
1.1.1 Add:
Users can add new contact information through certain interactions.
1.1.2 Modify:
Users can modify existing contact information through certain interactions.
1.1.3 Delete:
Users can delete existing contact information through certain interactions -
1.3 Documentation and Submission
Students are required to document their coding standards, development process, and project structure. The assignment must be submitted via GitHub, with separate repositories for the front end and back end, and a blog post detailing the assignment, development journey, and code explanations.
-
2 PSP Table
| Activity | Comments | Estimated Time | Actual Time |
|---|---|---|---|
| planning | Overall plan of this project | 1h | 1h |
| Preparation(learning) | download IDEA, Vue etc | 4h | 4h |
| Demand Analysis | Determine the requirements of the project and the functions that can be achieved | 1h | 1.5h |
| Architecture Design | Design a frontend-backend separated architecture with Vue for the frontend and Spring Boot for the backend | 1h | 1h |
| API Design | Create excuses for the front and back ends, and correlate the front and back end designs | 10h | 11h |
| Database Design | Create the required classes and bind the back end to the database | 15h | 20h |
| Test | Test whether the project meets expectations | 1h | 1.5 |
| Modify | Correct errors and optimize code | 4h | 6h |
| Total | 37h | 46h |
3 Presentation of the Finished Product

4 Design and Implementation Process
4.1 Requirements Analysis
Functional Requirements: Implement the functions of adding, search, editing, and deleting contact information.
User Interface: The interface should be user-friendly, easy to operate, and compatible with mainstream browsers.
Tools Selection
Frontend: Use the Vue framework to build the user interface.
Backend: Utilize the Spring Boot and Maven framework.
Database: Choose MySQL to store contact data, use Navicat to visualize management data, ensuring data persistence and efficient querying.
4.2 Architectural Design:
Frontend Architecture: Develop using a component-based approach, leveraging the Element UI components to aid in development.
Backend Architecture: Study and implement backend code for CRUD (Create, Read, Update, Delete) operations.
Database Design: Design a reasonable table structure, including a contacts table (with fields such as ID, name, and phone number), and consider indexing to optimize search performance.
4.3 Project Implementation Process
·Environment setup and configuration:
Download Node.js to set up the Vue front-end environment, and download npm to get the front-end up and running.
Download IDEA and build the Spring Boot framework into it.
Download Mysql and Navicat to prepare for the subsequent database setup
·Frontend Development:
Design and create user interfaces and design user interaction logic.
Set the callback function to the back end and display the back end data.
·Backend Development:
Receive front-end requirements, access database data and return data to the front-end
·Database Design and Implementation:
Design the database table structure based on requirements analysis, create and initialize the database.
Write code to handle cross-origin resource sharing (CORS) and implement CRUD operations for data.
Optimize database performance, such as by adding indexes and using transactions.
·Testing and Debugging:
Test that the code is running correctly, and optimize the code
5 Code Description
5.1 Front-end code
5.1.1 System home page
<template>
<div class="container">
<h1>联系人管理</h1>
<div class="button-container">
<button @click="showAddModal">添加联系人</button>
</div>
<table>
<thead>
<tr>
<th>姓名</th>
<th>电话</th>
<th>年龄</th>
<th>性别</th>
<th>地址</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="contact in contacts" :key="contact.id">
<td>{{ contact.name }}</td>
<td>{{ contact.phone }}</td>
<td>{{ contact.age }}</td>
<td>{{ contact.gender }}</td>
<td>{{ contact.address }}</td>
<td>
<button @click="editContact(contact)">修改</button>
<button @click="deleteContact(contact.id)">删除</button>
</td>
</tr>
</tbody>
</table>
<modal v-if="showModal" @close="closeModal">
<template #header>
<h2>{{ editMode ? '修改联系人' : '添加联系人' }}</h2>
</template>
<template #body>
<div>
<label>姓名:</label>
<input v-model="currentContact.name" />
<label>电话:</label>
<input v-model="currentContact.phone" />
<label>年龄:</label>
<input type="number" v-model="currentContact.age" />
<label>性别:</label>
<input v-model="currentContact.gender" />
<label>地址:</label>
<input v-model="currentContact.address" />
</div>
</template>
<template #footer>
<div class="button-group">
<button @click="saveContact">确认</button>
<button @click="closeModal">取消</button>
</div>
</template>
</modal>
</div>
</template>
5.1.2 TypeScript scripting section
<script>
import axios from 'axios';
import Modal from './AppModal.vue';
export default {
components: { Modal },
data() {
return {
contacts: [],
currentContact: { name: '', phone: '', age: null, gender: '', address: '' },
showModal: false,
editMode: false,
};
},
methods: {
fetchContacts() {
axios.get('/api/contacts').then(response => {
this.contacts = response.data;
});
},
showAddModal() {
this.currentContact = { name: '', phone: '', age: null, gender: '', address: '' };
this.editMode = false;
this.showModal = true;
},
editContact(contact) {
this.currentContact = { ...contact };
this.editMode = true;
this.showModal = true;
},
deleteContact(id) {
axios.delete(`/api/contacts/${id}`).then(() => {
this.fetchContacts();
});
},
saveContact() {
const method = this.editMode ? 'put' : 'post';
const url = this.editMode ? '/api/contacts' : '/api/contacts';
axios[method](url, this.currentContact).then(() => {
this.closeModal();
this.fetchContacts();
});
},
closeModal() {
this.showModal = false;
}
},
mounted() {
this.fetchContacts();
}
};
</script>
5.1.3 Style
<style scoped>
/* 页面主样式 */
h1 {
text-align: center;
font-size: 2rem;
margin: 20px 0;
color: #333;
}
/* 表格容器 */
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
}
/* 表格样式 */
table {
width: 50vw; /* 设置表格宽度为视口宽度的一半 */
margin: 20px auto; /* 表格水平居中 */
border-collapse: collapse;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
th, td {
padding: 12px;
border: 1px solid #ccc;
text-align: center;
word-wrap: break-word;
white-space: nowrap; /* 防止内容换行 */
overflow: hidden; /* 隐藏溢出文本 */
text-overflow: ellipsis; /* 使用省略号表示溢出文本 */
}
th {
background-color: #f2f2f2;
font-weight: bold;
}
tbody tr:hover {
background-color: #f5f5f5;
}
/* 媒体查询 */
@media (max-width: 768px) {
table {
display: block; /* 在小屏幕上使用块布局 */
overflow-x: auto; /* 超出部分水平滚动 */
white-space: nowrap; /* 避免单元格内容换行 */
}
th, td {
display: block; /* 每个单元格为块元素 */
text-align: right; /* 文字右对齐 */
}
th {
text-align: left; /* 表头文字左对齐 */
}
tbody tr {
margin-bottom: 10px; /* 行间距 */
border: none; /* 移除行的边框 */
}
}
/* 按钮容器样式 */
.button-container {
display: flex; /* 使用 Flexbox 排列按钮 */
justify-content: center; /* 水平居中 */
margin-bottom: 20px; /* 下方外边距 */
}
/* 按钮组样式 */
.button-group {
display: flex; /* 使用 Flexbox 布局 */
justify-content: center; /* 水平居中 */
gap: 10px; /* 按钮之间的间距 */
flex-wrap: nowrap; /* 防止换行 */
max-width: 100%; /* 最大宽度限制 */
}
/* 按钮样式 */
button {
padding: 10px 15px; /* 内边距 */
background-color: #007bff; /* 按钮背景颜色 */
color: white; /* 按钮字体颜色 */
border: none; /* 去掉边框 */
border-radius: 5px; /* 圆角 */
cursor: pointer; /* 鼠标悬停时的指针样式 */
transition: background-color 0.3s; /* 背景颜色过渡 */
margin: 0 5px; /* 按钮间距 */
font-size: 1rem; /* 字体大小 */
}
button:hover {
background-color: #0056b3; /* 鼠标悬停时背景颜色变化 */
}
/* 输入框样式 */
input {
width: 100%; /* 输入框宽度 */
padding: 10px; /* 内边距 */
margin: 10px 0; /* 上下外边距 */
border: 1px solid #ccc; /* 边框 */
border-radius: 5px; /* 圆角 */
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); /* 内部阴影 */
}
input:focus {
border-color: #007bff; /* 聚焦时边框颜色 */
outline: none; /* 去掉默认聚焦轮廓 */
}
.button-group {
display: flex; /* 使用 flexbox 布局 */
justify-content: center; /* 水平居中 */
gap: 10px; /* 按钮之间的间距 */
}
button {
padding: 10px 20px; /* 增加按钮内边距 */
border: none; /* 去掉边框 */
border-radius: 5px; /* 圆角 */
background-color: #007bff; /* 按钮背景色 */
color: white; /* 文字颜色 */
cursor: pointer; /* 鼠标指针效果 */
transition: background-color 0.3s; /* 背景色过渡效果 */
}
button:hover {
background-color: #0056b3; /* 鼠标悬停时背景色 */
}
</style>
5.2 back-end code
import com.example.demo.entity.Contact;
import com.example.demo.service.ContactService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/api/contacts")
public class ContactController {
@Resource
private ContactService contactService;
@GetMapping
public List<Contact> getAllContacts() {
return contactService.getAllContacts();
}
@GetMapping("/{id}")
public Contact getContact(@PathVariable Integer id) {
return contactService.getContactById(id);
}
@PostMapping
public void addContact(@RequestBody Contact contact) {
contact.setId(null); // 确保不传入 id
contactService.addContact(contact);
}
@PutMapping
public void updateContact(@RequestBody Contact contact) {
contactService.updateContact(contact);
}
@DeleteMapping("/{id}")
public void deleteContact(@PathVariable Integer id) {
contactService.deleteContact(id);
}
}
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("contacts")
public class Contact {
@TableId(type = IdType.AUTO)
private Integer id;
private String name;
private String phone;
private Integer age;
private String gender;
private String address;
}
6 Personal Journey and Learnings
Through this project of separating the front and back ends, I have a deep understanding of the operation law of the front and back ends of the web page, can make some web pages, and know the underlying law of the back end.
相关推荐
技术转移机构如何基于数据提升项目撮合精准度?.docx
技术转移机构如何基于数据提升项目撮合精准度?
超扭滑模与快速终端滑模的永磁同步电机无感控制:理论、离散化实现与仿真研究(Simulink仿真实现)
内容概要:本文系统研究了超扭滑模控制(STSMC)与快速终端滑模控制(FTSMC)在永磁同步电机(PMSM)无感控制中的应用,重点涵盖其理论基础、离散化实现方法及Simulink仿真验证。文章深入阐述了两种高阶滑模控制策略的设计原理,利用磁链无感观测技术实现转子位置与速度的精确估计,从而省去物理传感器,有效提升了系统的可靠性与鲁棒性。同时,提供了完整的Simulink仿真模型构建方案,包括控制器设计、关键参数整定及动态响应性能分析,充分验证了所提出的方法在零速与低速工况下的卓越控制性能和有效性。; 适合人群:具备电机控制、现代控制理论基础知识及熟练掌握MATLAB/Simulink仿真技能的研究生、科研人员与工程技术人员。; 使用场景及目标:①深入理解高阶滑模控制在电机驱动系统中的设计思想与具体实现;②掌握基于滑模观测器的无感控制核心技术;③开展永磁同步电机高性能控制算法的理论研究、仿真验证与工程化探索。; 阅读建议:建议将文中详尽的理论推导与Simulink仿真模型相结合进行学习,重点关注滑模面的构建、抖振抑制策略的实施以及离散化处理的细节,有条件的研究者可进一步将算法移植到DSP等硬件平台进行实验验证,以深化对理论的理解并检验其实际应用效果。
多源动态最优潮流的分布鲁棒优化方法(IEEE118节点)(Matlab代码实现)
内容概要:本文系统阐述了基于Matlab的多源动态最优潮流分布鲁棒优化方法,聚焦于IEEE118节点电力系统,旨在应对高比例可再生能源接入背景下源荷双重不确定性所带来的调度挑战。该方法深度融合分布鲁棒优化理论,通过构建能够抵御最坏情况概率分布的决策模型,有效提升了电力系统在复杂不确定性环境下的运行安全性、经济性与可靠性。研究不仅提供了完整的Matlab代码实现,便于结果复现与算法验证,还特别关注了含风电等新能源的现代电网低碳调度问题,为解决实际工程中的优化调度难题提供了强有力的理论支撑和技术工具。; 适合人群:具备电力系统分析基础和Matlab编程能力的研究生、科研人员及从事智能电网优化运行、能源系统规划等相关领域的工程技术人员。; 使用场景及目标:①研究含高比例可再生能源接入的电力系统动态最优潮流问题;②掌握分布鲁棒优化在电力系统经济调度、低碳调度中的建模思想与求解方法;③利用IEEE118标准测试系统进行算法有效性验证与性能对比分析;④基于所提供的Matlab代码进行二次开发,探索新型不确定性优化理论在电力系统中的创新应用。; 阅读建议:建议读者结合电力系统最优潮流、不确定性优化理论(特别是分布鲁棒优化)的背景知识进行学习,重点关注模型的构建逻辑、目标函数与约束条件的设计原理,以及Matlab代码的具体实现细节。在学习过程中,应动手调试代码,尝试修改系统参数(如新能源出力波动范围、负荷水平等),以观察不同场景下优化结果的变化,从而深刻理解该方法的适应性、优势及其潜在的局限性。
车间调度基于GA、PSO、SA、ACO、TS优化算法的车间调度比较研究(Matlab代码实现)
内容概要:本文系统性地比较了遗传算法(GA)、粒子群优化(PSO)、模拟退火(SA)、蚁群优化(ACO)和禁忌搜索(TS)五种智能优化算法在车间调度问题中的性能表现,并提供了基于Matlab的完整代码实现。研究聚焦于调度优化的核心目标——最小化完工时间(makespan),通过标准测试案例对各算法的收敛速度、求解精度和稳定性进行了深入对比分析,旨在为实际生产调度中算法的选择与改进提供科学依据。文中不仅详述了每种算法的设计思路与关键参数设置,还展示了其实现逻辑,便于读者理解、复现与拓展。; 适合人群:从事智能制造、工业工程、运筹优化等相关领域的研究人员,以及具备Matlab编程基础、希望将智能优化算法应用于实际调度问题的研究生和工程师。; 使用场景及目标:① 掌握主流智能优化算法在解决NP-hard车间调度问题上的具体应用与差异;② 学习如何利用Matlab实现并对比不同优化算法的性能;③ 为解决生产制造、物流配送等领域中的资源调度难题提供算法选型和技术参考。; 阅读建议:建议读者在阅读时重点关注各算法的Matlab实现代码和实验结果对比部分,动手运行代码以直观感受不同算法的寻优过程和效果差异。同时,可结合具体调度约束条件,尝试调整算法参数或融合多种算法思想,以深化对优化机理的理解。
3D人物伍子胥智能对话及反应动作报告
3D人物伍子胥智能对话及反应动作报告


