修改评论
This commit is contained in:
@@ -211,7 +211,8 @@ public class UserDao {
|
|||||||
|
|
||||||
while(rs.next()){
|
while(rs.next()){
|
||||||
Value = rs.getInt(8);
|
Value = rs.getInt(8);
|
||||||
}return Value;
|
}
|
||||||
|
return Value;
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@@ -7,6 +7,8 @@ import org.apache.commons.dbutils.QueryRunner;
|
|||||||
import org.apache.commons.dbutils.handlers.BeanListHandler;
|
import org.apache.commons.dbutils.handlers.BeanListHandler;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -56,14 +58,29 @@ public class commentDao {
|
|||||||
return commentEntityList;
|
return commentEntityList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<commentEntity> selectByTrait(String id,String trait)
|
public List<commentEntity> selectBylikeNum(String id)
|
||||||
{
|
{
|
||||||
List<commentEntity> commentEntityList ;
|
List<commentEntity> commentEntityList ;
|
||||||
try {
|
try {
|
||||||
Connection conn = JdbcUtils.getConnection();
|
Connection conn = JdbcUtils.getConnection();
|
||||||
QueryRunner runner = new QueryRunner();
|
QueryRunner runner = new QueryRunner();
|
||||||
String sql = "select * from comment where projectId = ? and isValid = 1 Order BY ?";
|
String sql = "select * from comment where projectId = ? and isValid = 1 Order BY likeNum DESC";
|
||||||
commentEntityList = runner.query(conn, sql,new BeanListHandler<>(commentEntity.class),id,trait);
|
commentEntityList = runner.query(conn, sql,new BeanListHandler<>(commentEntity.class),id);
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return commentEntityList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<commentEntity> selectByCreatTime(String id)
|
||||||
|
{
|
||||||
|
List<commentEntity> commentEntityList ;
|
||||||
|
try {
|
||||||
|
Connection conn = JdbcUtils.getConnection();
|
||||||
|
QueryRunner runner = new QueryRunner();
|
||||||
|
String sql = "select * from comment where projectId = ? and isValid = 1 Order BY creatTime ";
|
||||||
|
commentEntityList = runner.query(conn, sql,new BeanListHandler<>(commentEntity.class),id);
|
||||||
conn.close();
|
conn.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@@ -59,11 +59,11 @@ public class commentService {
|
|||||||
List<commentEntity> commentEntityList=new ArrayList<>();
|
List<commentEntity> commentEntityList=new ArrayList<>();
|
||||||
if(trait.equals("last"))
|
if(trait.equals("last"))
|
||||||
{
|
{
|
||||||
commentEntityList = commentDao.selectByTrait(id,"creatTime");
|
commentEntityList = commentDao.selectByCreatTime(id);
|
||||||
}
|
}
|
||||||
if(trait.equals("hot"))
|
if(trait.equals("hot"))
|
||||||
{
|
{
|
||||||
commentEntityList = commentDao.selectByTrait(id,"likeNum");
|
commentEntityList = commentDao.selectBylikeNum(id);
|
||||||
}
|
}
|
||||||
for(int i=0;i<commentEntityList.size();i++)
|
for(int i=0;i<commentEntityList.size();i++)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user