修改评论
This commit is contained in:
@@ -85,4 +85,14 @@ public class commentEntity {
|
|||||||
public void setLikeNum(int likeCount) {
|
public void setLikeNum(int likeCount) {
|
||||||
this.likeNum = likeCount;
|
this.likeNum = likeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String username;
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,7 @@ import com.hellogithub.dao.UserDao;
|
|||||||
import com.hellogithub.dao.commentDao;
|
import com.hellogithub.dao.commentDao;
|
||||||
import com.hellogithub.entity.commentEntity;
|
import com.hellogithub.entity.commentEntity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -55,7 +56,7 @@ public class commentService {
|
|||||||
|
|
||||||
public String selectByTrait(String id,String trait)
|
public String selectByTrait(String id,String trait)
|
||||||
{
|
{
|
||||||
List<commentEntity> commentEntityList = commentDao.selectByTrait(id,trait);
|
List<commentEntity> commentEntityList=new ArrayList<>();
|
||||||
if(trait.equals("last"))
|
if(trait.equals("last"))
|
||||||
{
|
{
|
||||||
commentEntityList = commentDao.selectByTrait(id,"creatTime");
|
commentEntityList = commentDao.selectByTrait(id,"creatTime");
|
||||||
@@ -64,7 +65,13 @@ public class commentService {
|
|||||||
{
|
{
|
||||||
commentEntityList = commentDao.selectByTrait(id,"likeNum");
|
commentEntityList = commentDao.selectByTrait(id,"likeNum");
|
||||||
}
|
}
|
||||||
|
for(int i=0;i<commentEntityList.size();i++)
|
||||||
|
{
|
||||||
|
commentEntity commentEntity = commentEntityList.get(i);
|
||||||
|
int userid = commentEntity.getUserId();
|
||||||
|
String username = userDao.selectNameById(userid);
|
||||||
|
commentEntity.setUsername(username);
|
||||||
|
}
|
||||||
return JSONObject.toJSONString(commentEntityList);
|
return JSONObject.toJSONString(commentEntityList);
|
||||||
}
|
}
|
||||||
public String addLikeNum(int commentId){
|
public String addLikeNum(int commentId){
|
||||||
|
Reference in New Issue
Block a user