일기장/하루 정리

220310 [목] 검색 동적 Query 완성, Mapper 입력

Supersett 2022. 3. 10. 11:47

[문제 직면..!]

String 배열을 List에 집어넣어야하는 상황이 생겼다.

 

[문제 해결]

Arrays.asList(배열) 메소드를 통해 변환 완료!!

하루종일 머리를 싸맨 검색동적쿼리..!

<select id="selectDetailSearch" parameterType="map" resultMap="SearchedStoreResultMap">
		select a.sto_num,sto_name,rev_rated,cm_goal_people,sto_add1||sto_add2 address,
		sto_phone,cm_delivery_time,cm_close from store_tb a 
		left join common_tb b on a.sto_num = b.sto_num 
		left join (select cm_num, round(avg(rev_rated),1) rev_rated
		from review_tb group by cm_num) c on b.cm_num =c.cm_num 
		where cm_delivery_time &gt;= '#{delevery_time}' 
		and sto_zip_code||sto_add1||sto_add2 like '#{juso}';
		
		<if test="delivery_time2!=null">
			and cm_delivery_time='#{delivery_time}'
		</if>
		<if test="close_time!=null">
			and cm_close_time='#{cm_close_time}'
		</if>
		<if test="rated!=null">
			<foreach collection="rated" item="rated" open="(" close=")" separator="or">
				and rev_rated='#{rated}'
			</foreach>
		</if>
	</select>

 

 

[오늘 할일]

1. 동적쿼리 작성

2. 부트스트랩 프로젝트에 합치기

3. 면접 답변 준비