vue+springboot用户注销功能

vue文件前端

html 复制代码
 <el-button type="warning" plain @click="handleDeletion">注 销</el-button>
javascript 复制代码
// 注销
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

java 复制代码
   /**
     * 注销
     * @param userName
     */
    @DeleteMapping("/deletePeople/{userName}")
    public Result deletePeople(@PathVariable String userName){
        peopleService.deletePeopleByUsername(userName);
        return Result.success();
    }

其中Result是写的一个公共方法

code是等于200(请求成功)还是500(请求失败)

mapper

java 复制代码
   //批量删除
    @Delete("delete from people where id in (#{id})")
    void deleteBatch(List<Integer> id);

service

java 复制代码
  /**
     * 根据用户名删除用户
     */
    public void deletePeopleByUsername(String username) {
        peoplesMapper.deleteByUsername(username);
    }
相关推荐
xiaoyustudiowww2 分钟前
fetch异步简单版本(Tomcat 9)
java·前端·tomcat
TOPGUS2 分钟前
谷歌Chrome浏览器即将对HTTP网站设卡:突出展示“始终使用安全连接”功能
前端·网络·chrome·http·搜索引擎·seo·数字营销
C_心欲无痕9 分钟前
ts - 模板字面量类型与 `keyof` 的魔法组合:`keyof T & `on${string}`使用
linux·运维·开发语言·前端·ubuntu·typescript
一勺菠萝丶14 分钟前
Java 后端想学 Vue,又想写浏览器插件?
java·前端·vue.js
AC赳赳老秦15 分钟前
Unity游戏开发实战指南:核心逻辑与场景构建详解
开发语言·spring boot·爬虫·搜索引擎·全文检索·lucene·deepseek
Java 码农17 分钟前
Spring Boot集成RabbitMQ的各种队列使用案例
spring boot·rabbitmq·java-rabbitmq
@PHARAOH19 分钟前
HOW - 如何禁用 localstorage
前端·状态模式
霍理迪20 分钟前
CSS布局方式——弹性盒子(flex)
前端·css
qq_124987075320 分钟前
基于springboot归家租房小程序的设计与实现(源码+论文+部署+安装)
java·大数据·spring boot·后端·小程序·毕业设计·计算机毕业设计
Irene199121 分钟前
Vue 3中:setup 函数接收两个重要参数:props 和 context(附:setup 中无法访问 this 详解)
vue.js·setup