TIL 11/4

startas·2021년 11월 4일
0

TIL

목록 보기
14/21

오늘한일

  1. 게시물 작성 api
  2. 게시물 수정 api
  3. 강의 3강 듣기

내일할일

  1. 게시물 수정 api 수정
  2. 팀원 api 수정 및 수정한것 토대로 api수정

게시물 작성

요구사항
title,address,img,content,위도,경도,지역의 데이터가 다들어가야된다.
BoardDto에는 title,address,img,content 만들어가기 때문에 나머지는 작성자가 입력하지 않고 검색하는 위치에 따라서 자동으로 기입이 되어야되기 때문에 가지고 있는 api에서 가져와야 한다.
게시물 작성은 로그인되어있는 회원만 작성할수 있어야되기 때문에 user정보도 같이 들어가야한다.

@Transactional
public Board createBoard(BoardDto boardDto, User user) throws Exception {
	List<String> strings = api.processAddress(boardDto.getAddress());
    Location findLocation = locationRepository.findByCityName(strings.get(0));
    GeographicDto address = addressToGps.getAddress(boardDto.getAddress());
    
    Board saveBoard = new UserMake(
    	boardDto.getLocationName(),
        boardDto.getAddress(),
        boardDto.getImg(),
        boardDto.getContent(),
        Double.valueOf(address.getLongitude()),
        Double.valueOf(address.getLatitude()),
        user,
        findLocation,
        "유저가 만듬"
    );
    Board createBoard = boardRepository.save(saveBoard);
    return createBoard;
}
profile
일기장으로 시작해서 정보공유가 될 때까지!

0개의 댓글

관련 채용 정보