贡献值(修正sql)
This commit is contained in:
@@ -201,26 +201,22 @@ public class UserDao {
|
||||
Connection conn = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet rs = null;
|
||||
String sql = "SELECT * FROM `user` t1,article t2 WHERE t1.userId = t2.userId AND t1.userId = ?";
|
||||
String sql = "SELECT * FROM `user` ,`article` WHERE `user`.userId = `article`.userId AND `user`.userName = ?";
|
||||
int Value = 0;
|
||||
int projectNum = 0;
|
||||
try{
|
||||
conn = JdbcUtils.getConnection();
|
||||
preparedStatement = conn.prepareStatement(sql);
|
||||
preparedStatement.setString(1, name);
|
||||
rs = preparedStatement.executeQuery();
|
||||
if(rs.next()){
|
||||
while(rs.next()){
|
||||
int projectNum = rs.getInt(6);
|
||||
Value = Value+projectNum;
|
||||
Value++;
|
||||
}
|
||||
return Value;
|
||||
}else{
|
||||
return 0;
|
||||
while(rs.next()){
|
||||
Value++;
|
||||
}
|
||||
projectNum = rs.getInt(6);
|
||||
Value = Value + projectNum;
|
||||
return Value;
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}finally {
|
||||
try{
|
||||
conn.close();
|
||||
@@ -229,6 +225,6 @@ public class UserDao {
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}return Value;
|
||||
}
|
||||
}
|
||||
|
@@ -56,5 +56,10 @@ public class UserService {
|
||||
public int dedleteAllLabel(String name){return userDao.dedleteAllLabel(name);}
|
||||
public long queryUserCount(){return userDao.queryUserCount();}
|
||||
|
||||
/**
|
||||
* 根据用户名返回贡献值
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public int contributionValueReturn(String name){return userDao.contributionValueReturn(name);}
|
||||
}
|
||||
|
Reference in New Issue
Block a user