feat: 报表上传-权限设定需求

调整了报告上传接口,报告权限由原来的预览下载统一权限,调整为两个权限,预览功能和预览下载功能
This commit is contained in:
2023-05-04 16:50:07 +08:00
parent 246d688d4a
commit bd4d553030
7 changed files with 118 additions and 32 deletions
@@ -93,7 +93,9 @@ public class ReportManageConroller {
if (count>0){
return Result.error("报告名称已存在");
}
String name = reportService.insert(entity, vo.getLabelList());
String name = reportService.insert(entity, vo.getLabelList(),
vo.getReportPreviewUserIdList(),
vo.getReportPreviewAndDownloadUserIdList());
map.put("reportName", name);
return Result.success(map);
}
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
@@ -16,6 +17,7 @@ import java.util.Date;
*/
@Data
@TableName("power_apply")
@Accessors(chain = true)
public class PowerApply {
/**
@@ -85,4 +87,11 @@ public class PowerApply {
*/
@TableField("del_flag")
private Integer delFlag;
/**
* 权限来源 1 上传报告时添加的
* 2 单独申请的权限
*/
@TableField("power_source")
private Integer powerSource;
}
@@ -5,10 +5,11 @@ import com.adc.da.report.eo.PowerApplyAct;
import com.adc.da.report.vo.DeleteParamRequestVO;
import com.adc.da.report.vo.PowerApplyPageVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
public interface IPowerApplyService {
public interface IPowerApplyService extends IService<PowerApply> {
/**
* @param powerApplyPageVO
@@ -58,4 +59,11 @@ public interface IPowerApplyService {
public void deleteById(DeleteParamRequestVO deleteParamVO);
void saveBatch(List<PowerApplyAct> powerApplyActs);
/**
* 根据报告id删除权限
*
* @param reportId 报表id
*/
void deleteByReportId(String reportId);
}
@@ -21,7 +21,9 @@ public interface IReportService {
* @param labelList
* @return 报告名称
*/
String insert(ReportEntity entity, List<String> labelList) throws IOException;
String insert(ReportEntity entity, List<String> labelList,
List<String> reportPreviewUserIdList,
List<String> reportPreviewAndDownloadUserIdList) throws IOException;
/**
* 删除报告
@@ -7,24 +7,20 @@ import com.adc.da.report.dao.mysql.FileDao;
import com.adc.da.report.dao.mysql.ReportDao;
import com.adc.da.report.dao.mysql.ReportLabelDao;
import com.adc.da.report.dao.mysql.ReportUserDao;
import com.adc.da.report.eo.FileEntity;
import com.adc.da.report.eo.ReportEntity;
import com.adc.da.report.eo.ReportLabelEntity;
import com.adc.da.report.eo.ReportUserEntity;
import com.adc.da.report.service.IReportContentService;
import com.adc.da.report.service.IReportLabelService;
import com.adc.da.report.service.IReportService;
import com.adc.da.report.service.ITreeLabelService;
import com.adc.da.report.eo.*;
import com.adc.da.report.service.*;
import com.adc.da.report.util.*;
import com.adc.da.report.vo.ReportQueryVo;
import com.adc.da.report.vo.ReportVo;
import com.adc.da.sys.dao.mysql.RoleEODao;
import com.adc.da.sys.entity.RoleEO;
import com.adc.da.util.utils.CollectionUtils;
import com.adc.da.util.utils.FileUtil;
import com.adc.da.util.utils.StringUtils;
import com.adc.da.util.utils.UUID;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -98,6 +94,10 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
@Autowired
private LocalFileUtil localFileUtil;
@Resource
private IPowerApplyService iPowerApplyService;
/**
* 新增或编辑报告
*
@@ -107,9 +107,12 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String insert(ReportEntity entity, List<String> labelList) throws IOException {
public String insert(ReportEntity entity, List<String> labelList,
List<String> reportPreviewUserIdList,
List<String> reportPreviewAndDownloadUserIdList) throws IOException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (StringUtils.isEmpty(entity.getId())) {
entity.setId(UUID.randomUUID10());
entity.setCreateDate(format.format(new Date()));
@@ -118,13 +121,36 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
entity.setUpdateDate(format.format(new Date()));
reportDao.insert(entity);
//插入用户关系
entity.getReportUserIdList().forEach(c -> {
ReportUserEntity reportUserEntity = new ReportUserEntity();
reportUserEntity.setReportId(entity.getId());
reportUserEntity.setUserId(c);
reportUserDao.insert(reportUserEntity);
});
//插入power_apply权限
if (CollectionUtils.isNotEmpty(reportPreviewUserIdList)) {
reportPreviewUserIdList.forEach(userId -> {
PowerApply powerApply = new PowerApply();
powerApply.setId(UUID.randomUUID10())
.setPower(1)
.setReportId(entity.getId())
.setUserId(userId)
.setCreateDate(new Date())
.setCreateUserId(UserUtils.getUserId())
.setDelFlag(0)
.setPowerSource(1);
iPowerApplyService.save(powerApply);
});
}
if (CollectionUtils.isNotEmpty(reportPreviewAndDownloadUserIdList)) {
reportPreviewAndDownloadUserIdList.forEach(userId -> {
PowerApply powerApply = new PowerApply();
powerApply.setId(UUID.randomUUID10())
.setPower(2)
.setReportId(entity.getId())
.setUserId(userId)
.setCreateDate(new Date())
.setCreateUserId(UserUtils.getUserId())
.setDelFlag(0)
.setPowerSource(1);
iPowerApplyService.save(powerApply);
});
}
//插入报表标签关系表
labelList.forEach((label) -> {
@@ -133,7 +159,7 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
});
//插入报表内容表
iReportContentService.insertReportContent(entity.getId() ,entity.getFileId());
iReportContentService.insertReportContent(entity.getId(), entity.getFileId());
CommonUtils.threadPoolExecutor().execute(() -> {
//生成html
@@ -157,14 +183,6 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
reportUserDao.delete(new QueryWrapper<ReportUserEntity>()
.eq("reportId", entity.getId()));
//插入用户关系表
entity.getReportUserIdList().forEach(c -> {
ReportUserEntity reportUserEntity = new ReportUserEntity();
reportUserEntity.setReportId(entity.getId());
reportUserEntity.setUserId(c);
reportUserDao.insert(reportUserEntity);
});
//修改报表标签关系表(先删后增)
iReportLabelService.deleteReportLabelByReportId(new String[]{entity.getId()});
@@ -174,6 +192,42 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
reportLabelDao.insert(reportLabelEntity);
});
//TODO 插入报表内容表(先删后增)
//删除power_apply表中的对应权限
iPowerApplyService.deleteByReportId(entity.getId());
//插入power_apply权限表
if (CollectionUtils.isNotEmpty(reportPreviewUserIdList)) {
reportPreviewUserIdList.forEach(userId -> {
PowerApply powerApply = new PowerApply();
powerApply.setId(UUID.randomUUID10())
.setPower(1)
.setReportId(entity.getId())
.setUserId(userId)
.setUpdateDate(new Date())
.setUpdateUserId(UserUtils.getUserId())
.setDelFlag(0)
.setPowerSource(1);
iPowerApplyService.save(powerApply);
});
}
if (CollectionUtils.isNotEmpty(reportPreviewAndDownloadUserIdList)) {
reportPreviewAndDownloadUserIdList.forEach(userId -> {
PowerApply powerApply = new PowerApply();
powerApply.setId(UUID.randomUUID10())
.setPower(2)
.setReportId(entity.getId())
.setUserId(userId)
.setUpdateDate(new Date())
.setUpdateUserId(UserUtils.getUserId())
.setDelFlag(0)
.setPowerSource(1);
iPowerApplyService.save(powerApply);
});
}
CommonUtils.threadPoolExecutor().execute(() -> {
String key = entity.getId() + "-" + entity.getFileId();
Boolean hasKey = stringRedisTemplate.hasKey(key);
@@ -375,7 +429,6 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
List<String> userIdList = reportUserDao.selectList(
new QueryWrapper<ReportUserEntity>().eq("reportId", c.getId()))
.stream().map(ReportUserEntity::getUserId).collect(Collectors.toList());
c.setReportUserIdList(userIdList);
});
return list;
}
@@ -448,7 +501,6 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
List<String> userIdList = reportUserDao.selectList(
new QueryWrapper<ReportUserEntity>().eq("reportId", c.getId()))
.stream().map(ReportUserEntity::getUserId).collect(Collectors.toList());
c.setReportUserIdList(userIdList);
});
return list;
}
@@ -10,6 +10,7 @@ import com.adc.da.report.vo.DeleteParamRequestVO;
import com.adc.da.report.vo.PowerApplyPageVO;
import com.adc.da.util.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
@@ -124,5 +125,12 @@ public class IpowerApplyServiceImpl extends ServiceImpl<PowerApplyDao, PowerAppl
powerApplyActDao.batchDel(ids);
}
@Override
public void deleteByReportId(String reportId){
UpdateWrapper<PowerApply> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("report_id", reportId);
PowerApply updatePowerApply = new PowerApply();
updatePowerApply.setDelFlag(1);
getBaseMapper().update(updatePowerApply, updateWrapper);
}
}
@@ -68,7 +68,12 @@ public class ReportVo {
/**
* 报告用户id
*/
private List<String> reportUserIdList;
private List<String> reportPreviewUserIdList;
/**
* 报告用户id
*/
private List<String> reportPreviewAndDownloadUserIdList;
/**
* 报告涉密等级