vue+springboot用戶注銷功能實現(xiàn)代碼
更新時間:2024年05月21日 12:10:02 作者:檀玥
這篇文章主要介紹了vue+springboot用戶注銷功能,本文通過示例代碼給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧

vue文件前端
<el-button type="warning" plain @click="handleDeletion">注 銷</el-button>
// 注銷
const handleDeletion = (userName) => {
ElMessageBox.confirm('注銷該用戶所有信息后無法恢復,您確認注銷嗎?', '注銷確認', { type: 'warning' }).then(() => {
const userName = data.form.username;
request.delete('http://localhost:9090/peoples/deletePeople/' + userName).then(res => {
if (res.code === '200') {
ElMessage.success("操作成功")
router.push('/login')
} else {
ElMessage.error(res.msg)
}
})
}).catch(res => {
console.error('Delete request failed');
})
}springboot后臺
controller
/**
* 注銷
* @param userName
*/
@DeleteMapping("/deletePeople/{userName}")
public Result deletePeople(@PathVariable String userName){
peopleService.deletePeopleByUsername(userName);
return Result.success();
}其中Result是寫的一個公共方法
code是等于200(請求成功)還是500(請求失?。?/p>

mapper
//批量刪除
@Delete("delete from people where id in (#{id})")
void deleteBatch(List<Integer> id);service
/**
* 根據(jù)用戶名刪除用戶
*/
public void deletePeopleByUsername(String username) {
peoplesMapper.deleteByUsername(username);
}到此這篇關于vue+springboot用戶注銷功能的文章就介紹到這了,更多相關vue springboot用戶注銷內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
- 詳解springboot?springsecuroty中的注銷和權限控制問題
- SpringBoot使用Spring Security實現(xiàn)登錄注銷功能
- SpringBoot--- SpringSecurity進行注銷權限控制的配置方法
- Vue+springboot批量刪除功能實現(xiàn)代碼
- springboot和vue前后端交互的實現(xiàn)示例
- SpringBoot3結合Vue3實現(xiàn)用戶登錄功能
- 基于SpringBoot和Vue3的博客平臺的用戶注冊與登錄功能實現(xiàn)
- SpringBoot和Vue.js實現(xiàn)的前后端分離的用戶權限管理系統(tǒng)
- 詳解SpringBoot項目整合Vue做一個完整的用戶注冊功能
- Vue結合Springboot實現(xiàn)用戶列表單頁面(前后端分離)
相關文章
element-ui配合node實現(xiàn)自定義上傳文件方式
這篇文章主要介紹了element-ui配合node實現(xiàn)自定義上傳文件方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-09-09
vue中通過使用$attrs實現(xiàn)組件之間的數(shù)據(jù)傳遞功能
組件之間傳遞數(shù)據(jù)的方式有很多種,之所以有這么多種方式,是為了滿足在不同場景不同條件下的使用。這篇文章主要介紹了vue中通過使用$attrs實現(xiàn)組件之間的數(shù)據(jù)傳遞,需要的朋友可以參考下2019-09-09
vue中的v-model原理,與組件自定義v-model詳解
這篇文章主要介紹了vue中的v-model原理,與組件自定義v-model詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-08-08

