Spring_마무리

song·2023년 11월 7일

Spring

목록 보기
18/19

순서

  1. Controller
  2. Service
  3. Dao
  4. *Mapper
  5. Dto
  • 흐름은 1번부터 4번으로 흘러가며 5번인 Dto를 끼고 흘러가게 된다.
  • 코드를 짜는 것은 5번부터 1번 순서대로 짜는 것을 추천한다.

Mapper

like

select * from board where title like concat('%', #{title}, '%')
like %#{title}%

조건문

<choose>
  <when test = "option == 'T'">
    title like concat('%', #{keyword}, '%')
  </when>
  <when test = "option == 'W'">
    writer like concat('%', #{keyword}, '%')
  </when>
  <otherwise>
    title like concat('%', #{keyword}, '%')
    or content like concat('%', #{keyword}, '%')
  </otherwise>
</choose>

choose로 감싸고 when으로 조건문 사용. otherwise는 else나 default와 같음.
option은 #{option}으로 안써도 알아서 인식된다.

profile
계속 나아가기

0개의 댓글