본문 바로가기
개발/Spring

[SpringBoot+IntelliJ+Oracle+Thymeleaf+Paging] 웹 게시판 만들기(3) - Service

by 코딩하는 흰둥이 2023. 4. 20.

이전글

https://greed-yb.tistory.com/210

 

[SpringBoot+IntelliJ+Oracle+Thymeleaf+Paging] 웹 게시판 만들기(1) - Controller

https://greed-yb.tistory.com/209 [SpringBoot+IntelliJ+Oracle+Thymeleaf+Paging] 웹 게시판 만들기(1) - 구성 Java 17 Maven Spring Boot 3.0.3 Oracle 11g IntelliJ Ultimate DBeaver 간단한 CRUD 만 구현해 놓았으며 순서대로 만들면서 올

greed-yb.tistory.com

 

 

Service
  • service -> board -> impl -> BoardService(interface 로 생성)
package com.example.practice.service.board;

import com.example.practice.util.SearchCriteria;
import com.example.practice.vo.BoardVo;

import java.util.List;

public interface BoardService {

    /**
     * 글 목록
     */
    List<BoardVo> boardSelect(SearchCriteria cri) throws Exception;

    /**
     * 게시글 수
     */
    int totalCount(SearchCriteria cri);

    /**
     * 글 저장
     */
    void boardCreate(BoardVo vo) throws Exception;

    /**
     * 게시글 상세 페이지
     */
    BoardVo boardRead(Integer num) throws Exception;

    /**
     * 게시글 삭제
     */
    void boardDelete(Integer num) throws Exception;

    /**
     * 게시글 수정 하기
     */
    void boardUpdate(BoardVo vo) throws Exception;
}

 

ServiceImpl
  • service -> board ->BoardServiceImple(BoardService 를 implements 받는다)
package com.example.practice.service.board.impl;

import com.example.practice.mapper.board.BoardMapper;
import com.example.practice.service.board.BoardService;
import com.example.practice.util.SearchCriteria;
import com.example.practice.vo.BoardVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BoardServiceImpl implements BoardService{

    @Autowired
    private BoardMapper boardMapper;

    @Override
    public List<BoardVo> boardSelect(SearchCriteria cri) throws Exception {
        return boardMapper.boardSelect(cri);
    }

    @Override
    public int totalCount(SearchCriteria cri) {
        return boardMapper.totalCount(cri);
    }


    @Override
    public void boardCreate(BoardVo vo) throws Exception {
        boardMapper.boardCreate(vo);
    }

    @Override
    public BoardVo boardRead(Integer num) throws Exception {
        return boardMapper.boardRead(num);
    }

    @Override
    public void boardDelete(Integer num) throws Exception {
        boardMapper.boardDelete(num);
    }

    @Override
    public void boardUpdate(BoardVo vo) throws Exception {
        boardMapper.boardUpdate(vo);
    }
}

댓글