
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(请求失败)

mapper
//批量删除
@delete("delete from people where id in (#{id})")
void deletebatch(list<integer> id);service
/**
* 根据用户名删除用户
*/
public void deletepeoplebyusername(string username) {
peoplesmapper.deletebyusername(username);
}到此这篇关于vue+springboot用户注销功能的文章就介绍到这了,更多相关vue springboot用户注销内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!
发表评论