增加平均星数
This commit is contained in:
@@ -151,4 +151,14 @@ public class projectEntity {
|
||||
public void setNum(long num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
double average;
|
||||
|
||||
public double getAverage() {
|
||||
return average;
|
||||
}
|
||||
|
||||
public void setAverage(double average) {
|
||||
this.average = average;
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ import com.hellogithub.dao.commentDao;
|
||||
import com.hellogithub.dao.projectDao;
|
||||
import com.hellogithub.dao.supportDao;
|
||||
import com.hellogithub.entity.categoryEntity;
|
||||
import com.hellogithub.entity.commentEntity;
|
||||
import com.hellogithub.entity.projectEntity;
|
||||
import com.hellogithub.entity.supportEntity;
|
||||
|
||||
@@ -146,6 +147,22 @@ public class projectService {
|
||||
projectEntity projectEntity = projectDao.selectProById(id);
|
||||
categoryEntity categoryEntity = categoryDao.retNum(projectEntity.getCategoryId());
|
||||
projectEntity.setCategoryName(categoryEntity.getCategoryName());
|
||||
|
||||
List<commentEntity> commentEntityList = commentDao.selectByProjectId(id);
|
||||
|
||||
if(commentEntityList.size() != 0)
|
||||
{
|
||||
int sum = 0;
|
||||
for(int i= 0;i<commentEntityList.size();i++)
|
||||
{
|
||||
sum +=commentEntityList.get(i).getStar();
|
||||
}
|
||||
double average = sum/commentEntityList.size();
|
||||
projectEntity.setAverage(average);
|
||||
}
|
||||
else{
|
||||
projectEntity.setAverage(0);
|
||||
}
|
||||
return projectEntity;
|
||||
}
|
||||
public int addProjectLookcount(String id ){
|
||||
|
Reference in New Issue
Block a user