首页>代码>spring boot+spring mvc+springdata jpa实现简单的用户登录注册系统>/ycuser/src/main/java/com/example/ycuser/controller/AdminController.java
package com.example.ycuser.controller;


import com.example.ycuser.entity.User;
import com.example.ycuser.service.AdminServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminServiceImp adminServiceImp;
    //获取用户清单信息
    @RequestMapping("/users/all")
    public List<User> getAll(){
        return adminServiceImp.findAll();
    }
    //根据用户名查找用户信息
    @PostMapping("/users/by")
    public List<User> findByUsername(@RequestParam String username){
        return adminServiceImp.findByUsername(username);
    }
    //根据用户账号修改用户信息
    @PostMapping("/users/update")
    public int updateByJPQL(@RequestParam(required=false) String password,
                               @RequestParam(required=false) String username){
        System.out.printf("password="+password+"     username="+username);
        return adminServiceImp.updateByJPQL(password,username);
    }
    //根据用户名删除用户信息
    @PostMapping("/users/delete")
    public  int deleteByJPQL(@RequestParam String username) {
        return adminServiceImp.deleteByJPQL(username);
    }

    //新增一个用户
    @PostMapping("/users/add")
    public  User post(@RequestParam String username,
                      @RequestParam String password
                      ){
        User user= new User();
        user.setUsername(username);
        user.setPassword(password);
        return  adminServiceImp.save(user);
    }

}
最近下载更多
GJQ123  LV4 2023年12月29日
abrnya  LV1 2023年5月30日
ajdgqd  LV3 2022年11月1日
cgfeng12345  LV10 2022年10月14日
liuxiao2  LV16 2022年9月23日
super12  LV1 2022年7月28日
SCL_5757  LV1 2022年5月14日
1037491525  LV1 2022年4月8日
ksk23333  LV5 2022年3月19日
圈布拉克拉夸  LV1 2021年11月2日
最近浏览更多
GJQ123  LV4 2023年12月29日
chenlie  LV2 2023年11月13日
xiao小果  LV12 2023年9月11日
飞呀飞呀飞不放  LV7 2023年8月9日
shaoqi 2023年7月26日
暂无贡献等级
abrnya  LV1 2023年5月30日
lyd1233456  LV1 2023年2月21日
消防超高层防风衣 2022年12月27日
暂无贡献等级
xxg634460601  LV3 2022年12月19日
小赤0120  LV4 2022年12月3日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友