فهرست منبع

获取每个人最新的截图

Reiskuchen 5 سال پیش
والد
کامیت
e2c425aa4c

+ 13 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ScreenshotController.java

@@ -1,13 +1,16 @@
 package com.management.platform.controller;
 
 
+import com.management.platform.service.ScreenshotService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
 
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author 吴涛涛
@@ -16,6 +19,15 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/screenshot")
 public class ScreenshotController {
+    @Autowired
+    private ScreenshotService screenshotService;
 
+    /**
+     * 获取每个人最新的截图
+     */
+    @RequestMapping("/getLatestScreenshotList")
+    public HttpRespMsg getLatestScreenshotList() {
+        return screenshotService.getLatestScreenshotList();
+    }
 }
 

+ 5 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ScreenshotMapper.java

@@ -5,15 +5,19 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.management.platform.entity.vo.ScreenshotVO;
 import com.management.platform.util.HttpRespMsg;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
- *  Mapper 接口
+ * Mapper 接口
  * </p>
  *
  * @author 吴涛涛
  * @since 2020-01-02
  */
 public interface ScreenshotMapper extends BaseMapper<Screenshot> {
+    List<Map<String, Object>> getLatestScreenshotList();
 
     HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo);
 }

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ScreenshotService.java

@@ -7,13 +7,14 @@ import com.management.platform.util.HttpRespMsg;
 
 /**
  * <p>
- *  服务类
+ * 服务类
  * </p>
  *
  * @author 吴涛涛
  * @since 2020-01-02
  */
 public interface ScreenshotService extends IService<Screenshot> {
+    HttpRespMsg getLatestScreenshotList();
 
     HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo);
 }

+ 8 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ScreenshotServiceImpl.java

@@ -48,6 +48,14 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
     @Resource
     private ScreenshotMapper screenshotMapper;
 
+    //获取所有人最新的截图
+    @Override
+    public HttpRespMsg getLatestScreenshotList() {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        httpRespMsg.data = screenshotMapper.getLatestScreenshotList();
+        return httpRespMsg;
+    }
+
     @Override
     public HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo) {
         String filePath = UploadFileToFileNameUtil.uploadFile(screenshotvo.getFile(), path);

+ 14 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ScreenshotMapper.xml

@@ -20,4 +20,18 @@
         id, uid, pic_url, indate, is_normal, is_handle, date_str, pic_type, pic_context
     </sql>
 
+    <!--获取每个人最新的桌面截图-->
+    <select id="getLatestScreenshotList" resultType="java.util.Map">
+        SELECT c.name, a.pic_url, a.indate
+        FROM screenshot AS a
+        JOIN(
+        SELECT uid, MAX(indate) AS max_indate
+        FROM screenshot
+        GROUP BY uid
+        ) AS b
+        ON a.uid = b.uid AND a.indate = b.max_indate
+        LEFT JOIN USER AS c
+        ON a.uid = c.id
+    </select>
+
 </mapper>