This commit is contained in:
2023-07-12 01:37:09 +08:00
parent 5a78a5f7ea
commit e36d90e35c
2 changed files with 24 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -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 )
{