package com.changhu.controller;

import com.changhu.common.annotation.JsonBody;
import com.changhu.common.pojo.vo.TokenInfo;
import com.changhu.pojo.params.LoginParams;
import com.changhu.service.LoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author 20252
 * @createTime 2024/8/28 下午5:12
 * @desc LoginController...
 */
@Tag(name = "登录相关")
@JsonBody
public class LoginController {

    @Autowired
    private LoginService loginService;

    @Operation(summary = "登录")
    @PostMapping("/login")
    public TokenInfo login(@RequestBody LoginParams loginParams) {
        return loginService.login(loginParams);
    }

    @Operation(summary = "登出")
    @GetMapping("/logout")
    public void logout() {
        loginService.logout();
    }
}
