修改评论

This commit is contained in:
cyk
2023-07-05 14:44:59 +08:00
parent 223f979a0f
commit c955633d88
3 changed files with 24 additions and 6 deletions

View File

@@ -211,7 +211,8 @@ public class UserDao {
while(rs.next()){
Value = rs.getInt(8);
}return Value;
}
return Value;
}catch(Exception e){
e.printStackTrace();

View File

@@ -7,6 +7,8 @@ import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
@@ -56,14 +58,29 @@ public class commentDao {
return commentEntityList;
}
public List<commentEntity> selectByTrait(String id,String trait)
public List<commentEntity> selectBylikeNum(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 ?";
commentEntityList = runner.query(conn, sql,new BeanListHandler<>(commentEntity.class),id,trait);
String sql = "select * from comment where projectId = ? and isValid = 1 Order BY likeNum DESC";
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();
} catch (SQLException e) {
throw new RuntimeException(e);

View File

@@ -59,11 +59,11 @@ public class commentService {
List<commentEntity> commentEntityList=new ArrayList<>();
if(trait.equals("last"))
{
commentEntityList = commentDao.selectByTrait(id,"creatTime");
commentEntityList = commentDao.selectByCreatTime(id);
}
if(trait.equals("hot"))
{
commentEntityList = commentDao.selectByTrait(id,"likeNum");
commentEntityList = commentDao.selectBylikeNum(id);
}
for(int i=0;i<commentEntityList.size();i++)
{