Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DTO 예시 #1

Open
puleugo opened this issue Apr 8, 2024 · 0 comments
Open

DTO 예시 #1

puleugo opened this issue Apr 8, 2024 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@puleugo
Copy link
Member

puleugo commented Apr 8, 2024

목록 응답 예시

class PostPreviewResponse:
    id: int
    title: str
    price: int
    rate: float
    completionCount: int
    completionTerm: int

    def __init__(self, id, title, price, rate, completionCount, completionTerm):
        self.id = id
        self.title = title
        self.price = price
        self.rate = rate
        self.completionCount = completionCount
        self.completionTerm = completionTerm


post = PostPreviewResponse(1, '제목', 12000, 3.5, 5, 30)
dbData = [
    {
        id: 1,
        title: '제목1',
        price: 12000,
        rate: 3.5,
        completionCount: 3,
        completionTerm: 5,
    },
    {
        id: 1,
        title: '제목1',
        price: 12000,
        rate: 3.5,
        completionCount: 3,
        completionTerm: 5,
    },
    {
        id: 1,
        title: '제목1',
        price: 12000,
        rate: 3.5,
        completionCount: 3,
        completionTerm: 5,
    }
]

response = PostPreviewResponse[]

for data in dbData:
    response.append(PostPreviewResponse(data.id, data.title, data.prie,
                        data.rate, data.completionCount, data.completionTerm));
@puleugo puleugo added the documentation Improvements or additions to documentation label Apr 8, 2024
@puleugo puleugo self-assigned this Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant