feat: 포인트 적립내역 조회 — GET /auth/point-history
CI / build (push) Failing after 12m7s

- point_history 최신순 조회(최대 100건), PointHistoryResponse
- PointService.getHistory, 인터셉터 경로 등록

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ByungCheol
2026-06-28 14:44:24 +09:00
parent 629ab1f811
commit d1c13e7cc1
6 changed files with 44 additions and 1 deletions
@@ -87,6 +87,13 @@ public class AuthController {
return java.util.Map.of("points", pointService.getPoints(current.getId()));
}
/** 포인트 적립/차감 내역 (최신순) */
@GetMapping("/point-history")
public java.util.List<com.sb.web.point.PointHistoryResponse> pointHistory(
@RequestAttribute(AuthInterceptor.CURRENT_MEMBER) SessionUser current) {
return pointService.getHistory(current.getId());
}
@PutMapping("/password")
public ResponseEntity<Void> changePassword(
@Valid @RequestBody PasswordChangeRequest req,
@@ -25,7 +25,8 @@ public class WebConfig implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) {
// 인증: 로그인 필요한 경로 (관리자 경로 포함 — SessionUser 세팅용으로 먼저 실행)
registry.addInterceptor(authInterceptor)
.addPathPatterns("/api/auth/me", "/api/auth/points", "/api/auth/logout", "/api/auth/password",
.addPathPatterns("/api/auth/me", "/api/auth/points", "/api/auth/point-history",
"/api/auth/logout", "/api/auth/password",
"/api/auth/verify-password", "/api/auth/profile", "/api/auth/profile-image",
"/api/board/**", "/api/admin/**", "/api/account/**");
// 인가: 관리자 전용 경로 (authInterceptor 다음에 실행되어 role 검사)
@@ -0,0 +1,16 @@
package com.sb.web.point;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 포인트 적립/차감 내역 항목.
*/
@Data
public class PointHistoryResponse {
private Integer amount; // 증감 포인트(+/-)
private String reason; // BOARD_WRITE 등
private LocalDateTime createdAt;
}
@@ -38,4 +38,9 @@ public class PointService {
Long p = pointMapper.getPoints(memberId);
return p == null ? 0L : p;
}
/** 최근 포인트 적립/차감 내역 (최신순) */
public java.util.List<PointHistoryResponse> getHistory(Long memberId) {
return pointMapper.findHistory(memberId, 100);
}
}
@@ -1,8 +1,11 @@
package com.sb.web.point.mapper;
import com.sb.web.point.PointHistoryResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 포인트(member.points) 및 적립 이력(point_history) 매퍼.
*/
@@ -17,4 +20,7 @@ public interface PointMapper {
int addPoints(@Param("memberId") Long memberId, @Param("amount") int amount);
Long getPoints(@Param("memberId") Long memberId);
/** 최근 적립/차감 내역 (최신순, 최대 limit건) */
List<PointHistoryResponse> findHistory(@Param("memberId") Long memberId, @Param("limit") int limit);
}
@@ -21,4 +21,12 @@
SELECT points FROM member WHERE id = #{memberId}
</select>
<select id="findHistory" resultType="com.sb.web.point.PointHistoryResponse">
SELECT amount, reason, created_at
FROM point_history
WHERE member_id = #{memberId}
ORDER BY id DESC
LIMIT #{limit}
</select>
</mapper>