|
|
@@ -40,15 +40,15 @@ public class StoreCommentController {
|
|
|
@ApiImplicitParam(name = "replyStatus", value = "回复状态(0:全部, 1:已回复, 2:未回复)", dataType = "Integer", paramType = "query"),
|
|
|
@ApiImplicitParam(name = "commentLevel", value = "评论等级(0:全部, 1:好评, 2:中评, 3:差评)", dataType = "Integer", paramType = "query"),
|
|
|
@ApiImplicitParam(name = "days", value = "查询时间, 多少天前", dataType = "Integer", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "phoneId", value = "消息标识", dataType = "String", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String", paramType = "query"),
|
|
|
@ApiImplicitParam(name = "userType", value = "评论的用户类型(0:商家, 其他:用户)", dataType = "String", paramType = "query"),
|
|
|
@ApiImplicitParam(name = "tagId", value = "标签id)", dataType = "Integer", paramType = "query"),
|
|
|
@ApiImplicitParam(name = "hasImage", value = "是否有图片(0否/1是)", dataType = "Boolean", paramType = "query")
|
|
|
})
|
|
|
@GetMapping("/getList")
|
|
|
- public R<IPage<StoreCommentVo>> getList(Integer pageNum, Integer pageSize, Integer businessId, Integer businessType, Integer storeId, Integer replyStatus, Integer commentLevel, Integer days, String phoneId, Integer userType, Integer tagId,@RequestParam(required = false, defaultValue = "false") Boolean hasImage) {
|
|
|
- log.info("StoreCommentController.getList?pageNum={}&pageSize={}&businessId={}&businessType={}&storeId={}&replyStatus={}&commentLevel={}&days={}&phoneId={}&userType={}&tagId={}&hasImage={}", pageNum, pageSize, businessId, businessType, storeId, replyStatus, commentLevel, days, phoneId, userType, tagId, hasImage);
|
|
|
- return R.data(storeCommentService.getList(pageNum, pageSize, businessId, businessType, storeId, replyStatus, commentLevel, days, phoneId, userType, tagId, hasImage));
|
|
|
+ public R<IPage<StoreCommentVo>> getList(Integer pageNum, Integer pageSize, Integer businessId, Integer businessType, Integer storeId, Integer replyStatus, Integer commentLevel, Integer days, String userId, Integer userType, Integer tagId,@RequestParam(required = false, defaultValue = "false") Boolean hasImage) {
|
|
|
+ log.info("StoreCommentController.getList?pageNum={}&pageSize={}&businessId={}&businessType={}&storeId={}&replyStatus={}&commentLevel={}&days={}&userId={}&userType={}&tagId={}&hasImage={}", pageNum, pageSize, businessId, businessType, storeId, replyStatus, commentLevel, days, userId, userType, tagId, hasImage);
|
|
|
+ return R.data(storeCommentService.getList(pageNum, pageSize, businessId, businessType, storeId, replyStatus, commentLevel, days, userId, userType, tagId, hasImage));
|
|
|
}
|
|
|
|
|
|
@ApiOperation("获取最新一条评论/评价")
|
|
|
@@ -143,27 +143,56 @@ public class StoreCommentController {
|
|
|
// log.info("StoreCommentController.saveComment?id={}&businessType={}&storeId={}&userId={}&replyId={}&commentContent={}&score={}&otherScore={}&isAnonymous={}", id, businessType, storeId, userId, replyId, commentContent, score, otherScore, isAnonymous);
|
|
|
// log.info(String.valueOf(imageUrls));
|
|
|
String imageUrls = map.get("imageUrls");
|
|
|
- String s = map.get("id");
|
|
|
- Integer id = null;
|
|
|
- if(null != s) {
|
|
|
- id = Integer.parseInt(s);
|
|
|
- }
|
|
|
- Integer businessType = Integer.parseInt(map.get("businessType"));
|
|
|
- Integer storeId = Integer.parseInt(map.get("storeId"));
|
|
|
- Integer userId = Integer.parseInt(map.get("userId"));
|
|
|
- String b = map.get("replyId");
|
|
|
- Integer replyId = null;
|
|
|
- if(null != b) {
|
|
|
- replyId = Integer.parseInt(b);
|
|
|
- }
|
|
|
+
|
|
|
+ Integer id = parseInteger(map, "id", false);
|
|
|
+ Integer businessType = parseInteger(map, "businessType", true);
|
|
|
+ Integer storeId = parseInteger(map, "storeId", true);
|
|
|
+ Integer userId = parseInteger(map, "userId", true);
|
|
|
+ Integer replyId = parseInteger(map, "replyId", false);
|
|
|
|
|
|
String commentContent = map.get("commentContent");
|
|
|
- Double score = Double.parseDouble(map.get("score"));
|
|
|
+ Double score = parseDouble(map, "score", true);
|
|
|
String otherScore = map.get("otherScore");
|
|
|
- Integer isAnonymous = Integer.parseInt(map.get("isAnonymous"));
|
|
|
+ Integer isAnonymous = parseInteger(map, "isAnonymous", true);
|
|
|
return R.data(storeCommentService.saveCommentOnlyStore(imageUrls, id, businessType, storeId, userId, replyId, commentContent, score, otherScore, isAnonymous));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 解析 Integer 类型参数,支持必填/选填,并在缺失或格式错误时抛出清晰异常。
|
|
|
+ */
|
|
|
+ private Integer parseInteger(Map<String, String> map, String key, boolean required) {
|
|
|
+ String value = map.get(key);
|
|
|
+ if (value == null || value.trim().isEmpty()) {
|
|
|
+ if (required) {
|
|
|
+ throw new IllegalArgumentException("参数[" + key + "]不能为空");
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return Integer.parseInt(value.trim());
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ throw new IllegalArgumentException("参数[" + key + "]格式不正确,应为整数", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解析 Double 类型参数,支持必填/选填,并在缺失或格式错误时抛出清晰异常。
|
|
|
+ */
|
|
|
+ private Double parseDouble(Map<String, String> map, String key, boolean required) {
|
|
|
+ String value = map.get(key);
|
|
|
+ if (value == null || value.trim().isEmpty()) {
|
|
|
+ if (required) {
|
|
|
+ throw new IllegalArgumentException("参数[" + key + "]不能为空");
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return Double.parseDouble(value.trim());
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ throw new IllegalArgumentException("参数[" + key + "]格式不正确,应为数字", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "回复率, 评价比例")
|
|
|
@ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true)})
|
|
|
@GetMapping("/getCommitPercent")
|