|
@@ -87,7 +87,11 @@ public class CommonRatingController {
|
|
|
@PostMapping("/addRating")
|
|
@PostMapping("/addRating")
|
|
|
public R<Integer> add(@RequestBody CommonRating commonRating) {
|
|
public R<Integer> add(@RequestBody CommonRating commonRating) {
|
|
|
log.info("CommonRatingController.add?commonRating={}", commonRating);
|
|
log.info("CommonRatingController.add?commonRating={}", commonRating);
|
|
|
- return R.data(commonRatingService.saveCommonRating(commonRating));
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ return R.data(commonRatingService.saveCommonRating(commonRating));
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ return R.fail(e.getMessage());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation("获取评价详情,和所有回复")
|
|
@ApiOperation("获取评价详情,和所有回复")
|
|
@@ -113,7 +117,7 @@ public class CommonRatingController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 删除评价(并重新统计店铺评分)
|
|
* 删除评价(并重新统计店铺评分)
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param ratingId 评价id
|
|
* @param ratingId 评价id
|
|
|
* @return 0:成功, 1:失败
|
|
* @return 0:成功, 1:失败
|
|
|
*/
|
|
*/
|
|
@@ -121,16 +125,16 @@ public class CommonRatingController {
|
|
|
@GetMapping("/deleteRating")
|
|
@GetMapping("/deleteRating")
|
|
|
public R deleteRating(@RequestParam Long ratingId) {
|
|
public R deleteRating(@RequestParam Long ratingId) {
|
|
|
log.info("删除评价,ratingId={}", ratingId);
|
|
log.info("删除评价,ratingId={}", ratingId);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 先获取评价信息(用于后续更新评分)
|
|
// 先获取评价信息(用于后续更新评分)
|
|
|
CommonRating rating = commonRatingService.getById(ratingId);
|
|
CommonRating rating = commonRatingService.getById(ratingId);
|
|
|
if (rating == null) {
|
|
if (rating == null) {
|
|
|
return R.fail("评价不存在");
|
|
return R.fail("评价不存在");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 删除评价
|
|
// 删除评价
|
|
|
boolean b = commonRatingService.removeById(ratingId);
|
|
boolean b = commonRatingService.removeById(ratingId);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (b) {
|
|
if (b) {
|
|
|
// 删除成功后,重新统计店铺评分(仅店铺评价类型)
|
|
// 删除成功后,重新统计店铺评分(仅店铺评价类型)
|
|
|
if (rating.getBusinessType() != null && rating.getBusinessType() == 1) {
|
|
if (rating.getBusinessType() != null && rating.getBusinessType() == 1) {
|