From e36d90e35cf7ee72792c05b4e8e55a1f547fa5b3 Mon Sep 17 00:00:00 2001 From: Qing Date: Wed, 12 Jul 2023 01:37:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/hellogithub/dao/UserDao.java | 20 +++++++++++++++++++ .../hellogithub/service/projectService.java | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/com/hellogithub/dao/UserDao.java b/src/com/hellogithub/dao/UserDao.java index ea76218..26a7ad5 100644 --- a/src/com/hellogithub/dao/UserDao.java +++ b/src/com/hellogithub/dao/UserDao.java @@ -443,4 +443,24 @@ public class UserDao { } return num; } + + public int addUserProjectNum(int userId) + { + int num ; + try { + Connection conn = JdbcUtils.getConnection(); + QueryRunner runner = new QueryRunner(); + String sql="update user set projectNum = projectNum+1 where userId = ?"; + num = runner.update(conn,sql,userId); + sql="update user set contributionValue = contributionValue+10 where userId = ?"; + if( runner.update(conn,sql,userId) == 1 ) + { + num++; + } + conn.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + return num; + } } diff --git a/src/com/hellogithub/service/projectService.java b/src/com/hellogithub/service/projectService.java index baa808c..701ab56 100644 --- a/src/com/hellogithub/service/projectService.java +++ b/src/com/hellogithub/service/projectService.java @@ -268,7 +268,10 @@ public class projectService { String submitTime = format.format(time).toString(); int categoryId = categoryIdList.get(0); int userId = userDao.selectIdByName(username); - + int tem =userDao.addUserProjectNum(userId); + if( tem!=2){ + flag=0; + } pnum = projectDao.insertProject(userId,projectName,projectUrl,projectIco,projectTitle,projectDescription,submitTime,categoryId); if(pnum == 0 ) {