|
@@ -19,6 +19,7 @@ import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
import com.usky.fire.service.vo.CompanyDataVo;
|
|
|
import com.usky.fire.service.vo.DemReportInfoIdVo;
|
|
|
import com.usky.fire.service.vo.DemReportInfoVo;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -34,6 +35,7 @@ import java.util.*;
|
|
|
* @author han
|
|
|
* @since 2023-03-02
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class DemReportInfoServiceImpl extends AbstractCrudService<DemReportInfoMapper, DemReportInfo> implements DemReportInfoService {
|
|
|
|
|
@@ -139,17 +141,48 @@ public class DemReportInfoServiceImpl extends AbstractCrudService<DemReportInfoM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateReadStatus(String companyId) {
|
|
|
- DemReportInfo one = null;
|
|
|
- one = this.getOne(Wrappers.<DemReportInfo>lambdaQuery().eq(DemReportInfo::getId, companyId));
|
|
|
- if (one == null) {
|
|
|
- throw new BusinessException("当前报告已删除!请联系管理员");
|
|
|
+ public void updateReadStatus(String id) {
|
|
|
+ String remark = null;
|
|
|
+ try {
|
|
|
+ remark = SecurityUtils.getLoginUser().getSysUser().getRemark();
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ log.error("获取remake失败", e);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String companyId = null;
|
|
|
+ LambdaQueryWrapper<BaseCompany> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(BaseCompany::getCompanyId)
|
|
|
+ .eq(BaseCompany::getOrganization, remark);
|
|
|
+ BaseCompany baseCompany = baseCompanyMapper.selectOne(queryWrapper);
|
|
|
+ if (baseCompany != null) {
|
|
|
+ companyId = baseCompany.getCompanyId();
|
|
|
+ } else {
|
|
|
+ log.warn("未查询到与组织[{}]匹配的公司信息", remark);
|
|
|
+ return;
|
|
|
}
|
|
|
- Integer isRead = one.getIsRead();
|
|
|
- if (isRead == 0) {
|
|
|
- one.setReadTime(LocalDateTime.now());
|
|
|
- one.setIsRead(1);
|
|
|
- this.updateById(one);
|
|
|
+
|
|
|
+ DemReportInfo report = this.getOne(Wrappers.<DemReportInfo>lambdaQuery()
|
|
|
+ .eq(DemReportInfo::getId, id));
|
|
|
+ if (report == null) {
|
|
|
+ log.warn("报告ID[{}]不存在,无法更新已读状态", id);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String reportCompanyId = report.getCompanyId();
|
|
|
+ if (!Objects.equals(reportCompanyId, companyId)) {
|
|
|
+ log.warn("报告ID[{}]所属公司[{}]与当前用户公司[{}]不匹配,无权限更新",
|
|
|
+ id, reportCompanyId, companyId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (report.getIsRead() == 0) {
|
|
|
+ report.setReadTime(LocalDateTime.now());
|
|
|
+ report.setIsRead(1);
|
|
|
+ this.updateById(report);
|
|
|
+ log.info("报告ID[{}]已更新为已读状态", id);
|
|
|
+ } else {
|
|
|
+ log.info("报告ID[{}]非第一次阅读,无需更新", id);
|
|
|
}
|
|
|
}
|
|
|
}
|