feat: 가계부·게시판 백엔드 API 구현
- com.sb.web 패키지로 재구성: account / auth / board / user / admin / common - 가계부(account): 내역(필터), 계좌·순자산, 예산, 분류, 정기 거래, 투자 포트폴리오 (종목·매매 이력, 이동평균 평단·실현/평가손익) - MyBatis + MariaDB + Redis 세션, BCrypt - 스키마 자동 초기화(db/*.sql, 멱등), 사용자별 데이터 격리(member_id) - 문서: docs/BACKEND.md, .env.example Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
9243a41385
commit
2a2f81dc32
@@ -0,0 +1,51 @@
|
||||
package com.sb.web.auth.controller;
|
||||
|
||||
import com.sb.web.auth.dto.LoginRequest;
|
||||
import com.sb.web.auth.dto.LoginResponse;
|
||||
import com.sb.web.auth.dto.MemberResponse;
|
||||
import com.sb.web.auth.dto.SessionUser;
|
||||
import com.sb.web.auth.dto.SignupRequest;
|
||||
import com.sb.web.auth.service.AuthService;
|
||||
import com.sb.web.auth.web.AuthInterceptor;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 인증 API.
|
||||
* POST /api/auth/signup 회원가입 (비보호)
|
||||
* POST /api/auth/login 로그인 (비보호)
|
||||
* POST /api/auth/logout 로그아웃 (보호)
|
||||
* GET /api/auth/me 내 정보 (보호)
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/auth")
|
||||
@RequiredArgsConstructor
|
||||
public class AuthController {
|
||||
|
||||
private final AuthService authService;
|
||||
|
||||
@PostMapping("/signup")
|
||||
public ResponseEntity<MemberResponse> signup(@Valid @RequestBody SignupRequest req) {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(authService.signup(req));
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public LoginResponse login(@Valid @RequestBody LoginRequest req) {
|
||||
return authService.login(req);
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
public ResponseEntity<Void> logout(HttpServletRequest request) {
|
||||
authService.logout(AuthInterceptor.resolveToken(request));
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@GetMapping("/me")
|
||||
public SessionUser me(@RequestAttribute(AuthInterceptor.CURRENT_MEMBER) SessionUser current) {
|
||||
return current;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user