首页>代码>spring boot+mybatis开发海底捞的排队系统(简易版)>/hdl/src/main/java/vip/waitfor/hdl/controller/UserController.java
package vip.waitfor.hdl.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import vip.waitfor.hdl.entity.User;
import vip.waitfor.hdl.service.IUserService;
import vip.waitfor.hdl.util.ResponseResult;

import javax.servlet.http.HttpSession;

/**
 * 处理管理员数据-控制器层
 *
 * @author 刘先生
 */
@RestController
@RequestMapping("user")
public class UserController extends BaseController {

    @Autowired
    private IUserService iUserService;
    //注册功能
//    @CrossOrigin
//    @RequestMapping("/reg")
//    public ResponseResult<Void> registration(User user){
//        //执行注册
//        iUserService.register(user);
//        //返回注册成功的数据
//        return new ResponseResult<Void>(SUCCESS);
//    }

    //登录功能
    @CrossOrigin
    @PostMapping("/login")
    public ResponseResult<User> handleLogin(@RequestParam("username") String username,
                                            @RequestParam("password") String password, HttpSession session) {
        //执行登录
        User user = iUserService.login(username, password);
        //将相关信息存入Session中
        session.setAttribute("uid", user.getUid());
        session.setAttribute("username", user.getUsername());
        //返回登录成功的数据
        return new ResponseResult<>(SUCCESS, user);
    }
}
最近下载更多
TY0165  LV20 2024年6月18日
autonomy  LV1 2024年4月12日
kkkllll  LV2 2024年1月24日
hbj1285984841  LV4 2023年10月19日
iceboard  LV2 2023年6月4日
万紫怡  LV4 2023年5月15日
youzitao  LV11 2023年4月17日
朱朱啊哈  LV16 2023年1月31日
LukeMaster  LV1 2022年11月19日
crosa_Don  LV18 2022年10月7日
最近浏览更多
Phoebe_HUI  LV5 1月14日
yimaoermao  LV1 2024年11月28日
17507331220 2024年11月19日
暂无贡献等级
grant1123  LV2 2024年6月22日
TY0165  LV20 2024年6月18日
来一杯西瓜冰咩  LV6 2024年5月14日
1941549176  LV4 2024年5月9日
autonomy  LV1 2024年4月12日
微信网友_6927932988952576  LV12 2024年3月31日
WBelong  LV8 2024年3月29日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友