@@ -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,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;
+
- * Mapper 接口
+ * Mapper 接口
* @since 2020-01-02
*/
public interface ScreenshotMapper extends BaseMapper<Screenshot> {
+ List<Map<String, Object>> getLatestScreenshotList();
HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo);
@@ -7,13 +7,14 @@ import com.management.platform.util.HttpRespMsg;
- * 服务类
+ * 服务类
public interface ScreenshotService extends IService<Screenshot> {
+ HttpRespMsg getLatestScreenshotList();
@@ -48,6 +48,14 @@ public class ScreenshotServiceImpl extends ServiceImpl<ScreenshotMapper, Screens
@Resource
private ScreenshotMapper screenshotMapper;
+ //获取所有人最新的截图
+ @Override
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
+ httpRespMsg.data = screenshotMapper.getLatestScreenshotList();
+ return httpRespMsg;
@Override
public HttpRespMsg saveAndProcessImage(ScreenshotVO screenshotvo) {
String filePath = UploadFileToFileNameUtil.uploadFile(screenshotvo.getFile(), path);
@@ -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>