feat: mpower 적용 - 게시판

dev
minuk926 2 years ago
parent 4cc51ca322
commit a3fdb731fe

@ -42,7 +42,7 @@ public class BoardDao extends BaseMpowerDaoSupport {
final String sql = QueryGenerator.createNamedQuery("board", "selectBoard")
.setParameter("ciCode", ciCode)
.getQueryString();
final String fieldStrs = "ci_code, ci_contentno, ci_contents, ci_email, ci_hit, ci_id, ci_ip, ci_nalja, ci_name, ci_pass, ci_pwd, ci_ref, ci_revel, ci_step, ci_time, ci_title";
final String fieldStrs = "ciCode, ciContentno, ciContents, ciEmail, ciHit, ciId, ciIp, ciNalja, ciName, ciPass, ciPwd, ciRef, ciRevel, ciStep, ciTime, ciTitle";
return Optional.ofNullable(selectOne(BoardDto.class, sql, fieldStrs));
}
@ -76,9 +76,9 @@ public class BoardDao extends BaseMpowerDaoSupport {
update(sql);
}
public int findByCiRefCnt(final Long ciCode) {
public int findByCiRefCnt(final Long ciRef) {
final String sql = QueryGenerator.createNamedQuery("board", "selectCntByCiRef")
.setParameter("ciCode", ciCode)
.setParameter("ciRef", ciRef)
.getQueryString();
return Integer.parseInt(selectOneColumn(sql));
}

@ -69,7 +69,7 @@ public class BoardService implements IBoardService {
BoardDto savedDto = boardDao.findById(ciCode).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND));
if(!Objects.equal(HeaderUtil.getUserId(), savedDto.getCiId())) throw new CustomBaseException("삭제 권한(게시글 소유자)이 없는 사용자 입니다");
// 댓글 존재 여부 조회
// 댓글 존재 여부 조회 : 댓글이 있는 경우 ciRef 에 ciCode로 존재
int cnt = boardDao.findByCiRefCnt(ciCode);
if(cnt > 1) throw new CustomBaseException("삭제 할 수 없는 게시글 입니다[댓글 존재]");
boardDao.deleteById(ciCode);

@ -261,6 +261,8 @@ public abstract class BaseMpowerDaoSupport {
break;
}
} catch (Exception e) {
log.error(e.getLocalizedMessage());
e.printStackTrace();
throw new MpowerException(String.format("%s::%s=%s", "DB Result 바인딩 오류", fields.get(j), client.getString("list1", row, j)));
}
}

@ -12,7 +12,7 @@ xit:
# api response logging 여부
api:
reponse:
logging: true
logging: false
file:
cmm:

@ -63,7 +63,7 @@
<native-query id="selectBoard">
/* board-mapper|updateCiHit|julim */
SELECT ci_code
SELECT ci_code,
ci_contentno,
ci_contents,
ci_email,

Loading…
Cancel
Save