|
|
@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -55,11 +56,22 @@ public class CommonCountController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value ="/{id}/count", method = RequestMethod.GET)
|
|
|
- public Long findCountById(@PathVariable("id") Long id) {
|
|
|
+ public String findCountById(@PathVariable("id") Long id) {
|
|
|
CommonCount commonCount = commonCountService.findById(id);
|
|
|
- if(commonCount == null)
|
|
|
+ if(commonCount == null && commonCount.getCount() != null)
|
|
|
throw new IllegalArgumentException("参数ID错误,数据不存在");
|
|
|
- return commonCount.getCount();
|
|
|
+
|
|
|
+ String result = "";
|
|
|
+ Double countdb = commonCount.getCount();
|
|
|
+ if (countdb % 1.0 == 0) {
|
|
|
+ result = String.valueOf(countdb.longValue());
|
|
|
+ } else {
|
|
|
+ BigDecimal count = new BigDecimal(countdb);
|
|
|
+ BigDecimal dividenum = new BigDecimal(1);
|
|
|
+ result = count.divide(dividenum, 3, BigDecimal.ROUND_HALF_UP).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
}
|