박기범

add delete api

1 { 1 {
2 - "accessKeyId": "ASIAXZL2SWFEQ3A42BQP", 2 + "accessKeyId": "",
3 - "secretAccessKey": "7VxG6RfekqWejvtLfdgLtZbxpXcUg6NshtTueiUV", 3 + "secretAccessKey": "",
4 - "sessionToken": "FwoGZXIvYXdzEMP//////////wEaDBXRmjIedzbi/hfWTCLDAY+AZ+EfzHvy0eV/zjF53n2JhNPJADGD+T32qA6dsBBNs4EyfXoejbu/9k1Evr2h042JwGLb7rZpnEFk46KoGGqo/mBRr+PLlKExbfnPLE6s3SRT0sdqgXkXS+7gQ/Y4aBB1+WLBySso2GxwftcUEJS/pC2YUdonzEpypIRUGD87aJaaMKIc5i9U7oh8uDht2FXWBEIWjhJAkBd+xuMyrhjq474NYCbQlQtG5annxEz5F5MQuKBKCk4G2yPlkGQ7Z0DmgyiNzIL3BTItePAyPGDb/Mvl+8aUiEgkysdTY0YUMhLaepwCzwlV9nuyfpVV2SH5gMoDmKoD", 4 + "sessionToken": "",
5 - "region": "us-east-1" 5 + "region": ""
6 } 6 }
......
...@@ -109,17 +109,26 @@ function addFavoriteFile(fileData) { ...@@ -109,17 +109,26 @@ function addFavoriteFile(fileData) {
109 return axios.post('api/favorites/addfile', fileData); 109 return axios.post('api/favorites/addfile', fileData);
110 } 110 }
111 function uploadContact(contactData){ 111 function uploadContact(contactData){
112 - return axios.post('/api/contact/contact_upload', contactData,{ 112 + return axios.post('/api/contact/contact_upload', contactData.file,{
113 headers: { 113 headers: {
114 'Content-Type': 'multipart/form-data', 114 'Content-Type': 'multipart/form-data',
115 }, 115 },
116 + params:{
117 + id: contactData.id,
118 + }
116 }); 119 });
117 } 120 }
118 function downloadContact(userID){ 121 function downloadContact(userID){
119 - return axios.post('/api/contact/contact_download', userID); 122 + return axios.post('/api/contact/contact_download', null, {params:{id:userID}});
120 } 123 }
121 function printContact(userID){ 124 function printContact(userID){
122 - return axios.post('/api/contact/contact_list', userID); 125 +
126 + console.log(String(userID));
127 +
128 + return axios.post('api/contact/contact_list', {id:userID}, {params:{id:userID},});
129 +}
130 +function deleteContact(userID){
131 + return axios.post('api/contact/contact_delete', {id:userID}, {params:{id:userID}});
123 } 132 }
124 133
125 export { 134 export {
...@@ -143,5 +152,6 @@ export { ...@@ -143,5 +152,6 @@ export {
143 modifyFile, 152 modifyFile,
144 uploadContact, 153 uploadContact,
145 downloadContact, 154 downloadContact,
146 - printContact 155 + printContact,
156 + deleteContact
147 }; 157 };
......
This diff is collapsed. Click to expand it.
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
8 <th class="text-left">Name</th> 8 <th class="text-left">Name</th>
9 <th class="text-left">Phone</th> 9 <th class="text-left">Phone</th>
10 <th class="text-left">Email</th> 10 <th class="text-left">Email</th>
11 - <th class="text-left">Date</th>
12 </tr> 11 </tr>
13 </thead> 12 </thead>
14 <tbody> 13 <tbody>
...@@ -16,7 +15,6 @@ ...@@ -16,7 +15,6 @@
16 <td>{{ item.name }}</td> 15 <td>{{ item.name }}</td>
17 <td>{{ item.phone}}</td> 16 <td>{{ item.phone}}</td>
18 <td>{{ item.email }}</td> 17 <td>{{ item.email }}</td>
19 - <td>{{ item.added_date}}</td>
20 </tr> 18 </tr>
21 </tbody> 19 </tbody>
22 </template> 20 </template>
...@@ -32,12 +30,13 @@ ...@@ -32,12 +30,13 @@
32 </div> 30 </div>
33 <br /> 31 <br />
34 <v-btn color="blue" @click="upload_contact">upload</v-btn> 32 <v-btn color="blue" @click="upload_contact">upload</v-btn>
35 - <v-btn color="blud" @click = "download_contact">download</v-btn> 33 + <v-btn color="green" @click = "download_contact">download</v-btn>
34 + <v-btn color="gray" @click = "delete_contact">delete</v-btn>
36 </v-flex> 35 </v-flex>
37 </template> 36 </template>
38 37
39 <script> 38 <script>
40 - import { uploadContact, downloadContact, printContact } from '../api/index'; 39 + import { uploadContact, downloadContact, printContact, deleteContact } from '../api/index';
41 import Axios from 'axios'; 40 import Axios from 'axios';
42 export default { 41 export default {
43 data() { 42 data() {
...@@ -51,10 +50,10 @@ ...@@ -51,10 +50,10 @@
51 const curData = { 50 const curData = {
52 id : this.$store.state.id, 51 id : this.$store.state.id,
53 } 52 }
54 - console.log(curData); 53 + const list_reponse = await printContact(curData.id);
55 - const list_reponse = await printContact(curData); 54 + this.$store.commit('setContactList', list_reponse.data.contact_list);
56 - this.$store.commit('setContactList', list_reponse);
57 this.contact_list = this.$store.getters.contact; 55 this.contact_list = this.$store.getters.contact;
56 + console.log(list_reponse);
58 } catch (error) { 57 } catch (error) {
59 console.log("에러"); 58 console.log("에러");
60 console.log(error); 59 console.log(error);
...@@ -74,21 +73,20 @@ ...@@ -74,21 +73,20 @@
74 try { 73 try {
75 const formData = new FormData(); 74 const formData = new FormData();
76 formData.append('file', this.contact_file); 75 formData.append('file', this.contact_file);
77 - formData.append('id', this.$store.state.id);
78 const currentData = { 76 const currentData = {
79 id: this.$store.state.id 77 id: this.$store.state.id
80 }; 78 };
81 const fileData = { 79 const fileData = {
82 id: this.$store.state.id, 80 id: this.$store.state.id,
83 - file: this.contact_file 81 + file: formData
84 } 82 }
85 console.log(fileData); 83 console.log(fileData);
86 - const response = await uploadContact(formData); 84 + const response = await uploadContact(fileData);
87 - const contact_response = await printContact(currentData); 85 + const contact_response = await printContact(currentData.id);
88 console.log(contact_response); 86 console.log(contact_response);
89 - this.$store.commit('setContactList', contact_response); 87 + this.$store.commit('setContactList', contact_response.data.contact_list);
90 console.log(this.$store.getters.contact); 88 console.log(this.$store.getters.contact);
91 - this.contact_list = contact_response; 89 + this.contact_list = this.$store.getters.contact;
92 } catch (error) { 90 } catch (error) {
93 console.log('에러'); 91 console.log('에러');
94 console.log(error); 92 console.log(error);
...@@ -100,12 +98,29 @@ ...@@ -100,12 +98,29 @@
100 id: this.$store.state.id 98 id: this.$store.state.id
101 }; 99 };
102 console.log(curData); 100 console.log(curData);
103 - const response = await downloadContact(curData); 101 + const response = await downloadContact(curData.id);
104 console.log(response); 102 console.log(response);
105 }catch(error){ 103 }catch(error){
106 console.log('에러'); 104 console.log('에러');
107 console.log(error); 105 console.log(error);
108 } 106 }
107 + },
108 + async delete_contact(){
109 + try{
110 + const curData = {
111 + id: this.$store.state.id
112 + };
113 + const response_d = await deleteContact(curData.id);
114 +
115 + const contact_response = await printContact(curData.id);
116 +
117 + this.$store.commit('setContactList', contact_response.data.contact_list);
118 +
119 + this.contact_list = this.$store.getters.contact;
120 + }catch(error){
121 + console.log('에러');
122 + console.log(error);
123 + }
109 } 124 }
110 125
111 } 126 }
......