박기범

add delete api

{
"accessKeyId": "ASIAXZL2SWFEQ3A42BQP",
"secretAccessKey": "7VxG6RfekqWejvtLfdgLtZbxpXcUg6NshtTueiUV",
"sessionToken": "FwoGZXIvYXdzEMP//////////wEaDBXRmjIedzbi/hfWTCLDAY+AZ+EfzHvy0eV/zjF53n2JhNPJADGD+T32qA6dsBBNs4EyfXoejbu/9k1Evr2h042JwGLb7rZpnEFk46KoGGqo/mBRr+PLlKExbfnPLE6s3SRT0sdqgXkXS+7gQ/Y4aBB1+WLBySso2GxwftcUEJS/pC2YUdonzEpypIRUGD87aJaaMKIc5i9U7oh8uDht2FXWBEIWjhJAkBd+xuMyrhjq474NYCbQlQtG5annxEz5F5MQuKBKCk4G2yPlkGQ7Z0DmgyiNzIL3BTItePAyPGDb/Mvl+8aUiEgkysdTY0YUMhLaepwCzwlV9nuyfpVV2SH5gMoDmKoD",
"region": "us-east-1"
"accessKeyId": "",
"secretAccessKey": "",
"sessionToken": "",
"region": ""
}
......
......@@ -109,17 +109,26 @@ function addFavoriteFile(fileData) {
return axios.post('api/favorites/addfile', fileData);
}
function uploadContact(contactData){
return axios.post('/api/contact/contact_upload', contactData,{
return axios.post('/api/contact/contact_upload', contactData.file,{
headers: {
'Content-Type': 'multipart/form-data',
},
params:{
id: contactData.id,
}
});
}
function downloadContact(userID){
return axios.post('/api/contact/contact_download', userID);
return axios.post('/api/contact/contact_download', null, {params:{id:userID}});
}
function printContact(userID){
return axios.post('/api/contact/contact_list', userID);
console.log(String(userID));
return axios.post('api/contact/contact_list', {id:userID}, {params:{id:userID},});
}
function deleteContact(userID){
return axios.post('api/contact/contact_delete', {id:userID}, {params:{id:userID}});
}
export {
......@@ -143,5 +152,6 @@ export {
modifyFile,
uploadContact,
downloadContact,
printContact
printContact,
deleteContact
};
......
This diff is collapsed. Click to expand it.
......@@ -8,7 +8,6 @@
<th class="text-left">Name</th>
<th class="text-left">Phone</th>
<th class="text-left">Email</th>
<th class="text-left">Date</th>
</tr>
</thead>
<tbody>
......@@ -16,7 +15,6 @@
<td>{{ item.name }}</td>
<td>{{ item.phone}}</td>
<td>{{ item.email }}</td>
<td>{{ item.added_date}}</td>
</tr>
</tbody>
</template>
......@@ -32,12 +30,13 @@
</div>
<br />
<v-btn color="blue" @click="upload_contact">upload</v-btn>
<v-btn color="blud" @click = "download_contact">download</v-btn>
<v-btn color="green" @click = "download_contact">download</v-btn>
<v-btn color="gray" @click = "delete_contact">delete</v-btn>
</v-flex>
</template>
<script>
import { uploadContact, downloadContact, printContact } from '../api/index';
import { uploadContact, downloadContact, printContact, deleteContact } from '../api/index';
import Axios from 'axios';
export default {
data() {
......@@ -51,10 +50,10 @@
const curData = {
id : this.$store.state.id,
}
console.log(curData);
const list_reponse = await printContact(curData);
this.$store.commit('setContactList', list_reponse);
const list_reponse = await printContact(curData.id);
this.$store.commit('setContactList', list_reponse.data.contact_list);
this.contact_list = this.$store.getters.contact;
console.log(list_reponse);
} catch (error) {
console.log("에러");
console.log(error);
......@@ -74,21 +73,20 @@
try {
const formData = new FormData();
formData.append('file', this.contact_file);
formData.append('id', this.$store.state.id);
const currentData = {
id: this.$store.state.id
};
const fileData = {
id: this.$store.state.id,
file: this.contact_file
file: formData
}
console.log(fileData);
const response = await uploadContact(formData);
const contact_response = await printContact(currentData);
const response = await uploadContact(fileData);
const contact_response = await printContact(currentData.id);
console.log(contact_response);
this.$store.commit('setContactList', contact_response);
this.$store.commit('setContactList', contact_response.data.contact_list);
console.log(this.$store.getters.contact);
this.contact_list = contact_response;
this.contact_list = this.$store.getters.contact;
} catch (error) {
console.log('에러');
console.log(error);
......@@ -100,12 +98,29 @@
id: this.$store.state.id
};
console.log(curData);
const response = await downloadContact(curData);
const response = await downloadContact(curData.id);
console.log(response);
}catch(error){
console.log('에러');
console.log(error);
}
},
async delete_contact(){
try{
const curData = {
id: this.$store.state.id
};
const response_d = await deleteContact(curData.id);
const contact_response = await printContact(curData.id);
this.$store.commit('setContactList', contact_response.data.contact_list);
this.contact_list = this.$store.getters.contact;
}catch(error){
console.log('에러');
console.log(error);
}
}
}
......