花了一晚上肝的前后端Node.js+React小项目。 员工review管理系统。
Frontend:
- React
- React Hook : All made by Functional Component
- Antd: The component CSS is done by Antd style.
- Webpack, Babel: the default setting of create-react-app
Backend:
- Node.js
- Koa: Using the Koa framework
Database:
- Mysql
- made the database done remember the database name, the username and the password
- Search "Config database here" in the project let the value be the correct one.
- Search "config here". There will be two parts to be filled or corrected. backend_prefix: the API address prefix, the default port of this backend server is 7000. frontend_address: the address which is the frontend, the defaulut port is 3000.
- cd ${Project_address}
- yarn
- yarn start
- open the browser.
- cd app
- npm install
- npm run dev / npm start
- There is a default user "root", use this name and put any words in password filed to login the system as admin user.
- The login function is the mock one, the username must be added to the database, but the password is not checked, please use any words you like~.
- The system has two kind of user, which are 'Admin' and 'Employee'. The functional diffirence is as same as the introduction.
- As admin users, you can add user which is admin or employee, and request the review to the employee or the other admin.
- In the review management, the review info only can be edited when it have not been done.
- As employee users, you can only fill the request and give the feedback.
App -> Login -> Home - (Admin user) -> UserInfo -> CommonTable -> Add/Delete/Edit/Find - (Admin user) -> ReviewInfo -> CommonTable -> Add/Edit/Find - (Employee user) -> TodoList -> ButtonClick -> Modal to do the review -> No Login -> Login
app -> routes -> controller -> module -> database operate -> callback
- Login Page
- User Management Page
- Review Management Page
- Fill Review Page
In the table, you can click the row and get in to the detail Modal or edit the information.
the 3 and 4 are using the one Component called "CommonTable", which is setting by the props.
- Login
/login: (username) => {code, statue, data: {the login user}} 2. User
/user/users: () => {code, msg, data (all Users)}
/user/addUser: (username, usertype, userage) => {code, msg, data(all Users after add)}
/user/editUser: (username, usertype, userage) => {code, msg}
/user/delUser: (user_id) => {code, msg} 3. Review
/review/reviews: () => {code, msg, data(all Reviews)}
/review/addReview: (from, to, nowUser) => {code, msg}
/review/editReview: (from,to) => {code, msg}
/review/getReviewList: (nowUser) => {code, msg, data(all reviews to be done by now user)}
/review/completeReview: (content) => {code, msg}
-- users definition
CREATE TABLE `users` (
`user_id` int NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) NOT NULL,
`user_age` int NOT NULL,
`user_type` varchar(255) NOT NULL,
`createdAt` datetime NOT NULL,
`updatedAt` datetime NOT NULL,
PRIMARY KEY (`user_id`)
);
-- reviews definition
CREATE TABLE `reviews` (
`review_id` int NOT NULL AUTO_INCREMENT,
`review_from` varchar(255) NOT NULL,
`review_to` int NOT NULL,
`has_done` tinyint(1) NOT NULL,
`content` varchar(1000) NOT NULL,
`create_by` varchar(255) NOT NULL,
`createdAt` datetime NOT NULL,
`updatedAt` datetime NOT NULL,
PRIMARY KEY (`review_id`)
);- Login function can be improved to the true login.
- The apis should have the authentication to provide the attacking.
- The user table can provide more data of the review situation.
- The logger and security operation should be improved in the backend server.
江东子弟多才俊,卷土重来未可知。