浏览代码

评论接口

elis 2 年之前
父节点
当前提交
c44075e265

+ 5 - 7
nngkxxdp/src/main/java/com/example/nngkxxdp/controller/EvaluationController.java

@@ -2,6 +2,7 @@ package com.example.nngkxxdp.controller;
 
 import cn.hutool.core.util.StrUtil;
 import com.example.nngkxxdp.entity.SEvaluation;
+import com.example.nngkxxdp.entity.SEvaluationDO;
 import com.example.nngkxxdp.entity.SEvaluationVo;
 import com.example.nngkxxdp.service.SEvaluationService;
 import com.example.nngkxxdp.util.ConstStr;
@@ -9,10 +10,7 @@ import com.example.nngkxxdp.util.SendUtil;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Sort;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.Map;
 
@@ -48,7 +46,7 @@ public class EvaluationController {
      * @return
      */
     @PostMapping("/page")
-    public Map<String, Object> queryPage(SEvaluationVo sEvaluation){
+    public Map<String, Object> queryPage(@RequestBody SEvaluationVo sEvaluation){
         PageRequest pageRequest;
         try{
              pageRequest = PageRequest.of(sEvaluation.getPage(),sEvaluation.getSize());
@@ -56,8 +54,8 @@ public class EvaluationController {
             e.printStackTrace();
             return SendUtil.send(false, e.getMessage(),null);
         }
-        Page<SEvaluation> sEvaluations = sEvaluationService.queryByPage(sEvaluation, pageRequest);
-        return SendUtil.send(sEvaluations);
+        Page<SEvaluationDO> sEvaluations = sEvaluationService.queryByPage(sEvaluation, pageRequest);
+        return SendUtil.send(true, ConstStr.RESULT_SUCCESS,sEvaluations);
     }
 
     /**

+ 2 - 1
nngkxxdp/src/main/java/com/example/nngkxxdp/dao/SEvaluationDao.java

@@ -2,6 +2,7 @@ package com.example.nngkxxdp.dao;
 
 import com.example.nngkxxdp.entity.FoodGradeDo;
 import com.example.nngkxxdp.entity.SEvaluation;
+import com.example.nngkxxdp.entity.SEvaluationDO;
 import com.example.nngkxxdp.entity.SEvaluationVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -33,7 +34,7 @@ public interface SEvaluationDao {
      * @param pageable    分页对象
      * @return 对象列表
      */
-    List<SEvaluation> queryAllByLimit(SEvaluationVo sEvaluation, @Param("pageable") Pageable pageable);
+    List<SEvaluationDO> queryAllByLimit(SEvaluationVo sEvaluation, @Param("pageable") Pageable pageable);
 
     /**
      * 统计总行数

+ 65 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/entity/SEvaluationDO.java

@@ -0,0 +1,65 @@
+package com.example.nngkxxdp.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 评价表(SEvaluation)实体类
+ *
+ * @author elis
+ * @since 2022-09-01 10:36:43
+ */
+@Data
+public class SEvaluationDO implements Serializable {
+    private static final long serialVersionUID = -22272998471408823L;
+    /**
+     * id
+     */
+    private String id;
+    /**
+     * 食堂id
+     */
+    private String canteenName;
+    /**
+     * 菜品id
+     */
+    private String dishesName;
+    /**
+     * 评分
+     */
+    private String score;
+    /**
+     * 评价
+     */
+    private String evaluation;
+    /**
+     * 图片路径组
+     */
+    private String photoPath;
+    /**
+     * 视频路径组
+     */
+    private String videoPath;
+    /**
+     * 人员id
+     */
+    private String userid;
+    /**
+     * 是否违规0:未违规-1:违规
+     */
+    private Integer isviolations;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+
+}
+

+ 22 - 2
nngkxxdp/src/main/java/com/example/nngkxxdp/entity/SEvaluationVo.java

@@ -1,6 +1,12 @@
 package com.example.nngkxxdp.entity;
 
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSetter;
 import lombok.Data;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
 import org.springframework.data.domain.Sort;
 
 import java.util.Date;
@@ -10,31 +16,45 @@ public class SEvaluationVo {
     /**
      * 食堂id
      */
-    private String canteenid;
+    @JsonProperty("canteenName")
+    private String canteenName;
     /**
      * 菜品id
      */
-    private String dishesid;
+    @JsonProperty("dishesName")
+    private String dishesName;
+
     /**
      * 人员id
      */
+    @JsonProperty("userid")
     private String userid;
+
+    @JsonProperty("score")
+    private Double score;
     /**
      * 是否违规0:未违规-1:违规
      */
+    @JsonProperty("isviolations")
     private Integer isviolations;
 
     /**
      * 创建时间
      */
+    @JsonProperty("createTime")
     private Date createTime;
     /**
      * 更新时间
      */
+    @JsonProperty("updateTime")
     private Date updateTime;
 
+    @NonNull
+    @JsonProperty("size")
     private Integer size;
 
+    @NonNull
+    @JsonProperty("page")
     private Integer page;
 
     private Sort sort;

+ 2 - 1
nngkxxdp/src/main/java/com/example/nngkxxdp/service/SEvaluationService.java

@@ -1,6 +1,7 @@
 package com.example.nngkxxdp.service;
 
 import com.example.nngkxxdp.entity.SEvaluation;
+import com.example.nngkxxdp.entity.SEvaluationDO;
 import com.example.nngkxxdp.entity.SEvaluationVo;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
@@ -31,7 +32,7 @@ public interface SEvaluationService {
      * @param pageRequest 分页对象
      * @return 查询结果
      */
-    Page<SEvaluation> queryByPage(SEvaluationVo sEvaluation, PageRequest pageRequest);
+    Page<SEvaluationDO> queryByPage(SEvaluationVo sEvaluation, PageRequest pageRequest);
 
     /**
      * 新增数据

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

@@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert;
 import com.example.nngkxxdp.entity.FoodGradeDo;
 import com.example.nngkxxdp.entity.SEvaluation;
 import com.example.nngkxxdp.dao.SEvaluationDao;
+import com.example.nngkxxdp.entity.SEvaluationDO;
 import com.example.nngkxxdp.entity.SEvaluationVo;
 import com.example.nngkxxdp.service.SEvaluationService;
 import org.springframework.stereotype.Service;
@@ -47,7 +48,7 @@ public class SEvaluationServiceImpl implements SEvaluationService {
      * @return 查询结果
      */
     @Override
-    public Page<SEvaluation> queryByPage(SEvaluationVo sEvaluation, PageRequest pageRequest) {
+    public Page<SEvaluationDO> queryByPage(SEvaluationVo sEvaluation, PageRequest pageRequest) {
         long total = sEvaluationDao.count(sEvaluation);
         return new PageImpl<>(sEvaluationDao.queryAllByLimit(sEvaluation, pageRequest), pageRequest, total);
     }

+ 30 - 56
nngkxxdp/src/main/resources/mapper/SEvaluationDao.xml

@@ -27,45 +27,32 @@
     </select>
 
     <!--查询指定行数据-->
-    <select id="queryAllByLimit" resultMap="SEvaluationMap">
+    <select id="queryAllByLimit" resultType="com.example.nngkxxdp.entity.SEvaluationDO">
         select
-          id, canteenId, dishesId, score, evaluation, photo_path, video_path, islike, userId, isviolations, create_time, update_time
-        from s_evaluation
+        se.id, sc.canteen_name, sf.dishes_name, se.score, se.evaluation, se.photo_path, se.video_path, se.islike, se.isviolations, se.create_time, se.update_time
+        from s_evaluation se
+        left join s_canteen sc on sc.id = se.canteenId
+        left join s_food sf on sf.id = se.dishesId
         <where>
-            <if test="canteenid != null and canteenid != ''">
-                and canteenId = #{canteenid}
-            </if>
-            <if test="dishesid != null and dishesid != ''">
-                and dishesId = #{dishesid}
+            <if test="sEvaluation.canteenName != null and sEvaluation.canteenName != ''">
+                and sc.canteen_name like  CONCAT('%', #{sEvaluation.canteenName}, '%')
             </if>
-            <if test="score != null and score != ''">
-                and score = #{score}
-            </if>
-            <if test="evaluation != null and evaluation != ''">
-                and evaluation = #{evaluation}
+            <if test="sEvaluation.dishesName != null and sEvaluation.dishesName != ''">
+                and sf.dishes_name LIKE CONCAT('%',+#{sEvaluation.dishesName}+,'%')
             </if>
-            <if test="photoPath != null and photoPath != ''">
-                and photo_path = #{photoPath}
+            <if test="sEvaluation.score != null and sEvaluation.score != ''">
+                and se.score = #{sEvaluation.score}
             </if>
-            <if test="videoPath != null and videoPath != ''">
-                and video_path = #{videoPath}
-            </if>
-            <if test="islike != null">
-                and islike = #{islike}
-            </if>
-            <if test="userid != null and userid != ''">
-                and userId = #{userid}
-            </if>
-            <if test="isviolations != null">
-                and isviolations = #{isviolations}
+            <if test="sEvaluation.isviolations != null">
+                and se.isviolations = #{sEvaluation.isviolations}
             </if>
-            <if test="createTime != null">
-                and create_time = #{createTime}
+            <if test="sEvaluation.createTime != null">
+                and se.create_time = #{sEvaluation.createTime}
             </if>
-            <if test="updateTime != null">
-                and update_time = #{createTime}
+            <if test="sEvaluation.updateTime != null">
+                and se.update_time = #{sEvaluation.updateTime}
             </if>
-            and isdel = 0
+            and se.isdel = 0
         </where>
         limit #{pageable.offset}, #{pageable.pageSize}
     </select>
@@ -73,42 +60,29 @@
     <!--统计总行数-->
     <select id="count" resultType="java.lang.Long">
         select count(1)
-        from s_evaluation
+        from s_evaluation se
+        left join s_canteen sc on sc.id = se.canteenId
+        left join s_food sf on sf.id = se.dishesId
         <where>
-            <if test="canteenid != null and canteenid != ''">
-                and canteenId = #{canteenid}
+            <if test="canteenName != null and canteenName != ''">
+                and sc.canteen_name like  CONCAT('%', #{canteenName}, '%')
             </if>
-            <if test="dishesid != null and dishesid != ''">
-                and dishesId = #{dishesid}
+            <if test="dishesName != null and dishesName != ''">
+                and sf.dishes_name LIKE CONCAT('%',+#{dishesName}+,'%')
             </if>
             <if test="score != null and score != ''">
-                and score = #{score}
-            </if>
-            <if test="evaluation != null and evaluation != ''">
-                and evaluation = #{evaluation}
-            </if>
-            <if test="photoPath != null and photoPath != ''">
-                and photo_path = #{photoPath}
-            </if>
-            <if test="videoPath != null and videoPath != ''">
-                and video_path = #{videoPath}
-            </if>
-            <if test="islike != null">
-                and islike = #{islike}
-            </if>
-            <if test="userid != null and userid != ''">
-                and userId = #{userid}
+                and se.score = #{score}
             </if>
             <if test="isviolations != null">
-                and isviolations = #{isviolations}
+                and se.isviolations = #{isviolations}
             </if>
             <if test="createTime != null">
-                and create_time = #{createTime}
+                and se.create_time = #{createTime}
             </if>
             <if test="updateTime != null">
-                and update_time = #{createTime}
+                and se.update_time = #{updateTime}
             </if>
-            and isdel = 0
+            and se.isdel = 0
         </where>
     </select>