170
社区成员




1.Course Assignment Requirements
3.1Functionality Demonstration
4Design and Implementation Process
6Personal Journey and Learnings
Course Name | Contact Management System |
---|---|
Assignment Requirements | Implement a contact management system with front-end and back-end separation, including adding, modifying, and deleting contacts |
Objectives of This Assignment | Master front-end and back-end separation development, database operations, and basic web development frameworks |
Other References | https://github.com/BYaoKSYao/Contacts |
Module | Estimated Time | Actual Time | Remarks |
---|---|---|---|
Frontend Page Development | 4 hours | 5 hours | |
Backend API Development | 6 hours | 7 hours | Encountered database connection issues |
Functional Testing | 2 hours | 3 hours | Testing covered all features |
Documentation Writing | 1 hour | 2 hours | Including blog and code comments |
Below are the main functionalities of the system, including adding, modifying, and deleting contacts.
Main interface:
Adding a contact:
Editing a contact
Deleting a contact
The system adopts a front-end and back-end separation architecture, with the front-end using the Vue.js framework, the back-end using the Express.js framework, and the MySQL database.
A table named testout
is created in the database, containing ID
, name
, age
, phone
fields.
Below is a code snippet from Vue.js for adding a contact:
async data_upload() {
if (this.available) {
try {
const res = await axios.post('http://127.0.0.1:3000/post', {
ID: '',
name: this.name,
age: this.age,
phone: this.phone
});
} catch (error) {
console.error(error);
}
this.name = ''
this.age = ''
this.phone = ''
this.fetch_data()
}
}
Below is a code snippet from Express.js for handling add contact requests:
router.post('/post', (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*');
console.log(req.body);
sql_function.post_sql((err, results) => {
if (err) {
console.error('Error fetching data');
res.status(500).send('Internal Server Error');
} else {
console.log("Storage successful");
res.send("Storage successful");
console.log('-------------------------------------');
}
}, req.body);
});
Through this assignment, I learned about the development model of front-end and back-end separation, mastered the use of Vue.js and Express.js, and how to operate the MySQL database. During the development process, I encountered some challenges, such as database connection issues and data interaction between the front-end and back-end, but I successfully resolved these issues by consulting materials and continuous attempts. This assignment not only improved my technical skills but also exercised my problem-solving abilities.