본문 바로가기

My Proect/파이널 프로젝트 - CineDate

19일차 - 슈퍼 리스트 화면 구현 및 기능 구현

슈퍼 리스트란?

CineDate에서 판매하는 콘을 결제하면 제일 상단 3명만 보여지는 리스트이다 !

돈을 쓰기 때문에 일반 리스트와는 다르게 좀 꾸며보았다.



DateProfile.xml
<select id= "superPartner" resultType="com.tenco.movie.repository.model.DateProfile">
		SELECT p.*,
		CASE
		WHEN m1.status IS NULL AND m2.status IS NULL
		THEN 0
		WHEN m1.status IS NOT NULL THEN
		CASE
		WHEN m1.status = 0 THEN 1
		WHEN m1.status = 1 THEN 2
		END
		WHEN m2.status IS
		NOT NULL THEN
		CASE
		WHEN m2.status = 0 THEN 1
		WHEN m2.status = 1 THEN 2
		END
		ELSE 0
		END AS status
		FROM profile_tb AS p
		JOIN user_tb AS u ON u.id = p.user_id
		LEFT JOIN matching_tb AS m1 ON
		(u.id = m1.r_user_id AND m1.s_user_id = #{userId})
		LEFT JOIN matching_tb
		AS m2 ON (u.id = m2.s_user_id AND m2.r_user_id = #{userId})
		WHERE u.id
		!= #{userId}
		AND u.gender != #{gender} AND p.list_status = 1 limit 3;
	</select>

 

 

 

DateController
/**
	 * 데이트 페이지 요청
	 * 
	 * @author 배병호 principal 기준으로 회원가입 페이지 date page or 회원가입 페이지 전화
	 * @author 김가령
	 * @author 유형정 슈퍼 리스트 추가
	 */
	@GetMapping("/date")
	public String getDatePage(@SessionAttribute(value = Define.PRINCIPAL, required = false) User principal, Model model, RedirectAttributes redirectAttributes) {
		/**
		 * 데이트 페이지 들어갈때 로그인 안되있으면 로그인 하라고 방어코드 추가함
		 * 
		 * @author 성후
		 */
		if (principal == null) {
			redirectAttributes.addFlashAttribute(Define.ENTER_YOUR_LOGIN, HttpStatus.BAD_REQUEST);
			return "redirect:/user/signIn"; // 로그인으로 리다이렉트
		}

		DateProfile proifile = dateService.searchProfile(principal.getId());
		if (proifile == null) {
			return "date/DateSignUp";
		} else if(proifile.getLifeStatus() == 1) {
			throw new DataDeliveryException(Define.PROFILE_SUSPENDING, HttpStatus.BAD_REQUEST);
		}
		
		List<DateProfile> list = dateService.searchPartner(principal.getId(), principal.getGender());
		System.out.println(list);
		
		List<DateProfile> superList = dateService.superPartner(principal.getId(), principal.getGender());
		System.out.println("superList : " + superList);

		model.addAttribute("list", list);
		model.addAttribute("superList", superList);

		return "date/ProfileList";
	}

 

 

 

DateProfileService
/**
	 * 슈퍼 파트너 리스트 / 상단 고정 3개
	 * @param principalId
	 * @param principalGender
	 * @return
	 */
	public List<DateProfile> superPartner(int principalId, String principalGender){
		
		List<DateProfile> superPartnerList = null;
		
		superPartnerList = profileRepository.superPartner(principalId, principalGender);
		
		return superPartnerList;
		
	}

 

 

 

ProfileList.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- header.jsp -->
<meta name="_csrf" content="${_csrf.token}">
<%@ include file="/WEB-INF/view/layout/header.jsp"%>

<div id="wrap">
	<div id="in--wrap">
	
		<h1 class="section--title super">슈퍼 리스트🍿</h1>
		<div class="table--scroll super--scroll">
			<c:choose>
				<c:when test="${superList != null}">
					<table class="table super--table">
						<tr class="table--title">
							<th>사진</th>
							<th>닉네임</th>
							<th>자기소개</th>
							<th>신청</th>
						</tr>
						<c:forEach var="superList" items="${superList}">
							<tr>
								<td><img class="m--profile list--profile super--profile" alt="슈퍼 프로필 사진" src="/DateProfileIMAGE/${superList.firstUploadFileName}"></td>
								<td>${superList.nickName}</td>
								<td>${superList.introduce}</td>
								<td>
									<c:choose>
										<c:when test="${superList.status == 2}">
											<button onclick="openChat('${superList.userId}')">매칭완료(대화창열기)</button>
										</c:when>
										<c:otherwise>
											<button onclick="openPopup('${superList.userId}')">상세 보기</button>
										</c:otherwise>
									</c:choose>
								</td>
							</tr>
						</c:forEach>
					</table>
				</c:when>
				<c:otherwise>
					<div class="jumbotron display-4">
						<h1>📽</h1>
						<h5>아무도 없어요 💦</h5>
					</div>
				</c:otherwise>
			</c:choose>
			
			<!-- 슈퍼 리스트의 효과  -->
			<div class="bubble b1"></div>
			<div class="bubble b2"></div>
			<div class="bubble b3"></div>
			<div class="bubble b4"></div>
			<div class="bubble b5"></div>
			<div class="bubble b6"></div>
			<div class="bubble b7"></div>
		</div>
		
		<h1 class="section--title">일반 리스트</h1>
		<div class="table--scroll">
			<c:choose>
				<c:when test="${list != null}">
					<table class="table">
						<tr class="table--title">
							<th>사진</th>
							<th>닉네임</th>
							<th>자기소개</th>
							<th>신청</th>
						</tr>
						<c:forEach var="list" items="${list}">
							<tr>
								<td><img class="m--profile list--profile" alt="프로필 사진" src="/DateProfileIMAGE/${list.firstUploadFileName}"></td>
								<td>${list.nickName}</td>
								<td>${list.introduce}</td>
								<td>
									<c:choose>
										<c:when test="${list.status == 2}">
											<button onclick="openChat('${list.userId}')">매칭완료(대화창열기)</button>
										</c:when>
										<c:otherwise>
											<button onclick="openPopup('${list.userId}')">상세 보기</button>
										</c:otherwise>
									</c:choose>
								</td>
							</tr>
						</c:forEach>
					</table>
				</c:when>
				<c:otherwise>
					<div class="jumbotron display-4">
						<h1>📽</h1>
						<h5>아무도 없어요 💦</h5>
					</div>
				</c:otherwise>
			</c:choose>
		</div>

	</div>
</div>

<%@ include file="/WEB-INF/view/layout/footer.jsp"%>

 

728x90