우리조에서 차별화 기능 아이디어로 제출한 것은 다음과 같다.
1. JPetStore가 상점이므로 리뷰 게시판을 추가하자!
2. JPetStore가 펫샵의 기능을 하고 있으므로 사용자들의 참여를 이끌어내기 위하여 양육일기를 작성할 수 있는 게시판을 구현하자.
기본적으로 다이어리와 관련한 모든 URL에 대응한다. 형식적 Validation이 진행되고 서비스를 통하여 로직을 수행하고, View 컴포넌트(JSP)에 연결된다.
기본적으로 다이어리와 관련된 모든 로직을 수행한다. DiaryActionBean에서 서비스를 호출하게 된다. 해당 서비스는 DiaryMapper, DiaryCommentsMapper, DiaryLikesMapper을 이용하여 데이터베이스와 상호작용하며 자세한 내용은 다음에서 설명한다.
기본적으로 Mybatis를 사용하기 위한 인터페이스 클래스이며 데이터베이스 테이블에 대응하는 매퍼들이 존재한다. DiaryMapper는 DIARY 테이블, DiaryCommentsMapper는 COMMENTS 테이블, DiaryLikesMapper는 LIKES 테이블과 상호작용하게 된다.
Mapper 인터페이스에서 정의한 메소드에 해당하는 쿼리를 동적으로 생성하여 실행하게 되며, 해당 쿼리가 명시되어 있는 파일이다.
Synology NAS에 MariaDB에 기존 JPetStore6 DB를 마이그레이션하고, 해당 데이터베이스만 접근할 수 있는 계정을 생성한다. 해당 계정은 같이 협업하는 팀원 역시도 데이터베이스에 대한 제어를 획득할 수 있었어야 한다.(차별화 기능을 제외하고 추가기능(어드민)을 구현하는 팀원에도 DB를 설계하는 팀원이 존재했다.) 그래서 해당 계정에 GRANT ALL = 모든 권한을 주었다.
도커에서 Apache Tomcat + JDK 11 버전을 가지고 있는 이미지를 컨테이너로 빌드하고 해당 컨테이너에 빌드된 프로젝트 .war파일을 담아서 외부에서 접근가능할 수 있도록 하였다. 해당 톰캣에는 다른 웹앱 프로젝트도 작동하고 있어서 SSL인증과 DNS 레코드 설정이 이미 되어있는 상태이다.
select no, imgurl, title, categoryid, userid, date, content,
(select count(*) from LIKES where d_no = no) as likes,
(select count(*) from COMMENTS where d_no= no) as comments
from DIARY where no = #{no};
diaryLikesMapper.insertLike(likes);
int likesCnt = diaryLikesMapper.getLikesCount(likes.getD_no());
diaryMapper.updateDiaryLikes(likes.getD_no(), likesCnt);
public void setDiaryList(int offset){
if (orderCategory == null || orderCategory.equals("ALL")) {
diaryList=diaryService.getDiaryList(orderLikesOrComments, offset);
} else {
diaryList=diaryService.getCategoriedDiaryList(offset, orderCategory, orderLikesOrComments);
}
}
public void setSearchedDiaryList(int offset){
if (orderCategory == null || orderCategory.equals("ALL")) {
diaryList=diaryService.getSearchedDiaryList(offset, orderLikesOrComments, keyword);
} else {
diaryList=diaryService.getSearchedCategoriedDiaryList(offset, orderCategory, orderLikesOrComments, keyword);
}
}
<select id="getDiaryList" resultType="Diary">
select no, imgurl, title, categoryid, userid, date, likes, comments
from DIARY
where 1 = 1
<if test='param2 != null and param2 != "ALL"'>
and categoryid = #{param2}
</if>
<if test="param4 != null">
and (userid like CONCAT('%',#{param4},'%') OR title like CONCAT('%',#{param4},'%'))
</if>
order by ${param3} desc limit #{param1}, 6;
</select>
public void fileUpload() throws IOException {
String now = new SimpleDateFormat("yyyyMMddHmsS").format(new Date()); //현재시간
String saveDir = context.getRequest().getSession().getServletContext().getRealPath("/static");
File dir = new File(saveDir);
//diary.setImgurl("default.png");
if (!dir.exists()) {
dir.mkdirs();
}
if (petImage != null && petImage.getSize() != 0) {
try {
String fileName = petImage.getFileName();
int i = -1;
i = fileName.lastIndexOf("."); // 파일 확장자 위치
String realFileName = now + fileName.substring(i, fileName.length()); //현재시간과 확장자 합치기
diary.setImgurl(realFileName);
//System.out.println(saveDir + "/" + realFileName);
petImage.save(new File(saveDir + "/" + realFileName));
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
}
}
}