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