Day20(4.8)

ShinJuYong·2022년 4월 8일
0

camp

목록 보기
20/44
post-thumbnail

N:M

Services (비즈니스로직)

  // N:M
    // productTags // ["#전자제품", "#영등포", "#컴퓨터"]
    const tagResults = [];
    // ForEach로 처리하면 한번에 (비동기)로 처리가된다.
    // productTags.forEach(async (e) => {
    //   const tagname = e.replace('#', '');

    //   const prevTag = await this.productTagRepository.findOne({
    //     name: tagname,
    //   });

    //   if (prevTag) {
    //     tagResults.push(prevTag);
    //   } else {
    //     tagResults.push(
    //       await this.productTagRepository.save({ name: tagname }),
    //     );
    //   }
    // });

    for (let i = 0; i < productTags.length; i++) {
      const tagname = productTags[i].replace('#', '');

      // 이미 등록된 태그인지 확인하기
      const prevTag = await this.productTagRepository.findOne({
        name: tagname,
      });

      if (prevTag) {
        // 이미등록됐다면 결과에 바로 푸쉬해준다
        tagResults.push(prevTag);
      } else {
        // 없다면 새로 생성해서 푸쉬한다.
        tagResults.push(
          await this.productTagRepository.save({ name: tagname }),
        );
      }
    }

    return this.productRepository.save({
      ...product,
      productSaleslocation: result, //{ id: result.id }, 동일하게 인식한다.
      productCategory: { id: productCategoryId },
      productTags: tagResults,
    });

dto

Login

로그인을 하려는 유저가 많을수록 DB에저장된 데이터를 불러오기때문에 DB의 부하가 많아져
DB를분할하고, 그 분할한 DB에 Redis까지 얹는다..

JWT

JSON이나 전달받은 (Rquest)내용을 JWT방식으로 암호화한 이후 Client로 암호화한 JWT Key를 보내준다

TIL Git

강의-깃허브
숙제-깃허브

알고리즘

Week4 Test : PASS

0개의 댓글