diff --git a/src/com/hellogithub/dao/UserDao.java b/src/com/hellogithub/dao/UserDao.java index 2987b45..930e68f 100644 --- a/src/com/hellogithub/dao/UserDao.java +++ b/src/com/hellogithub/dao/UserDao.java @@ -418,6 +418,14 @@ public class UserDao { QueryRunner runner = new QueryRunner(); String sql="delete from user where userId = ?"; num = runner.update(conn,sql,id); + sql="update project set isValid = 0 where userId = ?"; + runner.update(conn,sql,id); + sql="delete from support where userId = ?"; + runner.update(conn,sql,id); + sql="delete from comment where userId = ?"; + runner.update(conn,sql,id); + sql="update article set isValid = 0 where userId = ?"; + runner.update(conn,sql,id); } catch (SQLException e) { throw new RuntimeException(e); } diff --git a/src/com/hellogithub/dao/commentDao.java b/src/com/hellogithub/dao/commentDao.java index bcfa25b..c287bb9 100644 --- a/src/com/hellogithub/dao/commentDao.java +++ b/src/com/hellogithub/dao/commentDao.java @@ -128,7 +128,7 @@ public class commentDao { try { Connection conn = JdbcUtils.getConnection(); QueryRunner runner = new QueryRunner(); - String sql="update project set userId = ? , projectId = ? , content = ? ,isUsed =?, commentTime=?, isValid=?,star=?,likeNum=?where commentId =? "; + String sql="update comment set userId = ? , projectId = ? , content = ? ,isUsed =?, commentTime=?, isValid=?,star=?,likeNum=?where commentId =? "; num = runner.update(conn,sql,userId, projectId , content , isUsed, commentTime, isValid, star, likeNum ,commentId); } catch (SQLException e) { throw new RuntimeException(e); @@ -142,7 +142,7 @@ public class commentDao { try { Connection conn = JdbcUtils.getConnection(); QueryRunner runner = new QueryRunner(); - String sql="delete from project where commentId = ?"; + String sql="delete from comment where commentId = ?"; num = runner.update(conn,sql,id); } catch (SQLException e) { throw new RuntimeException(e); diff --git a/src/com/hellogithub/dao/projectDao.java b/src/com/hellogithub/dao/projectDao.java index d8d9e5e..1113451 100644 --- a/src/com/hellogithub/dao/projectDao.java +++ b/src/com/hellogithub/dao/projectDao.java @@ -369,10 +369,12 @@ public class projectDao { try { Connection conn = JdbcUtils.getConnection(); QueryRunner runner = new QueryRunner(); - runner.update(conn,"set foreign_key_checks = 0"); String sql="delete from project where projectId = ?"; num = runner.update(conn,sql,id); - runner.update(conn,"set foreign_key_checks = 1"); + sql="delete from support where projectId = ?"; + runner.update(conn,sql,id); + sql="delete from project_category where projectId = ?"; + runner.update(conn,sql,id); } catch (SQLException e) { throw new RuntimeException(e); } diff --git a/src/com/hellogithub/service/projectService.java b/src/com/hellogithub/service/projectService.java index 5d4df04..4d54c6b 100644 --- a/src/com/hellogithub/service/projectService.java +++ b/src/com/hellogithub/service/projectService.java @@ -289,5 +289,12 @@ public class projectService { { return projectDao.updateProjectDetail( projectId , userId , projectName, projectUrl , projectIco , projectTitle , projectDescription , startNum, submitTime ,categoryId,isValid,fileAddress, periodicals, lookCount); } - public int deleteProject(int id ){return projectDao.deleteProject(id);} + public int deleteProject(int id ) + { + int userId = projectDao.selectProById(String.valueOf(id)).getUserId(); + String userName= userDao.selectNameById(userId); + userEntity userEntity = userDao.selectUserByName(userName); + userDao.updateUserDetail(userEntity.getUserId(),userName,userEntity.getUserPassword(),userEntity.getCreatTime(),userEntity.getIsValid(),userEntity.getProjectNum()-1,userEntity.getSearchHistory(),userEntity.getContributionValue(),userEntity.getUserAvatar(),userEntity.getUserLevel()); + return projectDao.deleteProject(id); + } } \ No newline at end of file diff --git a/src/com/hellogithub/servlet/systemAdmin/deleteProjectServlet.java b/src/com/hellogithub/servlet/systemAdmin/deleteProjectServlet.java index 8161ac2..b9637d3 100644 --- a/src/com/hellogithub/servlet/systemAdmin/deleteProjectServlet.java +++ b/src/com/hellogithub/servlet/systemAdmin/deleteProjectServlet.java @@ -35,7 +35,6 @@ public class deleteProjectServlet extends HttpServlet { String proId = req.getParameter("id"); PrintWriter writer = resp.getWriter(); - int num = projectService.deleteProject(Integer.parseInt(proId)); if(num == 0) {