adidas clone 프로젝트 후기

JM·2020년 7월 5일
1

Project

목록 보기
1/11

adidas clone 프로젝트 소개

  • 스포츠 브랜드 adidas 한국 웹사이트를 클론하는 프로젝트.
  • 모든 카테고리가 아닌 남성 신발로 범위를 한정하여 구현.
  • Frontend와 처음으로 협업을 진행을 하고 github을 처음으로 사용.

Github

Github_adidas_clone

데모 영상

데모영상

구성원

  • Frontend 2명
  • Backend 3명

기간

200622 ~ 200703 (2주)

사용된 기술

  • Python, Django web framework
  • Beautifulsoup, Selenium
  • Bcrypt
  • JWT
  • MySQL
  • CORS headers
  • Git
  • Github
  • Postman

이번 프로젝트에 역할

  • Aquery tool을 이용하여 모델링 작성에 참여
  • 모델링을 통한 앱 작성 및 모델 작성
  • Mysql DB 구축
  • Data uploader 작성
  • 제품 전체 페이지, 상세 페이지, 리뷰 endpoint 구현
  • 각 페이지 Pagination

잘한 점

  • 모델링을 통해 각 테이블 간의 관계를 이해하였고 다른 프로젝트를 하더라도 논리와 근거에 맞게 작성을 할 수 있도록 학습
  • 코드 피드백을 받고 코드의 가독성을 높임
  • 팀원들과 의사소통을 원활하게 하며 행복하게 프로젝트 진행

아쉬운 점

  • 주문 기능을 완성하지 못한 부분
  • 처음부터 클린 코드에 대한 생각을 하지 못한 부분
  • Data를 주고받는 형태에 있어 Frontend와 처음부터 얘기하지 못하여 시간을 낭비한 부분
  • 예외 처리를 제대로 하지 못한 부분

아쉬운 점을 통해 느낀점

  • 업무 분담을 확실히 해야 한다.
  • 구현하는 기능들에 대해 시간 분배가 꼭 필요하다.
  • 내 코드에 대한 스스로 리뷰가 필요하다.
  • 성능에 대해서 생각을 해야 한다.
  • 예외 처리를 확실하게 해야 한다.

기억하고 싶은 코드/함수/로직

(1)

class TotalView(View):
    def get(self, request):    
        target_id = request.GET.get("id", None)
        all_sports = Product.objects.prefetch_related('gender','sport','tag','image_set','detail','size','color').all()[:40]
        product_list = [
        {
            'id'               : shoe.id,
            'name'             : shoe.name,
            'sport'            : shoe.sport.name,
            'tag'              : shoe.tag.name,
            'gender'           : shoe.gender.name,
            'use'              : shoe.detail.purpose,
            'original_price'   : round(shoe.price),
            'sale_price'       : round(shoe.discount_price),
            'sizes'            : [size_info.name for size_info in shoe.size.all()],
            'color'            : [color.name for color in shoe.color.all()][0],
            'main_images'      : [img.img_url for img in shoe.image_set.filter(product_id=shoe.id)[:2]],
            'sub_images'       : [sub_img.img_url for sub_img in shoe.image_set.filter(product_id = shoe.id,is_sub_img=True)],
            'color_number'     : len(shoe.image_set.filter(product_id = shoe.id,is_sub_img=True))
        } for shoe in all_sports]

        return JsonResponse({"total_product":product_list}, status=200)
  • 전체 상품 리스트를 불러오는 함수인데 기존 코드를 List comprehension을 통해 코드가 간결해지고 가독성이 높였다.
  • 이 코드에 대한 피드백을 받으며 성능, 코드의 간결함에 대해 생각을 하게 되었다.
  • 코드를 잘짜서 기억하기 보단 이 코드를 통해 생각했던 점을 기억하고 싶다.

(2)

from django.db import models

from account.models import Account
from order.models import Order

class Category(models.Model):
    name = models.CharField(max_length = 50)

    class Meta:
        db_table = "categories"

