Showing
9 changed files
with
318 additions
and
5 deletions
This diff is collapsed. Click to expand it.
... | @@ -3118,6 +3118,14 @@ | ... | @@ -3118,6 +3118,14 @@ |
3118 | "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.1.1.tgz", | 3118 | "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.1.1.tgz", |
3119 | "integrity": "sha512-5Kgy8Cz6LPC9DJcNb3yjAXTu3XihQgEdnIg50c//zOC/MyLP0Clg+Y8Sh9ZjjnvBrDZU4DgXS9C3T9r4/scGZQ==" | 3119 | "integrity": "sha512-5Kgy8Cz6LPC9DJcNb3yjAXTu3XihQgEdnIg50c//zOC/MyLP0Clg+Y8Sh9ZjjnvBrDZU4DgXS9C3T9r4/scGZQ==" |
3120 | }, | 3120 | }, |
3121 | + "axios": { | ||
3122 | + "version": "0.21.0", | ||
3123 | + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz", | ||
3124 | + "integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==", | ||
3125 | + "requires": { | ||
3126 | + "follow-redirects": "^1.10.0" | ||
3127 | + } | ||
3128 | + }, | ||
3121 | "axobject-query": { | 3129 | "axobject-query": { |
3122 | "version": "2.2.0", | 3130 | "version": "2.2.0", |
3123 | "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", | 3131 | "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", | ... | ... |
... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
7 | "@testing-library/jest-dom": "^5.11.6", | 7 | "@testing-library/jest-dom": "^5.11.6", |
8 | "@testing-library/react": "^11.2.2", | 8 | "@testing-library/react": "^11.2.2", |
9 | "@testing-library/user-event": "^12.5.0", | 9 | "@testing-library/user-event": "^12.5.0", |
10 | + "axios": "^0.21.0", | ||
10 | "react": "^17.0.1", | 11 | "react": "^17.0.1", |
11 | "react-dom": "^17.0.1", | 12 | "react-dom": "^17.0.1", |
12 | "react-scripts": "4.0.1", | 13 | "react-scripts": "4.0.1", | ... | ... |
1 | import React, {Component, components} from 'react'; | 1 | import React, {Component, components} from 'react'; |
2 | import Student from './components/Student'; | 2 | import Student from './components/Student'; |
3 | +import StudentAdd from './components/StudentAdd'; | ||
3 | import './App.css'; | 4 | import './App.css'; |
4 | import Paper from '@material-ui/core/Paper' | 5 | import Paper from '@material-ui/core/Paper' |
5 | import Table from '@material-ui/core/Table' | 6 | import Table from '@material-ui/core/Table' |
... | @@ -51,11 +52,25 @@ const students = [ | ... | @@ -51,11 +52,25 @@ const students = [ |
51 | 52 | ||
52 | class App extends Component{ | 53 | class App extends Component{ |
53 | 54 | ||
54 | - state = { | 55 | + constructor(props){ |
55 | - students: "", | 56 | + super(props); |
56 | - completed: 0 | 57 | + this.state = { |
58 | + students: '', | ||
59 | + completed: 0 | ||
60 | + } | ||
57 | } | 61 | } |
58 | 62 | ||
63 | + stateRefresh = () => { | ||
64 | + this.setState({ | ||
65 | + students: '', | ||
66 | + completed: 0 | ||
67 | + }); | ||
68 | + this.callApi() | ||
69 | + .then(res => this.setState({students: res})) | ||
70 | + .catch(err => console.log(err)); | ||
71 | + } | ||
72 | + | ||
73 | + | ||
59 | componentDidMount() { | 74 | componentDidMount() { |
60 | this.timer= setInterval(this.progress,20); | 75 | this.timer= setInterval(this.progress,20); |
61 | this.callApi() | 76 | this.callApi() |
... | @@ -79,7 +94,8 @@ class App extends Component{ | ... | @@ -79,7 +94,8 @@ class App extends Component{ |
79 | const {classes}= this.props; | 94 | const {classes}= this.props; |
80 | 95 | ||
81 | return ( | 96 | return ( |
82 | - <Paper className={classes.root}> | 97 | + <div> |
98 | + <Paper className={classes.root}> | ||
83 | <Table className={classes.table}> | 99 | <Table className={classes.table}> |
84 | 100 | ||
85 | <TableHead> | 101 | <TableHead> |
... | @@ -125,7 +141,11 @@ class App extends Component{ | ... | @@ -125,7 +141,11 @@ class App extends Component{ |
125 | 141 | ||
126 | </Table> | 142 | </Table> |
127 | 143 | ||
128 | - </Paper> | 144 | + </Paper> |
145 | + | ||
146 | + <StudentAdd stateRefresh={this.stateRefresh}/> | ||
147 | + </div> | ||
148 | + | ||
129 | 149 | ||
130 | ); | 150 | ); |
131 | } | 151 | } | ... | ... |
client/src/components/StudentAdd.js
0 → 100644
1 | +import React from 'react'; | ||
2 | +import {post} from 'axios'; | ||
3 | +class StudentAdd extends React.Component{ | ||
4 | + | ||
5 | + constructor(props){ | ||
6 | + super(props); | ||
7 | + this.state={ | ||
8 | + st_Code:'', | ||
9 | + st_Name:'', | ||
10 | + st_Id:'', | ||
11 | + st_Major:'', | ||
12 | + st_Midscore:'', | ||
13 | + st_Finalscore:'', | ||
14 | + st_Assignscore:'', | ||
15 | + st_Attendscore:'', | ||
16 | + st_Score:'' | ||
17 | + } | ||
18 | + } | ||
19 | + | ||
20 | + handleFormSubmit = (e) => { | ||
21 | + e.preventDefault() | ||
22 | + this.addStudent() | ||
23 | + .then((response) => { | ||
24 | + console.log(response.data); | ||
25 | + this.props.stateRefresh(); | ||
26 | + }) | ||
27 | + this.setState({ | ||
28 | + st_Code:'', | ||
29 | + st_Name:'', | ||
30 | + st_Id:'', | ||
31 | + st_Major:'', | ||
32 | + st_Midscore:'', | ||
33 | + st_Finalscore:'', | ||
34 | + st_Assignscore:'', | ||
35 | + st_Attendscore:'', | ||
36 | + st_Score:'' | ||
37 | + }) | ||
38 | + | ||
39 | + } | ||
40 | + | ||
41 | + handleValueChange = (e) => { | ||
42 | + let nextState = {}; | ||
43 | + nextState[e.target.name]=e.target.value; | ||
44 | + this.setState(nextState); | ||
45 | + } | ||
46 | + | ||
47 | + addStudent = () =>{ | ||
48 | + const url ='/api/students'; | ||
49 | + const formData=new FormData(); | ||
50 | + formData.append('st_Code',this.state.st_Code); | ||
51 | + formData.append('st_Name',this.state.st_Name); | ||
52 | + formData.append('st_Id',this.state.st_Id); | ||
53 | + formData.append('st_Major',this.state.st_Major); | ||
54 | + formData.append('st_Midscore',this.state.st_Midscore); | ||
55 | + formData.append('st_Finalscore',this.state.st_Finalscore); | ||
56 | + formData.append('st_Assignscore',this.state.st_Assignscore); | ||
57 | + formData.append('st_Attendscore',this.state.st_Attendscore); | ||
58 | + formData.append('st_Score',this.state.st_Score); | ||
59 | + const config = { | ||
60 | + headers: { | ||
61 | + 'content-tupe': 'multipart/form-data' | ||
62 | + } | ||
63 | + | ||
64 | + } | ||
65 | + return post(url, formData, config); | ||
66 | + } | ||
67 | + | ||
68 | + render(){ | ||
69 | + return( | ||
70 | + <form onSubmit={this.handleFormSubmit}> | ||
71 | + <h1>학생 추가</h1> | ||
72 | + 코드 번호 : <input type="text" name="st_Code" value={this.state.st_Code} onChange={this.handleValueChange}/><br/> | ||
73 | + 이름 : <input type="text" name="st_Name" value={this.state.st_Name} onChange={this.handleValueChange}/><br/> | ||
74 | + 학번 : <input type="text" name="st_Id" value={this.state.st_Id} onChange={this.handleValueChange}/><br/> | ||
75 | + 전공 : <input type="text" name="st_Major" value={this.state.st_Major} onChange={this.handleValueChange}/><br/> | ||
76 | + 중간 점수 : <input type="text" name="st_Midscore" value={this.state.st_Midscore} onChange={this.handleValueChange}/><br/> | ||
77 | + 기말 점수 : <input type="text" name="st_Finalscore" value={this.state.st_Finalscore} onChange={this.handleValueChange}/><br/> | ||
78 | + 과제 점수 : <input type="text" name="st_Assignscore" value={this.state.st_Assignscore} onChange={this.handleValueChange}/><br/> | ||
79 | + 출석 점수 : <input type="text" name="st_Attendscore" value={this.state.st_Attendscore} onChange={this.handleValueChange}/><br/> | ||
80 | + 학점 : <input type="text" name="st_Score" value={this.state.st_Score} onChange={this.handleValueChange}/><br/> | ||
81 | + <button type="submit">추가하기</button> | ||
82 | + | ||
83 | + </form> | ||
84 | + ) | ||
85 | + } | ||
86 | +} | ||
87 | + | ||
88 | +export default StudentAdd; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -41,6 +41,11 @@ | ... | @@ -41,6 +41,11 @@ |
41 | "color-convert": "^1.9.0" | 41 | "color-convert": "^1.9.0" |
42 | } | 42 | } |
43 | }, | 43 | }, |
44 | + "append-field": { | ||
45 | + "version": "1.0.0", | ||
46 | + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", | ||
47 | + "integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY=" | ||
48 | + }, | ||
44 | "array-flatten": { | 49 | "array-flatten": { |
45 | "version": "1.1.1", | 50 | "version": "1.1.1", |
46 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", | 51 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", |
... | @@ -76,6 +81,43 @@ | ... | @@ -76,6 +81,43 @@ |
76 | "fill-range": "^7.0.1" | 81 | "fill-range": "^7.0.1" |
77 | } | 82 | } |
78 | }, | 83 | }, |
84 | + "buffer-from": { | ||
85 | + "version": "1.1.1", | ||
86 | + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", | ||
87 | + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" | ||
88 | + }, | ||
89 | + "busboy": { | ||
90 | + "version": "0.2.14", | ||
91 | + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz", | ||
92 | + "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", | ||
93 | + "requires": { | ||
94 | + "dicer": "0.2.5", | ||
95 | + "readable-stream": "1.1.x" | ||
96 | + }, | ||
97 | + "dependencies": { | ||
98 | + "isarray": { | ||
99 | + "version": "0.0.1", | ||
100 | + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", | ||
101 | + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" | ||
102 | + }, | ||
103 | + "readable-stream": { | ||
104 | + "version": "1.1.14", | ||
105 | + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", | ||
106 | + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", | ||
107 | + "requires": { | ||
108 | + "core-util-is": "~1.0.0", | ||
109 | + "inherits": "~2.0.1", | ||
110 | + "isarray": "0.0.1", | ||
111 | + "string_decoder": "~0.10.x" | ||
112 | + } | ||
113 | + }, | ||
114 | + "string_decoder": { | ||
115 | + "version": "0.10.31", | ||
116 | + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", | ||
117 | + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" | ||
118 | + } | ||
119 | + } | ||
120 | + }, | ||
79 | "bytes": { | 121 | "bytes": { |
80 | "version": "3.1.0", | 122 | "version": "3.1.0", |
81 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", | 123 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", |
... | @@ -135,6 +177,17 @@ | ... | @@ -135,6 +177,17 @@ |
135 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", | 177 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", |
136 | "dev": true | 178 | "dev": true |
137 | }, | 179 | }, |
180 | + "concat-stream": { | ||
181 | + "version": "1.6.2", | ||
182 | + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", | ||
183 | + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", | ||
184 | + "requires": { | ||
185 | + "buffer-from": "^1.0.0", | ||
186 | + "inherits": "^2.0.3", | ||
187 | + "readable-stream": "^2.2.2", | ||
188 | + "typedarray": "^0.0.6" | ||
189 | + } | ||
190 | + }, | ||
138 | "concurrently": { | 191 | "concurrently": { |
139 | "version": "5.3.0", | 192 | "version": "5.3.0", |
140 | "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-5.3.0.tgz", | 193 | "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-5.3.0.tgz", |
... | @@ -152,6 +205,14 @@ | ... | @@ -152,6 +205,14 @@ |
152 | "yargs": "^13.3.0" | 205 | "yargs": "^13.3.0" |
153 | } | 206 | } |
154 | }, | 207 | }, |
208 | + "config": { | ||
209 | + "version": "3.3.3", | ||
210 | + "resolved": "https://registry.npmjs.org/config/-/config-3.3.3.tgz", | ||
211 | + "integrity": "sha512-T3RmZQEAji5KYqUQpziWtyGJFli6Khz7h0rpxDwYNjSkr5ynyTWwO7WpfjHzTXclNCDfSWQRcwMb+NwxJesCKw==", | ||
212 | + "requires": { | ||
213 | + "json5": "^2.1.1" | ||
214 | + } | ||
215 | + }, | ||
155 | "content-disposition": { | 216 | "content-disposition": { |
156 | "version": "0.5.3", | 217 | "version": "0.5.3", |
157 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", | 218 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", |
... | @@ -210,6 +271,38 @@ | ... | @@ -210,6 +271,38 @@ |
210 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", | 271 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", |
211 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" | 272 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" |
212 | }, | 273 | }, |
274 | + "dicer": { | ||
275 | + "version": "0.2.5", | ||
276 | + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", | ||
277 | + "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=", | ||
278 | + "requires": { | ||
279 | + "readable-stream": "1.1.x", | ||
280 | + "streamsearch": "0.1.2" | ||
281 | + }, | ||
282 | + "dependencies": { | ||
283 | + "isarray": { | ||
284 | + "version": "0.0.1", | ||
285 | + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", | ||
286 | + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" | ||
287 | + }, | ||
288 | + "readable-stream": { | ||
289 | + "version": "1.1.14", | ||
290 | + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", | ||
291 | + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", | ||
292 | + "requires": { | ||
293 | + "core-util-is": "~1.0.0", | ||
294 | + "inherits": "~2.0.1", | ||
295 | + "isarray": "0.0.1", | ||
296 | + "string_decoder": "~0.10.x" | ||
297 | + } | ||
298 | + }, | ||
299 | + "string_decoder": { | ||
300 | + "version": "0.10.31", | ||
301 | + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", | ||
302 | + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" | ||
303 | + } | ||
304 | + } | ||
305 | + }, | ||
213 | "ee-first": { | 306 | "ee-first": { |
214 | "version": "1.1.1", | 307 | "version": "1.1.1", |
215 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", | 308 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", |
... | @@ -474,6 +567,14 @@ | ... | @@ -474,6 +567,14 @@ |
474 | "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", | 567 | "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", |
475 | "dev": true | 568 | "dev": true |
476 | }, | 569 | }, |
570 | + "json5": { | ||
571 | + "version": "2.1.3", | ||
572 | + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", | ||
573 | + "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==", | ||
574 | + "requires": { | ||
575 | + "minimist": "^1.2.5" | ||
576 | + } | ||
577 | + }, | ||
477 | "locate-path": { | 578 | "locate-path": { |
478 | "version": "3.0.0", | 579 | "version": "3.0.0", |
479 | "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", | 580 | "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", |
... | @@ -531,11 +632,39 @@ | ... | @@ -531,11 +632,39 @@ |
531 | "mime-db": "1.44.0" | 632 | "mime-db": "1.44.0" |
532 | } | 633 | } |
533 | }, | 634 | }, |
635 | + "minimist": { | ||
636 | + "version": "1.2.5", | ||
637 | + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", | ||
638 | + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" | ||
639 | + }, | ||
640 | + "mkdirp": { | ||
641 | + "version": "0.5.5", | ||
642 | + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", | ||
643 | + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", | ||
644 | + "requires": { | ||
645 | + "minimist": "^1.2.5" | ||
646 | + } | ||
647 | + }, | ||
534 | "ms": { | 648 | "ms": { |
535 | "version": "2.0.0", | 649 | "version": "2.0.0", |
536 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", | 650 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", |
537 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" | 651 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" |
538 | }, | 652 | }, |
653 | + "multer": { | ||
654 | + "version": "1.4.2", | ||
655 | + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.2.tgz", | ||
656 | + "integrity": "sha512-xY8pX7V+ybyUpbYMxtjM9KAiD9ixtg5/JkeKUTD6xilfDv0vzzOFcCp4Ljb1UU3tSOM3VTZtKo63OmzOrGi3Cg==", | ||
657 | + "requires": { | ||
658 | + "append-field": "^1.0.0", | ||
659 | + "busboy": "^0.2.11", | ||
660 | + "concat-stream": "^1.5.2", | ||
661 | + "mkdirp": "^0.5.1", | ||
662 | + "object-assign": "^4.1.1", | ||
663 | + "on-finished": "^2.3.0", | ||
664 | + "type-is": "^1.6.4", | ||
665 | + "xtend": "^4.0.0" | ||
666 | + } | ||
667 | + }, | ||
539 | "mysql": { | 668 | "mysql": { |
540 | "version": "2.18.1", | 669 | "version": "2.18.1", |
541 | "resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz", | 670 | "resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz", |
... | @@ -564,6 +693,11 @@ | ... | @@ -564,6 +693,11 @@ |
564 | "validate-npm-package-license": "^3.0.1" | 693 | "validate-npm-package-license": "^3.0.1" |
565 | } | 694 | } |
566 | }, | 695 | }, |
696 | + "object-assign": { | ||
697 | + "version": "4.1.1", | ||
698 | + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", | ||
699 | + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" | ||
700 | + }, | ||
567 | "on-finished": { | 701 | "on-finished": { |
568 | "version": "2.3.0", | 702 | "version": "2.3.0", |
569 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", | 703 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", |
... | @@ -848,6 +982,11 @@ | ... | @@ -848,6 +982,11 @@ |
848 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", | 982 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", |
849 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" | 983 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" |
850 | }, | 984 | }, |
985 | + "streamsearch": { | ||
986 | + "version": "0.1.2", | ||
987 | + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", | ||
988 | + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" | ||
989 | + }, | ||
851 | "string-width": { | 990 | "string-width": { |
852 | "version": "3.1.0", | 991 | "version": "3.1.0", |
853 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", | 992 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", |
... | @@ -919,6 +1058,11 @@ | ... | @@ -919,6 +1058,11 @@ |
919 | "mime-types": "~2.1.24" | 1058 | "mime-types": "~2.1.24" |
920 | } | 1059 | } |
921 | }, | 1060 | }, |
1061 | + "typedarray": { | ||
1062 | + "version": "0.0.6", | ||
1063 | + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", | ||
1064 | + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" | ||
1065 | + }, | ||
922 | "unpipe": { | 1066 | "unpipe": { |
923 | "version": "1.0.0", | 1067 | "version": "1.0.0", |
924 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", | 1068 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", |
... | @@ -966,6 +1110,11 @@ | ... | @@ -966,6 +1110,11 @@ |
966 | "strip-ansi": "^5.0.0" | 1110 | "strip-ansi": "^5.0.0" |
967 | } | 1111 | } |
968 | }, | 1112 | }, |
1113 | + "xtend": { | ||
1114 | + "version": "4.0.2", | ||
1115 | + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", | ||
1116 | + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" | ||
1117 | + }, | ||
969 | "y18n": { | 1118 | "y18n": { |
970 | "version": "4.0.1", | 1119 | "version": "4.0.1", |
971 | "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", | 1120 | "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", | ... | ... |
... | @@ -8,8 +8,10 @@ | ... | @@ -8,8 +8,10 @@ |
8 | }, | 8 | }, |
9 | "dependencies": { | 9 | "dependencies": { |
10 | "body-parser": "^1.19.0", | 10 | "body-parser": "^1.19.0", |
11 | + "config": "^3.3.3", | ||
11 | "express": "4.17.1", | 12 | "express": "4.17.1", |
12 | "http-proxy-middleware": "^1.0.6", | 13 | "http-proxy-middleware": "^1.0.6", |
14 | + "multer": "^1.4.2", | ||
13 | "mysql": "^2.18.1" | 15 | "mysql": "^2.18.1" |
14 | }, | 16 | }, |
15 | "devDependencies": { | 17 | "devDependencies": { | ... | ... |
... | @@ -21,6 +21,9 @@ const connection = mysql.createConnection({ | ... | @@ -21,6 +21,9 @@ const connection = mysql.createConnection({ |
21 | 21 | ||
22 | connection.connect(); | 22 | connection.connect(); |
23 | 23 | ||
24 | +const multer=require('multer'); | ||
25 | +const upload = multer({dest:'./upload'}) | ||
26 | + | ||
24 | app.get('/api/students', (req, res)=>{ | 27 | app.get('/api/students', (req, res)=>{ |
25 | connection.query( | 28 | connection.query( |
26 | "SELECT * FROM dbproject.Students", | 29 | "SELECT * FROM dbproject.Students", |
... | @@ -30,4 +33,43 @@ app.get('/api/students', (req, res)=>{ | ... | @@ -30,4 +33,43 @@ app.get('/api/students', (req, res)=>{ |
30 | ); | 33 | ); |
31 | }); | 34 | }); |
32 | 35 | ||
36 | +app.use('/image', express.static('./upload')); | ||
37 | + | ||
38 | +app.post('/api/students',upload.single('image'), (req, res) =>{ | ||
39 | + let sql = 'INSERT INTO dbproject.Students VALUES (?,?,?,?,?,?,?,?,?)'; | ||
40 | + let st_Code= req.body.st_Code; | ||
41 | + let st_Name = req.body.st_Name; | ||
42 | + let st_Id = req.body.st_Id; | ||
43 | + let st_Major = req.body.st_Major; | ||
44 | + let st_Midscore = req.body.st_Midscore; | ||
45 | + let st_Finalscore = req.body.st_Finalscore; | ||
46 | + let st_Assignscore = req.body.st_Assignscore; | ||
47 | + let st_Attendscore = req.body.st_Attendscore; | ||
48 | + let st_Score = req.body.st_Score; | ||
49 | + console.log(st_Code); | ||
50 | + console.log(st_Name); | ||
51 | + console.log(st_Id); | ||
52 | + console.log(st_Major); | ||
53 | + console.log(st_Midscore); | ||
54 | + console.log(st_Finalscore); | ||
55 | + console.log(st_Assignscore); | ||
56 | + console.log(st_Attendscore); | ||
57 | + console.log(st_Score); | ||
58 | + | ||
59 | + let params=[st_Code, st_Name, | ||
60 | + st_Id, | ||
61 | + st_Major, | ||
62 | + st_Midscore, | ||
63 | + st_Finalscore, | ||
64 | + st_Assignscore, | ||
65 | + st_Attendscore, | ||
66 | + st_Score]; | ||
67 | + connection.query(sql, params, | ||
68 | + (err,rows,fields)=>{ | ||
69 | + res.send(rows); | ||
70 | + console.log(err); | ||
71 | + } | ||
72 | + ); | ||
73 | +}); | ||
74 | + | ||
33 | app.listen(port, () => console.log(`Listening on port ${port}`)); | 75 | app.listen(port, () => console.log(`Listening on port ${port}`)); |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment