package com.spring.domain.user.api;

import javax.validation.Valid;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.spring.domain.user.dto.ChangePasswordRequest;
import com.spring.domain.user.dto.SignUpRequest;
import com.spring.domain.user.service.ChangePasswordService;
import com.spring.domain.user.service.SignUpService;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/user")
public class SignApi {
    
    private final SignUpService signUpService;
    private final ChangePasswordService changePasswordService;

    @GetMapping("/conflict/{userId}")
    public boolean isConflictUserId(@PathVariable String userId) {
        return signUpService.isConflictUserId(userId);
    }

    @PostMapping("/sign-up")
    public void signUp(@RequestBody @Valid SignUpRequest request) {
        signUpService.signUp(request);
    }

    @PostMapping("/change-password")
    public void changePassword(@RequestBody @Valid ChangePasswordRequest request) {
        changePasswordService.changePassword(request);
    }

}
