浏览代码

小程序评论接口修改

wrh 2 年之前
父节点
当前提交
bb3b7d4798

+ 11 - 1
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/SEvaluationServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert;
 import cn.hutool.core.io.FileTypeUtil;
 import cn.hutool.core.lang.UUID;
 import com.example.nngkxxdp.dao.FileDao;
+import com.example.nngkxxdp.dao.FoodDao;
 import com.example.nngkxxdp.entity.*;
 import com.example.nngkxxdp.dao.SEvaluationDao;
 import com.example.nngkxxdp.service.SEvaluationService;
@@ -41,6 +42,9 @@ public class SEvaluationServiceImpl implements SEvaluationService {
     @Autowired
     private FileDao fileDao;
 
+    @Autowired
+    private FoodDao foodDao;
+
     @Value("${file.location}")
     private String location;
 
@@ -127,7 +131,13 @@ public class SEvaluationServiceImpl implements SEvaluationService {
     @Override
     public List<Map<String, Object>> getDetailByDishesId(String canteenId, String dishesId, Integer page, Integer limit) {
         Integer count = (page - 1) * limit;
-        return sEvaluationDao.getDetailByDishesId(canteenId, dishesId, count, limit);
+        List<Map<String, Object>> list = sEvaluationDao.getDetailByDishesId(canteenId, dishesId, count, limit);
+        for (Map<String, Object> map : list) {
+            String photoPath = map.getOrDefault("photoPath", "").toString();
+            List<Map<String, Object>> pic = foodDao.getFoodPicByPicId(photoPath.split(","));
+            map.put("photoPath", pic);
+        }
+        return list;
     }
 
     @Override

+ 3 - 3
nngkxxdp/src/main/resources/static/nnzwminiapp/pages/commentList/commentList.js

@@ -1,11 +1,11 @@
 // pages/commentList/commentList.js
 import {
-	imgUrl,
-	baseUrl
+	imgUrl
 } from "../api/request"
 
 import {
-	request
+	request,
+	baseUrl
 } from "../api/canteen-request.js"
 Page({
 

+ 1 - 2
nngkxxdp/src/main/resources/static/nnzwminiapp/pages/commentList/commentList.wxml

@@ -1,4 +1,3 @@
-<wxs module="filter" src="./util.wxs"></wxs>
 <view>
 	<view wx:if="{{compliment}}" class="top-cont">此菜品上周共获得<span>{{compliment}}</span>次点赞,获得<span>{{commentCount}}</span>次评论!</view>
 	<scroll-view class="content" scroll-y="true" style="height: {{height}};" bindscrolltolower="scrollBottom">
@@ -16,7 +15,7 @@
 				</view>
 				<view class="cont">{{item.evaluation}}</view>
 				<view class="image">
-					<image wx:for="{{filter.split(item.photoPath)}}" src="{{baseUrl}}{{item}}" wx:key="index" alt="" />
+					<image wx:for="{{item.photoPath}}" src="{{baseUrl}}{{item.path}}" wx:key="index" alt="" />
 				</view>
 			</view>
 		</view>

+ 0 - 14
nngkxxdp/src/main/resources/static/nnzwminiapp/pages/commentList/util.wxs

@@ -1,14 +0,0 @@
-// 支持es4语法
-var filter = {
-	split: function(data) {
-		if (data && data != '') {
-			return data.split(',')
-		} else {
-			return ''
-		}
-	}
-}
-// 导出对外暴露的属性
-module.exports = {
-	split: filter.split
-}