/** * 新增專案 * * @return boolean * @throws Exception */ public boolean insertNewProjectAndAttribut(ProjectVo vo, List<Projects_attributeJsonVo> avo) throws Exception { SqlSession session = null; boolean status = false; int cnt = 0; int cntAvo = 0; String json = ""; try { logger.debug("insertNewProjectAndAttribut entry ======"); session = getSession(false); // insert a new major project cnt = session.insert("project.insertProject", vo); // setting the project id to attributes for (Projects_attributeJsonVo d : avo) { d.setPid(vo.getId()); } // transfer the attributes to its JsonVo ProjectJsonVo pvo = new ProjectJsonVo(); pvo.setMajorPrjAttributes(avo); // to Json Gson gson = new Gson(); json = gson.toJson(pvo); DB_jsonMappingVo dbMapVo = new DB_jsonMappingVo(); dbMapVo.setId(vo.getId()); dbMapVo.setJson(json); cnt = session.update("project.updateProjectAttribute", dbMapVo); if (cnt > 0) { status = true; } session.commit(); } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); session.rollback(); throw e; } finally { closeCoonnection(session); } return status; }
/** * 啟用專案 * * @return boolean 成功或失敗 */ public boolean enable(ProjectVo vo) { SqlSession session = null; boolean status = false; try { session = getSession(false); vo.setStatus(STAUS_ENABLE); int cnt = session.update("project.updateStatus", vo); // logger.debug("cnt:" + cnt); session.commit(); if (cnt > 0) { status = true; } } catch (Exception e) { e.printStackTrace(); logger.error(e.getMessage()); session.rollback(); } finally { closeCoonnection(session); } return status; }