package com.user.service.web.controller;

import com.base.orbit.domain.AjaxResult;
import com.base.orbit.domain.enity.SysUser;
import com.user.service.service.ILoginServcie;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 设置SpringSecurity过滤器链将登录接口进行放行
 * 通过AuthenticationManager的authenticate方法来进行用户认证
 * 认证成功后返回jwt，将用户信息存入redis
 */
@RestController
@Api(tags = "登录管理")
public class LoginController {

    @Autowired
    private ILoginServcie loginServcie;

    @ApiOperation(value = "登录")
    @PostMapping("/user/login")
    public AjaxResult login(@RequestBody SysUser user) {
        return loginServcie.login(user);
    }


    @ApiOperation(value = "登出")
    @RequestMapping(value = "/user/logout", method = RequestMethod.GET)
    public AjaxResult logout() {
        return loginServcie.logout();
    }


}
