개발일지

개발일지 74일차

index.ys 2023. 6. 18. 02:09

유저 프로필사진 변경 추가

  • imageIndex를 추가로 전달받음
  • redis에 이미지 url을 list형태로 저장
  • 전달받은 imageIndex에 해당하는 image url을 반환
  • imageindex가 5일때는 새롭게 전달받는 image를 db에 저장하여 사용자의 프로필 사진 변경
  updateimage = async (userId, userPhoto, imageIndex) => {


        if (userId == null) {
            throw new Error("401/유저 아이디가 null 입니다");
        }

        if (imageIndex <= 4) {
            const profileImageUrl = await redisClient.LINDEX("image", imageIndex);
            return profileImageUrl
        }

        else {
            if (!userPhoto) {
                console.log(userPhoto)
                throw new Error("401/유저 포토가 입력되지 않았습니다.");
            }
            await this.userRepository.updateimageById(
                userId,
                userPhoto,
            );
            return { message: "이미지를 수정하였습니다." }
        }

    };

Redis에 이미지 url 저장