瀏覽代碼

消防报告添加已读状态与已读时间

fuyuchuan 9 小時之前
父節點
當前提交
a34437d7ec

+ 14 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/DemReportInfoController.java

@@ -45,7 +45,7 @@ public class DemReportInfoController {
                                                                @RequestParam(value = "sourceType", required = false) String sourceType,
                                                                @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                                                @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
-        return ApiResult.success(demReportInfoService.reportInfoList(companyId,sourceType,pageNum, pageSize));
+        return ApiResult.success(demReportInfoService.reportInfoList(companyId, sourceType, pageNum, pageSize));
     }
 
     /**
@@ -82,5 +82,18 @@ public class DemReportInfoController {
     public ApiResult<List<DemReportInfo>> reportById(@RequestParam(value = "id", required = false) Integer id) {
         return ApiResult.success(demReportInfoService.reportById(id));
     }
+
+    /**
+     * 报告读取状态更新
+     *
+     * @param companyId  单位ID
+     * @return
+     */
+    @Log(title = "报告读取状态更新", businessType = BusinessType.UPDATE)
+    @PutMapping("updateReadStatus")
+    public ApiResult<Void> updateReadStatus(@RequestParam(value = "companyId") String companyId) {
+        demReportInfoService.updateReadStatus(companyId);
+        return ApiResult.success();
+    }
 }
 

+ 10 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/DemReportInfo.java

@@ -77,5 +77,15 @@ public class DemReportInfo implements Serializable {
      */
     private LocalDateTime sendTime;
 
+    /**
+     * 是否已读
+     */
+    private Integer isRead;
+
+    /**
+     * 读取时间
+     */
+    private LocalDateTime readTime;
+
 
 }

+ 6 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/DemReportInfoService.java

@@ -51,4 +51,10 @@ public interface DemReportInfoService extends CrudService<DemReportInfo> {
      * @return
      */
     List<DemReportInfo> reportById(Integer id);
+
+    /**
+     * 批量更新已读状态
+     * @param companyId 单位ID
+     */
+    void updateReadStatus(String companyId);
 }

+ 17 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/DemReportInfoServiceImpl.java

@@ -1,6 +1,7 @@
 package com.usky.fire.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -136,4 +137,20 @@ public class DemReportInfoServiceImpl extends AbstractCrudService<DemReportInfoM
         List<DemReportInfo> list2 = this.list(queryWrapper1);
         return list2;
     }
+
+    @Override
+    public void updateReadStatus(String companyId) {
+        LambdaQueryWrapper<DemReportInfo> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(DemReportInfo::getCompanyId, companyId);
+        DemReportInfo one = this.getOne(queryWrapper);
+        if (one == null) {
+            throw new BusinessException("当前报告已删除!请联系管理员");
+        }
+        Integer isRead = one.getIsRead();
+        if (isRead == 0) {
+            one.setReadTime(LocalDateTime.now());
+            one.setIsRead(1);
+            this.updateById(one);
+        }
+    }
 }