inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

인프런 워밍업 클럽 스터디 3기 - Backend <3주 발자국>

kdm
0

package com.example.portfolio.presentation.controller

import com.example.portfolio.presentation.dto.*
import com.example.portfolio.presentation.service.PresentationService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/api")
class PresentationApiController(
    private val presentationService: PresentationService

) {

    // rest controller이기 때문에 httml response body에 리턴한다.
    @GetMapping("/test")
    //== @RequestMapping(method = [RequestMethod.GET], name = "/test")
    // 이 외에도 postMappring과 PutMapping이 존재한다.
    fun test(): String {
        return "OK"
    }

    @GetMapping("/v1/introductions")
    fun getIntroductions(): List<IntroductionDTO> {
        // 중요한 작업들은 서비스에서 다 해준다.
        return presentationService.getIntroductions()
    }

    @GetMapping("/v1/links")
    fun getLinks(): List<LinkDTO> {
        return presentationService.getLinks()
    }


    @GetMapping("/v1/resume")
    fun getResume(): ResumeDTO {
        return presentationService.getResume()
    }
    @GetMapping("/v1/projects")
    fun getProjects(): List<ProjectDTO> {
        return presentationService.getProjects()
    }


    @GetMapping("/v1/articles")
    fun getArticles(): List<ArticleDTO> {
        return presentationService.getArticles()
    }


}
package com.example.portfolio.presentation.repository

import com.example.portfolio.domain.entity.*
import com.example.portfolio.domain.repository.*
import org.springframework.stereotype.Repository
import java.security.PrivateKey

@Repository
class PresentationRepository(
    private val achievementRepository: AchievementRepository,
    private val introductionRepository: IntroductionRepository,
    private val linkRepository: LinkRepository,
    private val skillRepository: SkillRepository,
    private val projectRepository: ProjectRepository,
    private val experienceRepository: ExperienceRepository,

    private val articleRepository: ArticleRepository
) {
    fun getActiveAchivements(): List<Achievement> {
        return achievementRepository.findAllByIsActive(true)
    }

    fun getActiveExperiences(): List<Experience> {
        return experienceRepository.findAllByIsActive(true)
    }

    fun getActiveIntroductions(): List<Introduction> {
        return introductionRepository.findAllByIsActive(true)
    }
    fun getActiveLinks(): List<Link> {
        return linkRepository.findAllByIsActive(true)
    }
    fun getActiveProjects(): List<Project> {
        return projectRepository.findAllByIsActive(true)
    }
    fun getActiveSkills(): List<Skill> {
        return skillRepository.findAllByIsActive(true)
    }

    fun getArticles(): List<Article> {
        return articleRepository.findAll()
    }

    fun setArciels() {

    }
}

 

package com.example.portfolio.presentation.interceptor

import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.InterceptorRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer


@Configuration
class PresentationInterceptorConfiguration(
    private val presentationInterceptor: PresentationInterceptor
) :WebMvcConfigurer {

    override fun addInterceptors(registry: InterceptorRegistry) {
        registry.addInterceptor(presentationInterceptor)
            .addPathPatterns("/**")
            .excludePathPatterns("/assets/**", "/css/**", "/js/**", "/admin/**", "h2**", "/favicon.ico", "/error")
    }
}

 

 

느낀 점

프리젠테이션 부분에서 화면과 인터셉터 설계를 하면서 아직 화면 구성과 데이터 조작에 어려움을 느껴서 진도를 많이 못나갔다. 지금부터 복습 다시하면서 천천히 자기서으로 만들어야 한다는 시간을 가져야 겠다고 생각했다.

답변 0