当前位置: 代码网 > it编程>编程语言>Javascript > vue+springboot用户注销功能实现代码

vue+springboot用户注销功能实现代码

2024年06月11日 Javascript 我要评论
vue文件前端 <el-button type="warning" plain @click="handledeletion">注 销</el-button>// 注销cons

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用户注销内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com