package com.luojia_channel.modules.user.controller;

import com.luojia_channel.common.domain.Result;
import com.luojia_channel.common.domain.UserDTO;
import com.luojia_channel.modules.user.dto.UserLoginDTO;
import com.luojia_channel.modules.user.dto.UserRegisterDTO;
import com.luojia_channel.modules.user.service.UserLoginService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserLoginController {
    private final UserLoginService userLoginService;
    @PostMapping("/login")
    public Result<UserDTO> login(@RequestBody UserLoginDTO userLoginDTO){
        return Result.success(userLoginService.login(userLoginDTO));
    }

    @PostMapping("/register")
    public Result<UserDTO> register(@RequestBody UserRegisterDTO userRegisterDTO){
        return Result.success(userLoginService.register(userRegisterDTO));
    }

    @PostMapping("/logout")
    public Result logout(@RequestParam String accessToken){
        userLoginService.logout(accessToken);
        return Result.success();
    }

    @PostMapping("/hello")
    public Result<String> hello(){
        return Result.success("hello");
    }

}
