스프링 7

Spring 이미지 업로드 API 설계

✔ 이미지 업로드 API (ServiceImpl) - 기본 틀 (이미지가 없는 경우) @Override public JsonElement uploadImageImageVO image) { StopWatch watch = getStopWatch(); MultiValueMap params = new LinkedMultiValueMap(); try { if (image.getImage() == null) { return JsonParser.parseString(new Gson().toJson(new ResponseWithMessageVO(ApiCommonCode.ILLEGAL_PARAMETER, "이미지는 필수 항목입니다."))); } - 파일 형식 지정해주기 (조건) // 업로드된 이미지 파일 가져오기 Mu..

업무 기록/API 2023.05.26

Spring WatchaPedia 클론코딩 프로젝트 취향 분석(선호 배우, 국가, 장르, 감상 시간)

🎬 선호배우 분석 Service public List peopleCnt(Long userIdx){ Map peopleMap = new HashMap(); List movIdxs = starRepository.findStarMovie(userIdx); List peopleList = List.of(movieRepository.findPeopleList(movIdxs).toString() .split("\\[")[1].split("]")[0].split(", ")); for(String str: peopleList){ String[] personList = str.split(","); for(String per : personList){ if(per.contains("주연")){ Long personIdx ..

Spring 클론코딩 프로젝트 콘텐츠 DetailPage( 비슷한 장르의 작품 추천)

🎬 MovieRespose - Containing 이용하여 유사 장르 뽑기 List findByMovGenreContaining(String genre); 🎬 MovieService @Transactional(readOnly = true) public List similarGenre(String genre, Long movieIdx){ List result = new ArrayList(); List movieIdxList = new ArrayList(16); if(genre.contains("/")){ List genreList = Arrays.stream(genre.split("/")).toList(); HashMap containMovie = new HashMap(); for(String idx: g..

Spring 클론코딩 프로젝트 콘텐츠 DetailPage( 감상 가능한 곳, 유튜브(youtube) 예고편, 겔러리)

🎬 감상가능한 곳 타임리프 tb_movie 테이블의 mov_watch 컬럼에서 해당 movieIdx 값을 통해 해당하는 링크와 이미지 이름을 주기위해 타임리프에서 splt과 삼항연산자를 이용하여 구현하였다. th:title="${#strings.contains(wat,'aHR0cHM6Ly93d3cubmV0ZmxpeC5jb20vdGl0b')} or ${#strings.contains(wat,'netflix')}? '넷플릭스' : 1. {#strings.contains(wat,'aHR0cHM6Ly93d3cubmV0ZmxpeC5jb20vdGl0b' 이 부분은 넷플릭스의 고유 주소 값이다. 2. netflix 가 포함되어도 넷플릭스인걸 알 수 있기 때문에 타임리프에서 or 조건을 사용해서 1번과 2번이 포함되면..

Spring 클론코딩 프로젝트 콘텐츠 DetailPage( 출연/제작)

✔ 출연/제작 - Controller 부분 // 인물 리스트 List peopleList = new ArrayList(); List people = new ArrayList(); List personList = new ArrayList(); if(movie.people() != null){ peopleList = List.of(movie.people().split(",")); for(String per : peopleList){ people.add(per.split("\\(")[0] + "," + per.split("\\(")[1].split("\\)")[0]); } } try{ personList = personService.personList(people); }catch (Exception e){ S..

Spring 클론코딩 프로젝트 콘텐츠 DetailPage(별점,별점 그래프, 해당 유저 별점 달았는지)

✔ MovieController - @RequesdtMapping("/movie") 기본 주소 @Controller @RequestMapping("/movie") @RequiredArgsConstructor ✔ @GetMapping("/{movieIdx}") // http://localhost:8080/movie/1 @GetMapping("/{movieIdx}") // http://localhost:8080/movie/1 public String movieDetail( @PathVariable Long movieIdx, @PageableDefault(size = 5, sort = "commIdx", direction = Sort.Direction.DESC) Pageable pageable, ModelMa..

Spring 프로젝트 별점 순 출력

/* 별점 높은순 출력, 어느정도 인원이 평가해야(타임리프 적용) 0명이 평가한 경우 한명이 바로 5점을 주면 1등이 나오기 때문*/ @Transactional(readOnly = true) public List movieStar() { //평균 구하기 List result = new ArrayList(); // 평균점수가 최소 4.2 이상인 : 설정을 안할 경우 데이터가 없을경우 1점도 들어갈 수 있음 List result2 = new ArrayList(); // 평가한 인원이 최소 5명인 : 평가자가 0명인 경우 처음 평가한 이가 5점을 주면 바로 최고 점수 List result3 = new ArrayList(); List movieStar = movieRepository.findAll(); for(..