Browse Source

Merge branch 'master' of http://116.63.33.55/git/nazw

sunjuan 2 years ago
parent
commit
798d26c880

+ 30 - 20
nngkxxdp/src/main/java/com/example/nngkxxdp/controller/CanteenController.java

@@ -31,15 +31,16 @@ public class CanteenController {
 
     /**
      * description: 分页
+     *
+     * @param page        分页参数
+     * @param limit       分页参数
+     * @param canteenName 食堂名称
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author zwq
      * @date 2022/9/2 15:50
-     * @param page 分页参数
-     * @param limit 分页参数
-     * @param canteenName 食堂名称
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     @GetMapping("/page")
-    public Map<String,Object> page(Integer page, Integer limit, String canteenName) {
+    public Map<String, Object> page(Integer page, Integer limit, String canteenName) {
         if (Blank.isEmpty(page, limit)) {
             return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
         }
@@ -48,13 +49,14 @@ public class CanteenController {
 
     /**
      * description: 查询对应Id的食堂
+     *
+     * @param canteenId 食堂id
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author wrh
      * @date 2022/9/6 11:58
-     * @param canteenId 食堂id
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     @GetMapping("/detail")
-    public Map<String,Object> detail(String canteenId) {
+    public Map<String, Object> detail(String canteenId) {
         if (Blank.isEmpty(canteenId)) {
             return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
         }
@@ -63,14 +65,15 @@ public class CanteenController {
 
     /**
      * description: 新增
+     *
+     * @param canteen 食堂
+     * @param files   文件
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author zwq
      * @date 2022/9/2 15:51
-     * @param canteen 食堂
-     * @param files 文件
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     @PostMapping("/add")
-    public Map<String,Object> add(CanteenDO canteen, MultipartFile[] files) throws IOException {
+    public Map<String, Object> add(CanteenDO canteen, MultipartFile[] files) throws IOException {
         if (Blank.isEmpty(canteen.getCanteenName(), canteen.getFounder(), canteen.getComplaintPhone(),
                 canteen.getPrincipal())) {
             return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
@@ -94,14 +97,15 @@ public class CanteenController {
 
     /**
      * description: 修改
+     *
+     * @param canteen 食堂
+     * @param files   文件
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author zwq
      * @date 2022/9/2 15:51
-     * @param canteen 食堂
-     * @param files 文件
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     @PostMapping("/update")
-    public Map<String,Object> update(CanteenDO canteen, MultipartFile[] files) throws IOException {
+    public Map<String, Object> update(CanteenDO canteen, MultipartFile[] files) throws IOException {
         System.out.println(canteen);
         if (Blank.isEmpty(canteen.getId(), canteen.getCanteenName(), canteen.getComplaintPhone(),
                 canteen.getPrincipal())) {
@@ -126,20 +130,26 @@ public class CanteenController {
 
     /**
      * description: 删除
+     *
+     * @param id 主键
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author zwq
      * @date 2022/9/2 15:52
-     * @param id 主键
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     @PostMapping("/delete")
-    public Map<String,Object> delete(String id) {
+    public Map<String, Object> delete(String id) {
         return canteenService.deleteById(id);
     }
 
     @GetMapping("/allCanteen")
-    public Map<String,Object> allCanteen(){
+    public Map<String, Object> allCanteen() {
         List<CanteenNeDO> all = canteenService.all();
         return SendUtil.send(true, ConstStr.RESULT_SUCCESS, all);
     }
 
+    @GetMapping("/getDeliciousList")
+    public Map<String, Object> getDeliciousList() {
+        return SendUtil.send(true, ConstStr.RESULT_SUCCESS, canteenService.getAllDelicious());
+    }
+
 }

+ 27 - 16
nngkxxdp/src/main/java/com/example/nngkxxdp/dao/CanteenDao.java

@@ -19,70 +19,81 @@ public interface CanteenDao {
 
     /**
      * description: 查询单个
-     * @author zwq
-     * @date 2022/8/31 16:03
+     *
      * @param id ID
      * @return com.example.nngkxxdp.entity.SCanteenDO
+     * @author zwq
+     * @date 2022/8/31 16:03
      */
     CanteenDO queryById(@Param("id") String id);
 
     /**
      * description: 分页计数
-     * @author zwq
-     * @date 2022/8/31 16:03
+     *
      * @param canteenName 食堂名称
      * @return long 计数
+     * @author zwq
+     * @date 2022/8/31 16:03
      */
     long pageCount(@Param("canteenName") String canteenName);
 
     /**
      * description: 分页列表
-     * @author zwq
-     * @date 2022/8/31 16:04
-     * @param startRows 分页参数
-     * @param limit 分页参数
+     *
+     * @param startRows   分页参数
+     * @param limit       分页参数
      * @param canteenName 食堂名称
      * @return java.util.Map 数据
+     * @author zwq
+     * @date 2022/8/31 16:04
      */
     List<Map<String, Object>> pageList(Integer startRows, Integer limit, @Param("canteenName") String canteenName);
 
     /**
      * description: 新增
-     * @author zwq
-     * @date 2022/8/31 16:04
+     *
      * @param canteenDO 数据
      * @return java.lang.Integer
+     * @author zwq
+     * @date 2022/8/31 16:04
      */
     Integer addSCanteen(CanteenDO canteenDO);
 
     /**
      * description: 修改
-     * @author zwq
-     * @date 2022/8/31 16:04
+     *
      * @param canteenDO 数据
      * @return java.lang.Integer
+     * @author zwq
+     * @date 2022/8/31 16:04
      */
     Integer updateSCanteen(CanteenDO canteenDO);
 
     /**
      * description: 删除
-     * @author zwq
-     * @date 2022/8/31 16:05
+     *
      * @param id ID
      * @return java.lang.Integer
+     * @author zwq
+     * @date 2022/8/31 16:05
      */
     Integer deleteSCanteenById(@Param("id") String id);
 
     /**
      * description: 判断食堂是否存在菜单,菜品关联
-     * @author zwq
-     * @date 2022/9/8 9:58
+     *
      * @param id 主键
      * @return long 计数
+     * @author zwq
+     * @date 2022/9/8 9:58
      */
     long deleteCount(@Param("id") String id);
 
     Map<String, Object> detail(String canteenId);
 
     List<CanteenNeDO> getAllCanteen();
+
+    List<Map<String, Object>> getAllDeliciousByDishesId(String id);
+
+    Map<String, Object> getLatestComment(@Param("dishesId") String dishesId, @Param("canteenId") String canteenId);
 }

