Service
더보기
ArticleService
package com.sbs.example.easytextboard.service;
import java.util.List;
import com.sbs.example.easytextboard.container.Container;
import com.sbs.example.easytextboard.dao.ArticleDao;
import com.sbs.example.easytextboard.dto.Article;
import com.sbs.example.easytextboard.dto.Board;
public class ArticleService {
private ArticleDao articleDao;
public ArticleService() {
articleDao = Container.articleDao;
}
public int add(String title, String body, int loginedMemberId, int boardId) {
return articleDao.add(title, body, loginedMemberId, boardId);
}
public List<Article> getArticles() {
return articleDao.getArticles();
}
public Article getArticleByIndex(int i) {
return articleDao.getArticleByIndex(i);
}
public Article getArticle(int inputedId) {
return articleDao.getArticle(inputedId);
}
public void remove(int inputedId) {
articleDao.remove(inputedId);
}
public Article modify(int inputedId, String title, String body) {
return articleDao.modify(inputedId, title, body);
}
public int makeBoard(String boardName) {
return articleDao.makeBoard(boardName);
}
public Board getBoardById(int inputedId) {
return articleDao.getBoardById(inputedId);
}
public int getDefultBoardId() {
List<Board> boards = articleDao.getBoards();
return boards.get(1).id;
}
public void test() {
articleDao.test();
}
}
MemberService
package com.sbs.example.easytextboard.service;
import com.sbs.example.easytextboard.container.Container;
import com.sbs.example.easytextboard.dao.MemberDao;
import com.sbs.example.easytextboard.dto.Member;
public class MemberService {
private MemberDao memberDao;
public MemberService() {
memberDao = Container.memberDao;
}
public int join(String loginId, String loginPw, String name) {
return memberDao.join(loginId, loginPw, name);
}
public Member getMemberByLoginId(String loginId) {
return memberDao.getMemberByLoginId(loginId);
}
public boolean isJoinableLoginId(String loginId) {
Member member = memberDao.getMemberByLoginId(loginId);
if (member != null) {
return false;
}
return true;
}
public Member getMemberById(int loginedMemberId) {
return memberDao.getMemberById(loginedMemberId);
}
}
Session
더보기
package com.sbs.example.easytextboard.session;
public class Session {
public int loginedMemberId;
public int selectedBoardId;
public Session() {
loginedMemberId = 0;
selectedBoardId = 0;
}
public boolean isLogined() {
return loginedMemberId != 0;
}
public boolean isLogout() {
return !isLogined();
}
public void login(int memberId) {
loginedMemberId = memberId;
}
public void logout() {
loginedMemberId = 0;
}
public void selectedBoard(int id) {
selectedBoardId = id;
}
}
*전체적인 일상은 노션을 통해 작성하고 있습니다.
'Java' 카테고리의 다른 글
#067 게시글 Listing / Select / Board 까지 전체 코드 정리 2차 (0) | 2020.12.15 |
---|---|
#066 게시글 Listing / Select / Board 까지 전체 코드 정리 1차 (0) | 2020.12.15 |
#056 [그룹활동] 재미있는 취미 (0) | 2020.12.11 |
#055 [과제] 전체 구현 조건 (0) | 2020.12.11 |
#054 데이터 수명에 대하여 (0) | 2020.12.11 |