본문으로 건너뛰기

Repository Definition

Basic Structure

repository_test:
EntityName:
methods:
- id: methodName
query: "JPQL 또는 Native SQL"
params:
paramName: paramType
return: ReturnType
nativeQuery: true/false

Repository 예시

repository_test:
Article:
methods:
- id: findByTitleContaining
query: "SELECT a FROM Article a WHERE a.title LIKE :title"
params:
title: string
return: List<Article>

- id: findByBoardAndDateRange
query: "SELECT a FROM Article a WHERE a.board.bid = :boardId AND a.createDate BETWEEN :startDate AND :endDate"
params:
boardId: long
startDate: datetime
endDate: datetime
return: List<Article>

- id: getArticleStatistics
query: "SELECT b.name as boardName, COUNT(*) as articleCount FROM Article a JOIN a.board b GROUP BY b.bid, b.name"
return: List<Map<String, Object>>
nativeQuery: false

Transaction Port Definition

Transaction Port는 외부 시스템과의 통신을 정의하는 DSL입니다. 더 자세한 내용은 Port Reference.

Basic Structure

transaction:
dto:
DTOName:
fields:
fieldName: fieldType -- 설명

port:
PortName:
meta: type @configuration
methods:
methodName:
params:
paramName: paramType
return: ReturnType

Port Types

  • dbms: 데이터베이스 직접 연동
  • http: HTTP API 연동

Port Configuration

  • @datasource("name"): 데이터소스 지정
  • @url("baseUrl"): HTTP 기본 URL

Transaction Port Example

transaction:
dto:
BoardInfo:
fields:
boardId: long -- 게시판 ID
name: string -- 게시판명
articleCount: int -- 글 수

CarInfoOutput:
fields:
brand: string -- 브랜드명
modelId: string -- 모델 ID
description: string -- 설명

port:
BoardService:
meta: dbms @datasource("main")
methods:
getBoardInfo:
params:
boardId: long
return: BoardInfo

getArticleList:
params:
boardId: long
page: int
size: int
return: List<Article>

ExternalApiPort:
meta: http @url("https://api.external.com")
methods:
getUserInfo:
meta: method @HttpEndpoint(url="/users/{userId}", method="GET")
params:
userId: string
return: Map<String, Object>

createUser:
meta: method @HttpEndpoint(url="/users", method="POST")
params:
body: UserRequest @body
return: UserResponse