class Gender(models.Model):
    name = models.CharField(max_length = 20)

    class Meta:
        db_table = "gender"

class Sport(models.Model):
    name = models.CharField(max_length = 50)

    class Meta:
        db_table = "sports"

class Tag(models.Model):
    name = models.CharField(max_length = 20)

    class Meta:
        db_table = "tags"

class Review(models.Model):
    account         = models.ForeignKey("account.Account", on_delete=models.SET_NULL,null =True)
    product         = models.ForeignKey("Product", on_delete=models.SET_NULL,null =True)
    date            = models.DateTimeField(auto_now_add = True)
    comment         = models.CharField(max_length = 200)
    point           = models.IntegerField(default=1)
    
    class Meta:
        db_table = "reviews"

class Product (models.Model):
    category            = models.ForeignKey("Category", on_delete=models.SET_NULL, null= True, related_name='category_product')
    gender              = models.ForeignKey("Gender", on_delete=models.SET_NULL,null =True, related_name='gender_product')
    sport               = models.ForeignKey("Sport", on_delete=models.SET_NULL, null =True, related_name='sport_product')
    name                = models.CharField(max_length=50)
    tag                 = models.ForeignKey("Tag", on_delete=models.SET_NULL,null =True, related_name='tag_product')
    price               = models.DecimalField(max_digits=16, decimal_places=2)
    discount_price      = models.DecimalField(max_digits=16, decimal_places=2,default =0)
    description         = models.CharField(max_length=1500)
    detail              = models.OneToOneField("Detail", on_delete=models.SET_NULL , null =True, related_name='detail_product')
    size                = models.ManyToManyField("Size", through='ProductSize', related_name='size_product')
    code                = models.CharField(max_length = 50, default="")
    color               = models.ManyToManyField("Color", through='MiddleColorImage', related_name='colors_product')
    review_account      = models.ManyToManyField("account.Account", through='Review', related_name='reviews_product')
    
    class Meta:
        db_table = "products"

class Color(models.Model):
    name    = models.CharField(max_length=50)
    
    class Meta:
        db_table = "colors"

class MiddleColorImage(models.Model):
    product     = models.ForeignKey("Product", on_delete=models.SET_NULL, null =True)
    color       = models.ForeignKey("Color", on_delete=models.SET_NULL, null =True)

    class Meta:
        db_table = "middle_colorimages"

class Image(models.Model):
    img_url           = models.CharField(max_length=300)
    product           = models.ForeignKey("Product", on_delete=models.SET_NULL, null =True)
    is_sub_img        = models.BooleanField(default=False)

    class Meta:
        db_table = "images"

class Size (models.Model):
    name = models.CharField(max_length=10)

    class Meta:
        db_table = "sizes"

class ProductSize (models.Model):
    product     = models.ForeignKey("Product", on_delete=models.SET_NULL,null =True)
    size        = models.ForeignKey("Size", on_delete=models.SET_NULL,null=True)
    
    class Meta:
        db_table = "product_sizes"

class Detail (models.Model):
    code                = models.CharField(max_length = 50)
    purpose             = models.CharField(max_length = 50)
    material            = models.CharField(max_length = 200)
    origin              = models.CharField(max_length = 50)
    manufacturing_date  = models.CharField(max_length = 50)
    
    class Meta:
        db_table = "detail"
  • product app의 model 코드이다.
  • 프로젝트를 처음 시작하며 모델링과 관련하여 많은 생각을 하게 되었다.
  • 서비스를 구현함에 있어 Backend 측면에서 고려해야 될 부분이 많다는 점을 느꼈다.
  • 각 테이블 간의 관계를 어떻게 설정하느냐에 따라 성능이 달라질 수 있다는 개념을 경험하였다.
  • one to one, one to many, many to many 관계를 배웠고 이를 활용할 수 있게 되어 기억하고 싶다.

0개의 댓글