增加平均星数
This commit is contained in:
@@ -12,6 +12,7 @@ import com.hellogithub.entity.commentEntity;
|
||||
import com.hellogithub.entity.projectEntity;
|
||||
import com.hellogithub.entity.supportEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -158,7 +159,9 @@ public class projectService {
|
||||
sum +=commentEntityList.get(i).getStar();
|
||||
}
|
||||
double average = sum/commentEntityList.size();
|
||||
projectEntity.setAverage(average);
|
||||
BigDecimal two = new BigDecimal(average);
|
||||
double three = two.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
projectEntity.setAverage(three);
|
||||
}
|
||||
else{
|
||||
projectEntity.setAverage(0);
|
||||
|
@@ -43,6 +43,7 @@ public class selectProByIdServlet extends HttpServlet {
|
||||
int num = projectService.addProjectLookcount(id);
|
||||
PrintWriter writer = resp.getWriter();
|
||||
String dataMap = projectService.retProjectLabel(id);
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(dataMap);
|
||||
jsonObject.put("project",projectService.selectProById(id));
|
||||
writer.println(JSONObject.toJSONString(jsonObject));
|
||||
|
Reference in New Issue
Block a user