스프링부트 - 복습

Wald Eisen·2023년 7월 26일

study

목록 보기
25/26
package s8;

class 우유{

}

class 물{

}

class 얼음{

}

class 커피콩{
    
}

// 콘트롤러: 서비스님 dto 좀 주세요 -service.getData();
// 서비스: dto를 만들려면 필요한 데이터가 있다. String name을 줘. 리파지토리님 데이터 좀 주시죠.
// 리포지토리: (서비스) : select * from todo where user_idx = ?
//                       findByUserEntity

class 커피{ // DTO 
    String name;
    커피콩 bean;
    물 water;
    얼음 ice;
    우유 milk;

    //생성자
    public 커피(String name, 커피콩 bean, 물 water, 얼음 ice, 우유 milk){
        this.name = name;
        this.bean = bean;
        this.water = water;
        this.ice = ice;
        this.milk = milk;
    }

    // 스태틱은 커피를 관장하는 신.
    public static 커피 of(String name){
        if(name.equals("아메리카노")){
            커피 coffee = new 커피(name, new 커피콩(), new 물(), new 얼음(), null);
        }
        return null;
    }
}


class 커피타는직원{ //Service
    public 커피 getCoffee(String coffeeName){
        return 커피.of(coffeeName);
    }
}

class 주문받는직원{ //컨트롤러
    public 커피 getCoffee(커피타는직원 emp, String coffeeName){
        
        
        커피 coffee = emp.getCoffee(coffeeName);
        return coffee;
    }
}

public class Study03 {
    public static void main(String[] args) {
        주문받는직원 server = new 주문받는직원();

        커피타는직원 emp = new 커피타는직원();

        //고객
        커피 coffee = server.getCoffee(emp, "아메리카노");        
    }

}

서비스

  • 해당 유저가 작성한 삭제되지 않은 Todo 데이터 리스트 가져오기
  • dto로 바꾸기
  • 컨트롤러에 dto 리턴해주기

컨트롤러

  • 서비스에서 만든 dto 모델에 담기

  • 화면
    출력


// 로그인userDTO를 담은걸 알고 있으니 세션에서 유저정보가 NULL이면 로그인페이지로 강제이동

// null이 아니면 todo정보 담아서 메인 페이지 이동

// 세션이 loginUserDTO 좀 줘
// 서비스야 투두DTO좀 줘
// ModelAndView야 DTO좀 담아줘


(requset)
유저 > 컨트롤러 > 서비스 > 리파지토리 > 서비스 > 컨트롤러 > 유저 (response)

0개의 댓글