+ 37 - 7
nngkxxdp/src/main/java/com/example/nngkxxdp/elk/ElkController.java

@@ -14,6 +14,7 @@ import org.elasticsearch.action.get.GetResponse;
 import org.elasticsearch.action.search.SearchRequest;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.elasticsearch.client.RestClient;
+import org.elasticsearch.index.query.RangeQueryBuilder;
 import org.elasticsearch.search.aggregations.bucket.terms.Terms;
 import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
 import org.elasticsearch.action.search.SearchResponse;
@@ -79,6 +80,14 @@ public class ElkController {
      * 部门字段
      */
     private String deptName = "departmentname.keyword";
+    /**
+     * 发布时间
+     */
+    private String yearName = "publishtime";
+    /**
+     * 政策主题
+     */
+    private String subjectName = "e_type";
     private String pubOrg = "puborg.keyword";
     /**
      * 文件类型
@@ -111,7 +120,7 @@ public class ElkController {
      * @throws IOException
      */
     @GetMapping("search")
-    public Map<String, Object> search(Integer page, Integer limit, String content, String dept) throws IOException {
+    public Map<String, Object> search(Integer page, Integer limit, String content, String dept, Integer year, String subject) throws IOException {
         if (!Blank.notBlank(page) || !Blank.notBlank(limit)) {
             return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
         }
@@ -148,7 +157,26 @@ public class ElkController {
             should.add(QueryBuilders.matchQuery(deptName, dept));
             list.add(boolQueryBuilder2);
         }
-        if (Blank.notBlank(content) || Blank.notBlank(dept)) {
+        if (Blank.notBlank(year)) {
+            Calendar calendar = Calendar.getInstance();
+            int currentYear = calendar.get(Calendar.YEAR);
+            if (year == 0) {
+                RangeQueryBuilder boolQueryBuilder2 = QueryBuilders.rangeQuery(yearName);
+                boolQueryBuilder2.lte((currentYear - 2) + "-01-01");
+                list.add(boolQueryBuilder2);
+            } else {
+                RangeQueryBuilder boolQueryBuilder2 = QueryBuilders.rangeQuery(yearName);
+                boolQueryBuilder2.from(year + "-01-01").to((year + 1) + "-01-01");
+                list.add(boolQueryBuilder2);
+            }
+        }
+        if (Blank.notBlank(subject)) {
+            BoolQueryBuilder boolQueryBuilder2 = new BoolQueryBuilder();
+            List<QueryBuilder> should = boolQueryBuilder2.should();
+            should.add(QueryBuilders.matchQuery(subjectName, subject));
+            list.add(boolQueryBuilder2);
+        }
+        if (Blank.notBlank(content) || Blank.notBlank(dept) || Blank.notBlank(year) || Blank.notBlank(subject)) {
             searchSourceBuilder.query(boolQueryBuilder);
         }
         if (Blank.notBlank(content)) {
@@ -620,11 +648,12 @@ public class ElkController {
 
     /**
      * 分页查询问题反馈
-     * @param page 页码
-     * @param limit 每页条数
-     * @param phone 电话
+     *
+     * @param page     页码
+     * @param limit    每页条数
+     * @param phone    电话
      * @param deptName 部门
-     * @param remark 问题
+     * @param remark   问题
      * @return
      */
     @GetMapping("/getQuestionRemarkPage")
@@ -642,7 +671,8 @@ public class ElkController {
 
     /**
      * 更新问题反馈
-     * @param id 主键id
+     *
+     * @param id      主键id
      * @param isReply 回复状态值
      * @return
      */

+ 5 - 14
nngkxxdp/src/main/java/com/example/nngkxxdp/program/controller/CanteenMiniController.java

@@ -1,18 +1,12 @@
 package com.example.nngkxxdp.program.controller;
 
-import com.example.nngkxxdp.entity.CanteenNeDO;
 import com.example.nngkxxdp.program.service.CanteenMiniService;
-import com.example.nngkxxdp.service.CanteenService;
-import com.example.nngkxxdp.service.SupplyTimeService;
-import com.example.nngkxxdp.util.ConstMiNiStr;
-import com.example.nngkxxdp.util.SendUtil;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.List;
 import java.util.Map;
 
 @RestController
@@ -23,17 +17,14 @@ public class CanteenMiniController {
     private final CanteenMiniService canteenMiniService;
 
     @GetMapping("/getCanteenList")
-    public Map<String,Object> getCanteenList(){
-
+    public Map<String, Object> getCanteenList() {
         return canteenMiniService.getCanteenAll();
     }
 
-
-
-
-
-
-
+    @GetMapping("/getDeliciousList")
+    public Map<String, Object> getDeliciousList() {
+        return canteenMiniService.getAllDelicious();
+    }
 
 
 }

+ 8 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/program/service/CanteenMiniService.java

@@ -5,8 +5,16 @@ import java.util.Map;
 public interface CanteenMiniService {
     /**
      * 查询食堂详情列表
+     *
      * @return
      */
     Map<String, Object> getCanteenAll();
 
+    /**
+     * 查询食堂上周美味榜
+     *
+     * @author wrh
+     * @date 2022/10/26 11:35
+     */
+    Map<String, Object> getAllDelicious();
 }

+ 8 - 3
nngkxxdp/src/main/java/com/example/nngkxxdp/program/service/Impl/CanteenMiniServiceImpl.java

@@ -29,20 +29,20 @@ public class CanteenMiniServiceImpl implements CanteenMiniService {
     @Override
     public Map<String, Object> getCanteenAll() {
         List<CanteenNeDO> all = canteenService.all();
-        if (ObjectUtil.isEmpty(all)){
+        if (ObjectUtil.isEmpty(all)) {
             return SendUtil.send(true, ConstMiNiStr.RESULT_SUCCESS, "");
         }
 
         List<CanteenMiniDO> canteenMiniDos = new ArrayList<>();
         for (CanteenNeDO canteenNeDO : all) {
-            if (StrUtil.isEmpty(canteenNeDO.getSupplyTimeId())){
+            if (StrUtil.isEmpty(canteenNeDO.getSupplyTimeId())) {
                 continue;
             }
             String[] split = canteenNeDO.getSupplyTimeId().split(",");
             List<SupplyTimeDO> supplyTimeDos = supplyTimeService.queryByIdToArr(split);
             List<Map<String, Object>> supplyTimeMaps = new ArrayList<>();
             for (SupplyTimeDO supplyTimeDO : supplyTimeDos) {
-                Map<String,Object> supplyTime =  new HashMap<>(5);
+                Map<String, Object> supplyTime = new HashMap<>(5);
                 supplyTime.put("timeNode", supplyTimeDO.getTimeNode());
                 supplyTime.put("supplyStartTime", supplyTimeDO.getSupplyStartTime());
                 supplyTime.put("supplyEndTime", supplyTimeDO.getSupplyEndTime());
@@ -54,4 +54,9 @@ public class CanteenMiniServiceImpl implements CanteenMiniService {
         }
         return SendUtil.send(true, ConstMiNiStr.RESULT_SUCCESS, canteenMiniDos);
     }
+
+    @Override
+    public Map<String, Object> getAllDelicious() {
+        return SendUtil.send(true, ConstMiNiStr.RESULT_SUCCESS, canteenService.getAllDelicious());
+    }
 }

+ 17 - 12
nngkxxdp/src/main/java/com/example/nngkxxdp/service/CanteenService.java

@@ -21,38 +21,41 @@ public interface CanteenService {
      * 通过ID查询单条数据
      *
      * @param id 主键
-     * @return java.util.Map<java.lang.String,java.lang.Object> 数据
+     * @return java.util.Map<java.lang.String, java.lang.Object> 数据
      */
     CanteenDO queryById(String id);
 
     /**
      * description: 分页查询
+     *
+     * @param startRows   分页参数
+     * @param limit       分页参数
+     * @param canteenName 食堂名称
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author zwq
      * @date 2022/8/31 16:01
-     * @param startRows 分页参数
-     * @param limit 分页参数
-     * @param canteenName 食堂名称
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     Map<String, Object> page(Integer startRows, Integer limit, String canteenName);
 
     /**
      * description: 新增数据
+     *
+     * @param canteenDO 数据
+     * @param files     食堂图片
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author zwq
      * @date 2022/9/2 9:26
-     * @param canteenDO 数据
-     * @param files 食堂图片
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     Map<String, Object> add(CanteenDO canteenDO, MultipartFile[] files) throws IOException;
 
     /**
      * description: 更新数据
+     *
+     * @param canteenDO 数据
+     * @param files     图片
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author zwq
      * @date 2022/9/2 10:22
-     * @param canteenDO 数据
-     * @param files 图片
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     Map<String, Object> update(CanteenDO canteenDO, MultipartFile[] files) throws IOException;
 
@@ -60,11 +63,13 @@ public interface CanteenService {
      * 通过主键删除数据
      *
      * @param id 主键
-     * @return java.util.Map<java.lang.String,java.lang.Object> 数据
+     * @return java.util.Map<java.lang.String, java.lang.Object> 数据
      */
     Map<String, Object> deleteById(String id);
 
     List<CanteenNeDO> all();
 
     Map<String, Object> detail(String canteenId);
+
+    List<Map<String, Object>> getAllDelicious();
 }

+ 39 - 12
nngkxxdp/src/main/java/com/example/nngkxxdp/service/impl/CanteenServiceImpl.java

@@ -14,7 +14,6 @@ import com.example.nngkxxdp.util.ConstStr;
 import com.example.nngkxxdp.util.SendUtil;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
@@ -22,6 +21,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.*;
 
+
 /**
  * 食堂表(SCanteen)表服务实现类
  *
@@ -56,12 +56,13 @@ public class CanteenServiceImpl implements CanteenService {
 
     /**
      * description: 分页查询
+     *
+     * @param startRows   分页参数
+     * @param limit       分页参数
+     * @param canteenName 食堂名称
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author zwq
      * @date 2022/8/31 16:01
-     * @param startRows 分页参数
-     * @param limit 分页参数
-     * @param canteenName 食堂名称
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     @Override
     public Map<String, Object> page(Integer startRows, Integer limit, String canteenName) {
@@ -79,11 +80,12 @@ public class CanteenServiceImpl implements CanteenService {
 
     /**
      * description: 新增数据
+     *
+     * @param canteenDO 数据
+     * @param files     食堂图片
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author zwq
      * @date 2022/9/2 9:26
-     * @param canteenDO 数据
-     * @param files 食堂图片
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     @Override
     public Map<String, Object> add(CanteenDO canteenDO, MultipartFile[] files) throws IOException {
@@ -131,11 +133,12 @@ public class CanteenServiceImpl implements CanteenService {
 
     /**
      * description: 更新数据
+     *
+     * @param canteenDO 数据
+     * @param files     文件
+     * @return java.util.Map<java.lang.String, java.lang.Object>
      * @author zwq
      * @date 2022/9/2 10:23
-     * @param canteenDO 数据
-     * @param files 文件
-     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     @Override
     public Map<String, Object> update(CanteenDO canteenDO, MultipartFile[] files) throws IOException {
@@ -233,7 +236,7 @@ public class CanteenServiceImpl implements CanteenService {
 
     @Override
     public List<CanteenNeDO> all() {
-        List<CanteenNeDO> canteenNeDOS =  canteenDao.getAllCanteen();
+        List<CanteenNeDO> canteenNeDOS = canteenDao.getAllCanteen();
         return canteenNeDOS;
     }
 
@@ -245,4 +248,28 @@ public class CanteenServiceImpl implements CanteenService {
         detail.put("supplyTime", time);
         return detail;
     }
+
+    @Override
+    public List<Map<String, Object>> getAllDelicious() {
+        List<CanteenNeDO> allCanteen = canteenDao.getAllCanteen();
+        List<Map<String, Object>> maps = new ArrayList<>();
+        for (CanteenNeDO canteenNeDO : allCanteen) {
+            List<Map<String, Object>> delicious = canteenDao.getAllDeliciousByDishesId(canteenNeDO.getId());
+            for (Map<String, Object> objectMap : delicious) {
+                Map<String, Object> evaluation = canteenDao.getLatestComment((String) objectMap.get("dishesId"), canteenNeDO.getId());
+                objectMap.put("evaluation", evaluation.get("evaluation"));
+                objectMap.put("dishesName", evaluation.get("dishesName"));
+                if (Blank.isNotEmpty(evaluation.get("dishesPhotoPath"))) {
+                    SFile sFile = fileDao.selectById(Integer.valueOf(evaluation.get("dishesPhotoPath").toString().split(",")[0]));
+                    objectMap.put("dishesPic", sFile.getPath());
+                }
+            }
+            HashMap<String, Object> map = new HashMap<>(3);
+            map.put("id", canteenNeDO.getId());
+            map.put("canteenName", canteenNeDO.getCanteenName());
+            map.put("deliciousList", delicious);
+            maps.add(map);
+        }
+        return maps;
+    }
 }

+ 83 - 45
nngkxxdp/src/main/resources/mapper/CanteenDao.xml

@@ -18,39 +18,47 @@
 
     <!--查询单个-->
     <select id="queryById" resultMap="CanteenMap">
-        SELECT
-          id, canteen_name, canteen_photo_path, supply_time_id, founder, principal, complaint_phone, takeout_phone,
-          create_time, update_time, isdel
+        SELECT id,
+               canteen_name,
+               canteen_photo_path,
+               supply_time_id,
+               founder,
+               principal,
+               complaint_phone,
+               takeout_phone,
+               create_time,
+               update_time,
+               isdel
         FROM s_canteen
         WHERE id = #{id}
     </select>
-    
+
     <!--分页计数-->
     <select id="pageCount" resultType="java.lang.Long">
         SELECT COUNT(*)
         FROM s_canteen
         <where>
-          s_canteen.isdel = 0
-          <if test="canteenName != null and canteenName != ''">
-             AND canteen_name LIKE CONCAT('%', #{canteenName}, '%')
-          </if>
+            s_canteen.isdel = 0
+            <if test="canteenName != null and canteenName != ''">
+                AND canteen_name LIKE CONCAT('%', #{canteenName}, '%')
+            </if>
         </where>
     </select>
 
     <!--分页列表-->
     <select id="pageList" resultType="java.util.Map">
         SELECT
-          s_canteen.id, canteen_name, canteen_photo_path, supply_time_id, u.user_name founder, s_canteen.principal,
-          complaint_phone complaintPhone, takeout_phone takeoutPhone, s_canteen.create_time, s_canteen.update_time,
-          s_canteen.isdel
+        s_canteen.id, canteen_name, canteen_photo_path, supply_time_id, u.user_name founder, s_canteen.principal,
+        complaint_phone complaintPhone, takeout_phone takeoutPhone, s_canteen.create_time, s_canteen.update_time,
+        s_canteen.isdel
         FROM s_canteen
         LEFT JOIN p_user u
         ON u.id = s_canteen.founder
         <where>
-          s_canteen.isdel = 0
-          <if test="canteenName != null and canteenName != ''">
-            AND canteen_name LIKE CONCAT('%', #{canteenName}, '%')
-          </if>
+            s_canteen.isdel = 0
+            <if test="canteenName != null and canteenName != ''">
+                AND canteen_name LIKE CONCAT('%', #{canteenName}, '%')
+            </if>
         </where>
         ORDER BY s_canteen.create_time DESC
         LIMIT #{startRows}, #{limit}
@@ -62,15 +70,15 @@
                supply_time_id
         from s_canteen
         where isdel = 0
-              and id =#{canteenId}
+          and id = #{canteenId}
     </select>
 
     <!--新增所有列-->
     <insert id="addSCanteen">
         INSERT INTO s_canteen(id, canteen_name, canteen_photo_path, supply_time_id, founder, principal,
-        complaint_phone, takeout_phone, create_time, update_time, isdel)
+                              complaint_phone, takeout_phone, create_time, update_time, isdel)
         VALUES (#{id}, #{canteenName}, #{canteenPhotoPath}, #{supplyTimeId}, #{founder}, #{principal},
-        #{complaintPhone}, #{takeoutPhone}, #{createTime}, #{updateTime}, #{isdel})
+                #{complaintPhone}, #{takeoutPhone}, #{createTime}, #{updateTime}, #{isdel})
     </insert>
 
     <!--通过主键修改数据-->
@@ -109,20 +117,20 @@
     <select id="deleteCount" resultType="java.lang.Long">
         SELECT SUM(a.b) num
         FROM (
-        (SELECT COUNT(*) b
-        FROM
-        (SELECT 1 FROM s_canteen
-        INNER JOIN s_food sf ON sf.canteen_id = s_canteen.id
-        WHERE s_canteen.id = #{id}
-        LIMIT 1) food_num)
-        UNION ALL
-        (SELECT COUNT(*) b
-        FROM
-        (SELECT 1 FROM s_canteen
-        INNER JOIN s_menu sm ON sm.canteen_id = s_canteen.id
-        WHERE s_canteen.id = #{id}
-        LIMIT 1) menu_num)
-        ) a
+                 (SELECT COUNT(*) b
+                  FROM (SELECT 1
+                        FROM s_canteen
+                                 INNER JOIN s_food sf ON sf.canteen_id = s_canteen.id
+                        WHERE s_canteen.id = #{id}
+                        LIMIT 1) food_num)
+                 UNION ALL
+                 (SELECT COUNT(*) b
+                  FROM (SELECT 1
+                        FROM s_canteen
+                                 INNER JOIN s_menu sm ON sm.canteen_id = s_canteen.id
+                        WHERE s_canteen.id = #{id}
+                        LIMIT 1) menu_num)
+             ) a
     </select>
 
     <!--通过主键删除-->
@@ -133,19 +141,49 @@
     </delete>
 
     <select id="getAllCanteen" resultType="com.example.nngkxxdp.entity.CanteenNeDO">
-        SELECT
-            canteen_name,
-            id,
-            supply_time_id,
-            founder,
-            principal,
-            complaint_phone,
-            takeout_phone,
-            canteen_photo_path
-        FROM
-            s_canteen
-        WHERE
-            isdel = 0
+        SELECT canteen_name,
+               id,
+               supply_time_id,
+               founder,
+               principal,
+               complaint_phone,
+               takeout_phone,
+               canteen_photo_path
+        FROM s_canteen
+        WHERE isdel = 0
+    </select>
+    <select id="getAllDeliciousByDishesId" resultType="java.util.Map">
+        SELECT se.id                        commentId,
+               se.dishesId,
+               ROUND(AVG(se.score / 20), 0) score,
+               COUNT(*)                     commentCount,
+               COUNT(se.islike = 1 OR NULL) compliment
+        FROM `s_evaluation` se
+        WHERE se.isdel = 0
+          and se.isviolations = 0
+          and se.canteenId = #{id}
+          and YEARWEEK(date_format(se.create_time
+                           , '%Y-%m-%d')
+                  , 1) = YEARWEEK(now()
+                             , 1) - 1
+        GROUP BY se.dishesId
+        ORDER BY se.score DESC,
+                 compliment DESC
+        limit 3
+    </select>
+    <select id="getLatestComment" resultType="java.util.Map">
+        select se.evaluation,
+               sf.dishes_name,
+               se.dishesId,
+               sf.dishes_photo_path
+        from s_evaluation se
+                 left join s_food sf on sf.id = se.dishesId
+        where se.isdel = 0
+          and se.isviolations = 0
+          and se.dishesId = #{dishesId}
+          and se.canteenId = #{canteenId}
+        order by se.create_time DESC
+        limit 1
     </select>
 
 </mapper>

+ 2 - 2
nngkxxdp/src/main/resources/static/naqwzsjtj/naqwzsjtj/src/views/canteen/Food.vue

@@ -201,9 +201,7 @@
             //打开修改界面
             openModifyWorkDialog(data) {
                 this.workTitle = '编辑菜品';
-                console.log(JSON.stringify(data));
                 this.postManagement = JSON.parse(JSON.stringify(data));
-                this.postManagement.dishesPhotoPath = '';
                 this.postManagement.pic = [];
                 let params = {
                     picId: this.postManagement.dishesPhotoPath
@@ -218,6 +216,8 @@
                                 name: item.id
                             }
                         })
+                    } else {
+                        this.postManagement.dishesPhotoPath = '';
                     }
                 })
                 this.workDialog = true;

+ 109 - 81
nngkxxdp/src/main/resources/static/nnzwminiapp/pages/deliciousList/deliciousList.js

@@ -1,87 +1,115 @@
 // pages/deliciousList.js
 import {
-	imgUrl
+	imgUrl,
+	request,
+	baseUrl
 } from "../api/request"
 Page({
 
-  /**
-   * 页面的初始数据
-   */
-  data: {
-	imgUrl:imgUrl,
-    tab: 0,
-    item: ''
-  },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad: function (options) {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload: function () {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh: function () {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
-  },
-
-  changeItem: function (e) {
-    this.setData({
-      item: e.currentTarget.dataset.item
-    })
-  },
-  changeTab: function (e) {
-    this.setData({
-      tab: e.detail.current
-    })
-  },
-  toComment:function (e) {
-    wx.navigateTo({
-      url: '/pages/commentList/commentList'
-    })
-  }
+	/**
+	 * 页面的初始数据
+	 */
+	data: {
+		// 图片前缀
+		imgUrl: imgUrl,
+		// 服务器地址
+		baseUrl: baseUrl + '/',
+		// 默认选中
+		currentTab: 0,
+		// 食堂列表
+		canteenList: []
+	},
+	getDeliciousList() {
+		request({
+			url: '/canteen/getDeliciousList',
+			method: 'GET'
+		}).then(res => {
+			console.log(res);
+			this.setData({
+				canteenList: res.data
+			})
+		})
+	},
+	// 切换食堂
+	tabNav(e) {
+		let currentTab = e.currentTarget.dataset.index
+		this.setData({
+			currentTab
+		})
+	},
+	// 切换食堂
+	handleSwiper(e) {
+		let {
+			current,
+			source
+		} = e.detail
+		if (source === 'autoplay' || source === 'touch') {
+			const currentTab = current
+			this.setData({
+				currentTab
+			})
+		}
+	},
+	// 查看评论
+	toComment: function (e) {
+		wx.navigateTo({
+			url: '/pages/commentList/commentList'
+		})
+	},
+
+	/**
+	 * 生命周期函数--监听页面加载
+	 */
+	onLoad: function (options) {
+		this.getDeliciousList();
+	},
+
+	/**
+	 * 生命周期函数--监听页面初次渲染完成
+	 */
+	onReady: function () {
+
+	},
+
+	/**
+	 * 生命周期函数--监听页面显示
+	 */
+	onShow: function () {
+
+	},
+
+	/**
+	 * 生命周期函数--监听页面隐藏
+	 */
+	onHide: function () {
+
+	},
+
+	/**
+	 * 生命周期函数--监听页面卸载
+	 */
+	onUnload: function () {
+
+	},
+
+	/**
+	 * 页面相关事件处理函数--监听用户下拉动作
+	 */
+	onPullDownRefresh: function () {
+
+	},
+
+	/**
+	 * 页面上拉触底事件的处理函数
+	 */
+	onReachBottom: function () {
+
+	},
+
+	/**
+	 * 用户点击右上角分享
+	 */
+	onShareAppMessage: function () {
+
+	}
 })

+ 80 - 116
nngkxxdp/src/main/resources/static/nnzwminiapp/pages/deliciousList/deliciousList.wxml

@@ -1,123 +1,87 @@
 <!--pages/deliciousList.wxml-->
 <view class="head-bg">
-  <image style="width:100%" src="{{imgUrl}}list_bg.png"></image>
-</view>
-<view class="tab">
-  <view class="tab-item {{tab==0?'active':''}}" bindtap="changeItem" data-item="0">
-    <view style="height:90rpx;">A区食堂美味榜</view>
-  </view>
-  <view class="tab-item {{tab==1?'active':''}}" bindtap="changeItem" data-item="1">
-    <view style="height:90rpx">B区食堂美味榜</view>
-  </view>
+	<image style="width:100%" src="{{imgUrl}}list_bg.png"></image>
 </view>
+<scroll-view scroll-x class="tab" scroll-with-animation="true" scroll-into-view="item{{currentTab < 2 ? 0 : currentTab - 1 }}">
+	<view id="item{{index}}" wx:for="{{canteenList}}" wx:key="index" class="tab-item {{currentTab === index?'active' : ''}}" bindtap="tabNav" data-index="{{index}}">
+		{{item.canteenName}}美味榜
+	</view>
+</scroll-view>
 <!-- 内容 -->
 <view class="swiper-content">
-  <swiper current="{{item}}" bindchange="changeTab">
-    <swiper-item>
-      <scroll-view scroll-y="true" style="height: 100%;padding:0;margin:0;">
-        <view class="content">
-          <view class="cont-width first">
-            <view class="cont-bg" style="background-image: url({{imgUrl}}cont_bg.png);">
-              <view class="number" style="background-image: url(/pages//images/top1.png);">
-                <view>TOP</view>
-                <view>——</view>
-                <view>01</view>
-              </view>
-            </view>
-            <view class="stars">
-              <span>鲜椒过水钳鱼</span>
-              <image style="margin-left: 20px;" src="../images/stars2.png"></image>
-              <image src="../images/stars2.png"></image>
-              <image src="../images/stars2.png"></image>
-              <image src="../images/stars2.png"></image>
-              <image src="../images/stars2.png"></image>
-            </view>
-            <view class="quality">此菜品上周共获得<span>89</span>次点赞,获得<span>12</span>次评论</view>
-            <view class="comments">
-              <view>最新评论:</view>
-              <view>“鱼很入味,肉质十分鲜滑,也没有什么鱼翅,非常下饭。”</view>
-            </view>
-            <view class="btn">
-              <view bindtap="toComment">点击查看</view>
-            </view>
-          </view>
-          <view class="cont-width second">
-            <view class="cont-bg" style="background-image: url({{imgUrl}}cont_bg.png);">
-              <view class="number" style="background-image: url(/pages//images/top2.png);">
-                <view>TOP</view>
-                <view>——</view>
-                <view>02</view>
-              </view>
-            </view>
-            <view class="stars">
-              <span>鲜椒过水钳鱼</span>
-              <i></i><i></i><i></i><i></i><i></i><i></i>
-            </view>
-            <view class="quality">此菜品上周共获得<span>89</span>次点赞,获得<span>12</span>次评论</view>
-            <view class="comments">
-              <view>最新评论:</view>
-              <view>“鱼很入味,肉质十分鲜滑,也没有什么鱼翅,非常下饭。”</view>
-            </view>
-            <view class="btn">
-              <view bindtap="toComment">点击查看</view>
-            </view>
-          </view>
-        </view>
-      </scroll-view>
-    </swiper-item>
-
-    <swiper-item>
-      <scroll-view scroll-y="true" style="height: 100%">
-        <view class="content">
-          <view class="cont-width first">
-            <view class="cont-bg" style="background-image: url({{imgUrl}}cont_bg.png);">
-              <view class="number" style="background-image: url(/pages//images/top1.png);">
-                <view>TOP</view>
-                <view>——</view>
-                <view>01</view>
-              </view>
-            </view>
-            <view class="stars">
-              <span>鲜椒过水钳鱼</span>
-              <image style="margin-left: 20px;" src="../images/stars2.png"></image>
-              <image src="../images/stars2.png"></image>
-              <image src="../images/stars2.png"></image>
-              <image src="../images/stars2.png"></image>
-              <image src="../images/stars2.png"></image>
-            </view>
-            <view class="quality">此菜品上周共获得<span>89</span>次点赞,获得<span>12</span>次评论</view>
-            <view class="comments">
-              <view>最新评论:</view>
-              <view>“鱼很入味,肉质十分鲜滑,也没有什么鱼翅,非常下饭。”</view>
-            </view>
-            <view class="btn">
-              <view bindtap="toComment">点击查看</view>
-            </view>
-          </view>
-          <view class="cont-width second">
-            <view class="cont-bg" style="background-image: url({{imgUrl}}cont_bg.png);">
-              <view class="number" style="background-image: url(/pages//images/top2.png);">
-                <view>TOP</view>
-                <view>——</view>
-                <view>02</view>
-              </view>
-            </view>
-            <view class="stars">
-              <span>鲜椒过水钳鱼</span>
-              <i></i><i></i><i></i><i></i><i></i><i></i>
-            </view>
-            <view class="quality">此菜品上周共获得<span>89</span>次点赞,获得<span>12</span>次评论</view>
-            <view class="comments">
-              <view>最新评论:</view>
-              <view>“鱼很入味,肉质十分鲜滑,也没有什么鱼翅,非常下饭。”</view>
-            </view>
-            <view class="btn">
-              <view bindtap="toComment">点击查看</view>
-            </view>
-          </view>
-        </view>
-      </scroll-view>
-    </swiper-item>
-  </swiper>
+	<swiper current="{{currentTab}}" bindchange="handleSwiper">
+		<swiper-item wx:for="{{canteenList}}" wx:key="index">
+			<scroll-view scroll-y="true" style="height: 100%;padding:0;margin:0;">
+				<view class="content">
+					<view hidden="{{!item.deliciousList[0]}}" class="cont-width first">
+						<view class="cont-bg" style="background-image: url({{imgUrl}}cont_bg.png);">
+							<view class="number" style="background-image: url({{imgUrl}}top1.png);">
+								<view>TOP</view>
+								<view>——</view>
+								<view>01</view>
+							</view>
+						</view>
+						<view class="stars">
+							<span style="margin-right: 20rpx;">{{item.deliciousList[0].dishesName}}</span>
+							<image wx:key="index" wx:for="{{item.deliciousList[0].score}}" src="{{imgUrl}}stars1.png"></image>
+							<image wx:key="index" wx:for="{{5 - item.deliciousList[0].score}}" src="{{imgUrl}}stars2.png"></image>
+						</view>
+						<view class="quality">此菜品上周共获得<span>{{item.deliciousList[0].compliment}}</span>次点赞,获得<span>{{item.deliciousList[0].commentCount}}</span>次评论</view>
+						<view class="comments">
+							<view>最新评论:</view>
+							<view>“{{item.deliciousList[0].evaluation}}”</view>
+						</view>
+						<view class="btn">
+							<view bindtap="toComment">点击查看</view>
+						</view>
+					</view>
+					<view hidden="{{!item.deliciousList[1]}}" class="cont-width second">
+						<view class="cont-bg" style="background-image: url({{imgUrl}}cont_bg.png);">
+							<view class="number" style="background-image: url({{imgUrl}}top2.png);">
+								<view>TOP</view>
+								<view>——</view>
+								<view>02</view>
+							</view>
+						</view>
+						<view class="stars">
+							<span style="margin-right: 20rpx;">{{item.deliciousList[1].dishesName}}</span>
+							<image wx:key="index" wx:for="{{item.deliciousList[1].score}}" src="{{imgUrl}}stars1.png"></image>
+							<image wx:key="index" wx:for="{{5 - item.deliciousList[1].score}}" src="{{imgUrl}}stars2.png"></image>
+						</view>
+						<view class="quality">此菜品上周共获得<span>{{item.deliciousList[1].compliment}}</span>次点赞,获得<span>{{item.deliciousList[1].commentCount}}</span>次评论</view>
+						<view class="comments">
+							<view>最新评论:</view>
+							<view>“{{item.deliciousList[1].evaluation}}”</view>
+						</view>
+						<view class="btn">
+							<view bindtap="toComment">点击查看</view>
+						</view>
+					</view>
+					<view hidden="{{!item.deliciousList[2]}}" class="cont-width third">
+						<view class="cont-bg" style="background-image: url({{imgUrl}}cont_bg.png);">
+							<view class="number" style="background-image: url({{imgUrl}}top3.png);">
+								<view>TOP</view>
+								<view>——</view>
+								<view>03</view>
+							</view>
+						</view>
+						<view class="stars">
+							<span style="margin-right: 20rpx;">{{item.deliciousList[2].dishesName}}</span>
+							<image wx:key="index" wx:for="{{item.deliciousList[2].score}}" src="{{imgUrl}}stars1.png"></image>
+							<image wx:key="index" wx:for="{{5 - item.deliciousList[2].score}}" src="{{imgUrl}}stars2.png"></image>
+						</view>
+						<view class="quality">此菜品上周共获得<span>{{item.deliciousList[2].compliment}}</span>次点赞,获得<span>{{item.deliciousList[2].commentCount}}</span>次评论</view>
+						<view class="comments">
+							<view>最新评论:</view>
+							<view>“{{item.deliciousList[2].evaluation}}”</view>
+						</view>
+						<view class="btn">
+							<view bindtap="toComment">点击查看</view>
+						</view>
+					</view>
+				</view>
+			</scroll-view>
+		</swiper-item>
+	</swiper>
 </view>
 <!-- 内容结尾 -->

+ 78 - 77
nngkxxdp/src/main/resources/static/nnzwminiapp/pages/deliciousList/deliciousList.wxss

@@ -1,136 +1,137 @@
 /* pages/deliciousList.wxss */
-page{
-  background: #F5F5F5;
+page {
+	background: #F5F5F5;
 }
+
 .content .cont-width {
-  width: 90%;
-  margin: 1.25rem auto;
-  background: #FFFFFF;
-  box-shadow: 0px 6px 12px 0px rgba(187, 187, 187, 0.5);
-  border-radius: 10px;
-  padding: 0.9375rem 0.625rem;
+	width: 90%;
+	margin: 1.25rem auto;
+	background: #FFFFFF;
+	box-shadow: 0px 6px 12px 0px rgba(187, 187, 187, 0.5);
+	border-radius: 10px;
+	padding: 0.9375rem 0.625rem;
 }
 
 .content .cont-width .cont-bg {
-  height: 6.625rem;
-  border-radius: 20px;
-  margin: 0 auto;
-  margin-bottom: 0.625rem;
-  background-size: 100% 100%;
-  position: relative;
+	height: 6.625rem;
+	border-radius: 20px;
+	margin: 0 auto;
+	margin-bottom: 0.625rem;
+	background-size: 100% 100%;
+	position: relative;
 }
 
 .content .cont-width .cont-bg .number {
-  position: absolute;
-  width: 3.0625rem;
-  height: 3.725rem;
-  font-size: 0.8125rem;
-  color: #fff;
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  justify-content: center;
-  background-size: 100% 100%;
-  margin-top: -1.125rem;
-  margin-left: 0.625rem;
+	position: absolute;
+	width: 3.0625rem;
+	height: 3.725rem;
+	font-size: 0.8125rem;
+	color: #fff;
+	display: flex;
+	flex-direction: column;
+	align-items: center;
+	justify-content: center;
+	background-size: 100% 100%;
+	margin-top: -1.125rem;
+	margin-left: 0.625rem;
 }
 
 .content .cont-width .cont-bg .number view {
-  height: 0.625rem;
-  line-height: 0.625rem;
+	height: 0.625rem;
+	line-height: 0.625rem;
 }
 
 .content .cont-width .cont-bg .number view:nth-child(2n) {
-  font-size: 0.625rem;
-  opacity: 0.34;
+	font-size: 0.625rem;
+	opacity: 0.34;
 }
 
 .content .cont-width .cont-bg .number view:last-child {
-  font-size: 0.75rem;
-  font-family: DOUYU;
-  font-weight: normal;
+	font-size: 0.75rem;
+	font-family: DOUYU;
+	font-weight: normal;
 }
 
 .content .cont-width .stars {
-  font-size: 1rem;
-  font-weight: 600;
-  display: flex;
-  align-items: center;
+	font-size: 1rem;
+	font-weight: 600;
+	display: flex;
+	align-items: center;
 }
 
 .content .cont-width .stars image {
-  width: 0.9375rem;
-  height: 0.9375rem;
-  margin-left: 3px;
+	width: 0.9375rem;
+	height: 0.9375rem;
+	margin-left: 3px;
 }
 
 .content .cont-width .quality {
-  font-size: 0.875rem;
-  margin: 0.625rem 0;
-  color: #666
+	font-size: 0.875rem;
+	margin: 0.625rem 0;
+	color: #666
 }
 
 .content .cont-width .quality view {
-  color: #F58E3C;
+	color: #F58E3C;
 }
 
 .content .cont-width .comments {
-  font-size: 0.875rem;
-  display: flex;
+	font-size: 0.875rem;
+	display: flex;
 }
 
 .content .cont-width .comments view:first-child {
-  width: 6.825rem;
-  font-weight: 600;
+	width: 6.825rem;
+	font-weight: 600;
 }
 
 .content .cont-width .comments view:last-child {
-  color: #508FF4;
+	color: #508FF4;
 }
 
 .content .cont-width .btn {
-  display: flex;
-  justify-content: flex-end;
+	display: flex;
+	justify-content: flex-end;
 }
 
 .content .cont-width .btn view {
-  width: 4.825rem;
-  height: 2rem;
-  line-height: 2rem;
-  font-size: 0.875rem;
-  color: #fff;
-  text-align: center;
-  background: #FF6C00;
-  border-radius: 30px;
+	width: 4.825rem;
+	height: 2rem;
+	line-height: 2rem;
+	font-size: 0.875rem;
+	color: #fff;
+	text-align: center;
+	background: #FF6C00;
+	border-radius: 30px;
 }
 
 /* tab */
-.tab{
-  height: 8vh;
-  display: flex;
+.tab {
+	white-space: nowrap;
+	-webkit-overflow-scrolling: touch;
+	background: #FFF;
+	height: 90rpx;
+	padding: 0 32rpx;
+	box-sizing: border-box;
 }
 
-.tab-item{
-  flex: 1;
-  font-size: 35rpx;
-  text-align: center;
-  line-height: 90rpx;
-  height: 90rpx;
-  border-bottom: 6rpx solid #eee ;
-  display: flex;
-  justify-content: center;
-  flex-direction: row;
+.tab-item {
+	font-size: 35rpx;
+	text-align: center;
+	display: inline-block;
+	height: 90rpx;
+	line-height: 90rpx;
+	margin: 0 30rpx;
 }
 
-.tab-item.active{
-  color: rgb(79, 172, 226);
-  border-bottom: 7rpx solid rgb(79, 172, 226);
+.tab-item.active {
+	color: rgb(79, 172, 226);
 }
 
 .swiper-content {
-  height: 64vh;
+	height: 64vh;
 }
 
 .swiper-content swiper {
-  height: 100%;
+	height: 100%;
 }