런타임 라이브러리
생성된 코드는 elasticore-springboot3(Spring Boot 3) 또는 elasticore-springboot4(Spring Boot 4) 위에서 돕니다. 둘 다
Java 패키지 io.elasticore.springboot3 를 쓰므로 Boot 버전이 바뀌어도 생성 코드의 import 는 그대로입니다. 생성기와
같은 버전으로 올리세요 - 생성 코드가 예전 런타임에는 없는 클래스를 씁니다.
지금 묻는 사람
| 클래스·필드 | 뜻 |
|---|---|
security.CurrentUser - currentUser.id(), signedIn(), hasRole("ADMIN") | 생성된 서비스가 보는 "지금 묻는 사람". 기본은 SessionCurrentUser, 내 빈이 대신할 수 있음 (Spring Security) |
CurrentUser.runAsSystem(() -> ...) | 애플리케이션 자신: 안에서는 모든 @access 검사가 통과 - 시작 데이터, 야간 작업 |
ACCESS.require(currentUser, "report") | 생성된 서비스의 필드: 직접 만든 연산에 엔티티의 @access 를 적용 - 방문자 401, 권한 없으면 403, 줄에 없는 연산은 관리자의 것 |
security.SessionCurrentUser.signIn(request, id, role), signOut(request) | 생성된 로그인이 쓰는 세션 - 나만의 흐름(가입과 동시에 로그인)에만 |
security.AccessPolicy, security.PasswordHasher | 바꿀 수 있는 빈 (기본 해셔는 PBKDF2) |
// 시작할 때 애플리케이션 자신으로 관리자 만들기
CurrentUser.runAsSystem(() -> customers.save(admin));
값 타입
| 클래스 | 뜻 |
|---|---|
domain.Money | money 필드의 타입. Money.of("10.00"), Money.of(bigDecimal)(null 이면 null), plus, minus, times(long), times(Quantity), times(BigDecimal), rounded(2)(반올림), toBigDecimal(), isNegative(), compareTo. plus(null)·minus(null) 은 같은 금액. 불변, 10 과 10.00 은 같음 |
domain.Quantity | quantity 필드의 타입: 음수 없음, 0 밑으로 minus 하면 422 not enough, plus, covers |
5.5 % VAT: net.times(new java.math.BigDecimal("0.055")).rounded(2).
거절
예외 (io.elasticore.springboot3.) | 응답 |
|---|---|
validation.BadRequestException | 400 |
security.NotSignedInException | 401 |
security.ForbiddenException | 403 |
validation.NotFoundException (또는 jakarta.persistence.EntityNotFoundException) | 404 |
validation.ConflictException | 409 |
validation.InvariantViolationException | state. 코드 409, reference. 404, 그 밖 422 |
http.PortCallException | 502 |
각각 번역용 (code, message, args...) 를 받습니다 - API 와 오류 응답.
만날 수 있는 그 밖의 것
| 클래스 | 뜻 |
|---|---|
EnableElastiCore | 포트 프록시 등록 (HTTP 런타임 방식, DBMS) |
validation.RequestShapeErrors | 컨트롤러 전의 problem+json 응답 - 생성된 XxxApiErrors 가 가져옴 |
validation.ErrorMessages, BeanValidation | 요청 언어로 메시지 찾기, 서비스 측 검증 |
util.IdUtils.newId(n) | @genid 의 ID 생성기 |
entity.PersistentModel | mapping: xml 도메인 클래스의 표식 (Kotlin all-open / no-arg) |
domain.Lookup | derive(lookup) 이 참조한 행을 읽는 것 |