feat:报告查询列表接口
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.adc.da.report.constant;
|
||||
|
||||
/**
|
||||
* @author: CaiHaohan
|
||||
* @Date: 2023/5/9 14:50
|
||||
* @Description: power_apply表power字段对应的权限
|
||||
*/
|
||||
public class PowerApplyConstants {
|
||||
|
||||
/**
|
||||
* 无权限
|
||||
*/
|
||||
public static final Integer NONE = 0;
|
||||
|
||||
/**
|
||||
* 预览权限
|
||||
*/
|
||||
public static final Integer PREVIEW = 1;
|
||||
|
||||
/**
|
||||
* 预览 + 下载
|
||||
*/
|
||||
public static final Integer PREVIEW_DOWNLOAD = 2;
|
||||
|
||||
/**
|
||||
* 下载权限
|
||||
*/
|
||||
public static final Integer DOWNLOAD = 3;
|
||||
}
|
||||
@@ -13,4 +13,16 @@ public class ReportConstants {
|
||||
public static final String FILE_EXTENSIONS_PPTX = "pptx";
|
||||
public static final String FILE_EXTENSIONS_PDF = "pdf";
|
||||
|
||||
/**
|
||||
* 公开报告(内部公开)
|
||||
*/
|
||||
public static final String PUBLIC_REPORT = "公开";
|
||||
|
||||
/**
|
||||
* 不涉及用户隐私
|
||||
*/
|
||||
public static final String NO_USER_PRIVACY_INVOLVED = "不涉及用户隐私";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ public class ReportLogBookController {
|
||||
public ResponseMessage getThumbUpCount(String reportId){
|
||||
|
||||
//根据报告id和当前登录用户id获取点赞数
|
||||
ReportDetailThumbUpVo result = reportLogBookService.getThumbUpCount(reportId);
|
||||
ReportDetailThumbUpVo result = reportLogBookService.thumbUpCount(reportId);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class ReportRatingController {
|
||||
/**
|
||||
* 获取报告评分
|
||||
*/
|
||||
@ApiOperation(value = "给报告评分")
|
||||
@ApiOperation(value = "获取报告评分")
|
||||
@GetMapping("/rating")
|
||||
public ResponseMessage getRating(String reportId) {
|
||||
return reportUserRatingService.getRating(reportId);
|
||||
|
||||
@@ -32,7 +32,7 @@ public interface IReportLogBookService {
|
||||
* @param reportId
|
||||
* @return
|
||||
*/
|
||||
ReportDetailThumbUpVo getThumbUpCount(String reportId);
|
||||
ReportDetailThumbUpVo thumbUpCount(String reportId);
|
||||
|
||||
/**
|
||||
* 点赞或者取消点赞
|
||||
@@ -41,4 +41,34 @@ public interface IReportLogBookService {
|
||||
* @return
|
||||
*/
|
||||
ReportDetailThumbUpVo thumbUpOrDown(String reportId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取点击量
|
||||
* @param reportId
|
||||
* @return
|
||||
*/
|
||||
Integer getClickCount(String reportId);
|
||||
|
||||
/**
|
||||
* 获取下载量
|
||||
* @param reportId
|
||||
* @return
|
||||
*/
|
||||
Integer getDownloadCount(String reportId);
|
||||
|
||||
/**
|
||||
* 获取预览量
|
||||
* @param reportId
|
||||
* @return
|
||||
*/
|
||||
Integer getPreviewCount(String reportId);
|
||||
|
||||
/**
|
||||
* 获取点赞量
|
||||
* @param reportId
|
||||
* @return
|
||||
*/
|
||||
Integer getThumbUpCount(String reportId);
|
||||
|
||||
}
|
||||
|
||||
+23
-4
@@ -113,7 +113,7 @@ public class IReportLogBookServiceImpl extends ServiceImpl<ReportLogBookDao, Rep
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportDetailThumbUpVo getThumbUpCount(String reportId) {
|
||||
public ReportDetailThumbUpVo thumbUpCount(String reportId) {
|
||||
//查找是否有点赞记录
|
||||
ReportLogBook entity = findThumbUpLog(reportId);
|
||||
ReportDetailThumbUpVo reportDetailThumbUpVo = new ReportDetailThumbUpVo();
|
||||
@@ -121,12 +121,31 @@ public class IReportLogBookServiceImpl extends ServiceImpl<ReportLogBookDao, Rep
|
||||
reportDetailThumbUpVo.setLogId(entity.getId());
|
||||
}
|
||||
//计算已有点赞数
|
||||
Integer count = thumbUpCount(reportId);
|
||||
Integer count = getThumbUpCount(reportId);
|
||||
reportDetailThumbUpVo.setThumbUpCount(count);
|
||||
return reportDetailThumbUpVo;
|
||||
}
|
||||
|
||||
private Integer thumbUpCount(String reportId) {
|
||||
@Override
|
||||
public Integer getClickCount(String reportId) {
|
||||
return query().eq("report_id", reportId)
|
||||
.eq("type", 4).count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDownloadCount(String reportId) {
|
||||
return query().eq("report_id", reportId)
|
||||
.eq("type", 2).count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getPreviewCount(String reportId) {
|
||||
return query().eq("report_id", reportId)
|
||||
.eq("type", 1).count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getThumbUpCount(String reportId) {
|
||||
return query().eq("report_id", reportId)
|
||||
.eq("type", 3).count();
|
||||
}
|
||||
@@ -163,7 +182,7 @@ public class IReportLogBookServiceImpl extends ServiceImpl<ReportLogBookDao, Rep
|
||||
thumbDown(entity.getId());
|
||||
}
|
||||
//计算已有点赞数
|
||||
Integer count = thumbUpCount(reportId);
|
||||
Integer count = getThumbUpCount(reportId);
|
||||
reportDetailThumbUpVo.setThumbUpCount(count);
|
||||
return reportDetailThumbUpVo;
|
||||
}
|
||||
|
||||
+149
-17
@@ -46,6 +46,10 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.adc.da.report.constant.PowerApplyConstants.*;
|
||||
import static com.adc.da.report.constant.ReportConstants.NO_USER_PRIVACY_INVOLVED;
|
||||
import static com.adc.da.report.constant.ReportConstants.PUBLIC_REPORT;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
* @Date 2021/11/9 08:37
|
||||
@@ -378,24 +382,83 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
||||
return list;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IPage<ReportVo> page(ReportQueryVo vo) {
|
||||
// IPage<ReportEntity> page = new Page<>();
|
||||
// page.setCurrent(vo.getPageNo());
|
||||
// page.setSize(vo.getPageSize());
|
||||
// //判断是不是管理员
|
||||
// boolean admin = false;
|
||||
// List<RoleEO> roleEOList = roleEODao.selectByuserId(UserUtils.getUserId());
|
||||
// for (RoleEO roleEO : roleEOList) {
|
||||
// if ("管理员".equals(roleEO.getName())){
|
||||
// admin= !admin;
|
||||
// }
|
||||
// }
|
||||
// if (admin) {
|
||||
// vo.setUsid(null);
|
||||
// } else {
|
||||
// vo.setUsid(UserUtils.getUserId());
|
||||
// }
|
||||
//
|
||||
// //按照labelId筛选
|
||||
// Set<String> idSet = new HashSet<>();
|
||||
// if (Objects.nonNull(vo.getLabelId()) && !vo.getLabelId().isEmpty()) {
|
||||
// LambdaQueryWrapper<ReportLabelEntity> reportLabelEntityWrapper = new LambdaQueryWrapper<>();
|
||||
// reportLabelEntityWrapper.in(ReportLabelEntity::getLabelId, vo.getLabelId());
|
||||
// List<ReportLabelEntity> reportLabelEntities = reportLabelDao.selectList(reportLabelEntityWrapper);
|
||||
// reportLabelEntities.forEach(reportLabelEntity -> {
|
||||
// idSet.add(reportLabelEntity.getReportId());
|
||||
// });
|
||||
// idSet.add("1");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// IPage<ReportVo> list = reportDao.page(page, vo,idSet);
|
||||
// //获取所有报告的labelId
|
||||
// list.getRecords().forEach((reportVo) -> {
|
||||
// reportVo.setLabelList(findLabelList(reportVo.getId()));
|
||||
// });
|
||||
// list.getRecords().forEach(c -> {
|
||||
// FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity());
|
||||
// if (StringUtils.isEmpty(fileEntity.getFileType())) {
|
||||
// c.setFileType(null);
|
||||
// }
|
||||
// //ppt文件
|
||||
// else if (ReportConstants.FILE_EXTENSIONS_PPT.equalsIgnoreCase(fileEntity.getFileType()) ||
|
||||
// ReportConstants.FILE_EXTENSIONS_PPTX.equalsIgnoreCase(fileEntity.getFileType())) {
|
||||
// c.setFileType("1");
|
||||
// }
|
||||
// //excel文件
|
||||
// else if (ReportConstants.FILE_EXTENSIONS_XLS.equalsIgnoreCase(fileEntity.getFileType()) ||
|
||||
// ReportConstants.FILE_EXTENSIONS_XLSX.equalsIgnoreCase(fileEntity.getFileType())) {
|
||||
// c.setFileType("2");
|
||||
// }
|
||||
// //pdf文件
|
||||
// else if (ReportConstants.FILE_EXTENSIONS_PDF.equalsIgnoreCase(fileEntity.getFileType())) {
|
||||
// c.setFileType("3");
|
||||
// }
|
||||
// //word文件
|
||||
// else {
|
||||
// c.setFileType("4");
|
||||
// }
|
||||
//
|
||||
// //文件大小
|
||||
// c.setFileSize(StringUtils.isNotEmpty(fileEntity.getFileSize())
|
||||
// ? String.valueOf(Integer.parseInt(fileEntity.getFileSize()) / 1024) + "kb" : "0kb");
|
||||
// c.setFileName(fileEntity.getFileName());
|
||||
// List<String> userIdList = reportUserDao.selectList(
|
||||
// new QueryWrapper<ReportUserEntity>().eq("reportId", c.getId()))
|
||||
// .stream().map(ReportUserEntity::getUserId).collect(Collectors.toList());
|
||||
// });
|
||||
// return list;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public IPage<ReportVo> page(ReportQueryVo vo) {
|
||||
IPage<ReportEntity> page = new Page<>();
|
||||
page.setCurrent(vo.getPageNo());
|
||||
page.setSize(vo.getPageSize());
|
||||
//判断是不是管理员
|
||||
boolean admin = false;
|
||||
List<RoleEO> roleEOList = roleEODao.selectByuserId(UserUtils.getUserId());
|
||||
for (RoleEO roleEO : roleEOList) {
|
||||
if ("管理员".equals(roleEO.getName())){
|
||||
admin= !admin;
|
||||
}
|
||||
}
|
||||
if (admin) {
|
||||
vo.setUsid(null);
|
||||
} else {
|
||||
vo.setUsid(UserUtils.getUserId());
|
||||
}
|
||||
|
||||
//按照labelId筛选
|
||||
Set<String> idSet = new HashSet<>();
|
||||
@@ -409,12 +472,81 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
||||
idSet.add("1");
|
||||
}
|
||||
|
||||
|
||||
IPage<ReportVo> list = reportDao.page(page, vo,idSet);
|
||||
//获取所有报告的labelId
|
||||
list.getRecords().forEach((reportVo) -> {
|
||||
reportVo.setLabelList(findLabelList(reportVo.getId()));
|
||||
|
||||
//查询下载量
|
||||
list.getRecords().forEach(c -> {
|
||||
Integer downloadCount = reportLogBookService.getDownloadCount(c.getId());
|
||||
c.setDownload(downloadCount);
|
||||
});
|
||||
//查询点击量
|
||||
list.getRecords().forEach(c -> {
|
||||
Integer clickCount = reportLogBookService.getClickCount(c.getId());
|
||||
c.setClicks(clickCount);
|
||||
});
|
||||
//查询点赞量
|
||||
list.getRecords().forEach(c -> {
|
||||
Integer thumbUpCount = reportLogBookService.getThumbUpCount(c.getId());
|
||||
c.setThumbUp(thumbUpCount);
|
||||
});
|
||||
//查询报告评级
|
||||
list.getRecords().forEach(c -> {
|
||||
Double ratingAvg = reportUserRatingService.getRatingAvg(c.getId());
|
||||
c.setRating(ratingAvg);
|
||||
});
|
||||
//按查询条件排序
|
||||
//按时间排序
|
||||
if (vo.getOrderByTime() != null) {
|
||||
if (vo.getOrderByTime().equals(0)) {
|
||||
list.getRecords().sort(Comparator.comparing(ReportVo::getCreateDate).reversed());
|
||||
}
|
||||
if (vo.getOrderByTime().equals(1)) {
|
||||
list.getRecords().sort(Comparator.comparing(ReportVo::getCreateDate));
|
||||
}
|
||||
}
|
||||
|
||||
//按点击量排序
|
||||
if (vo.getOrderByClicks() != null) {
|
||||
if (vo.getOrderByClicks().equals(0)) {
|
||||
list.getRecords().sort(Comparator.comparing(ReportVo::getClicks).reversed());
|
||||
}
|
||||
if (vo.getOrderByClicks().equals(1)) {
|
||||
list.getRecords().sort(Comparator.comparing(ReportVo::getClicks));
|
||||
}
|
||||
}
|
||||
|
||||
//按下载量排序
|
||||
if (vo.getOrderByDownload() != null) {
|
||||
if (vo.getOrderByDownload().equals(0)) {
|
||||
list.getRecords().sort(Comparator.comparing(ReportVo::getDownload).reversed());
|
||||
}
|
||||
if (vo.getOrderByDownload().equals(1)) {
|
||||
list.getRecords().sort(Comparator.comparing(ReportVo::getDownload));
|
||||
}
|
||||
}
|
||||
|
||||
//设置权限
|
||||
UserEO userEo = userEODao.selectById(UserUtils.getUserId());
|
||||
String levelId = userEo.getLevelId() == null ? "1.0" : userEo.getLevelId();
|
||||
//用户级别
|
||||
double level = Double.parseDouble(levelId);
|
||||
//总监拥有全部报告的预览和下载权力
|
||||
if (level <= 0.5) {
|
||||
list.getRecords().forEach(reportVo -> {
|
||||
reportVo.setPower(PREVIEW_DOWNLOAD);
|
||||
});
|
||||
} else {
|
||||
list.getRecords().forEach(reportVo -> {
|
||||
//其余人员只能预览公开报告(涉密等级:公开(内部公开)、隐私等级:不涉及用户隐私)
|
||||
if (reportVo.getConfidentialLevel().equals(PUBLIC_REPORT) &&
|
||||
reportVo.getPrivacyLevel().equals(NO_USER_PRIVACY_INVOLVED)) {
|
||||
reportVo.setPower(PREVIEW);
|
||||
} else {
|
||||
reportVo.setPower(NONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
list.getRecords().forEach(c -> {
|
||||
FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity());
|
||||
if (StringUtils.isEmpty(fileEntity.getFileType())) {
|
||||
|
||||
+4
@@ -62,8 +62,12 @@ public class IReportUserRatingServiceImpl extends ServiceImpl<ReportUserRatingDa
|
||||
@Override
|
||||
public Double getRatingAvg(String reportId) {
|
||||
QueryWrapper<ReportUserRatingEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("report_id", reportId);
|
||||
wrapper.select("AVG(user_rating) as user_rating");
|
||||
List<Map<String, Object>> result = reportUserRatingDao.selectMaps(wrapper);
|
||||
if (result.get(0) == null) {
|
||||
return 0.0;
|
||||
}
|
||||
BigDecimal userRating = (BigDecimal) result.get(0).get("user_rating");
|
||||
return userRating.doubleValue();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.adc.da.report.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -95,4 +92,9 @@ public class ReportDetailVo {
|
||||
* 下载权限(0没有1有)
|
||||
*/
|
||||
private Integer downPower;
|
||||
|
||||
/**
|
||||
* 用户权限级别
|
||||
*/
|
||||
private Double levelId;
|
||||
}
|
||||
|
||||
@@ -21,31 +21,47 @@ public class ReportQueryVo {
|
||||
*/
|
||||
private int pageSize;
|
||||
|
||||
/**
|
||||
* 报告名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 全文模糊检索的关键词
|
||||
*/
|
||||
private String keyContent;
|
||||
|
||||
/**
|
||||
* 标签集合
|
||||
*/
|
||||
private List<String> labelId;
|
||||
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
private List<String> year;
|
||||
|
||||
/**
|
||||
* 报告名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 标签集合
|
||||
*/
|
||||
private List<String> labelId;
|
||||
|
||||
/**
|
||||
* 按时间排序(0代表最新发布的排名最前 1相反)
|
||||
*/
|
||||
private Integer orderByTime;
|
||||
|
||||
/**
|
||||
* 按点击量排序(0代表点击量最多的报告排序在最前 1相反)
|
||||
*/
|
||||
private Integer orderByClicks;
|
||||
|
||||
/**
|
||||
* 按下载量排序(0代表下载量最多的报告排名最前 1相反)
|
||||
*/
|
||||
private Integer orderByDownload;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String usid;
|
||||
|
||||
|
||||
private List<String> ids;
|
||||
|
||||
//
|
||||
|
||||
@@ -30,6 +30,7 @@ public class ReportVo {
|
||||
* 权限
|
||||
*/
|
||||
private Integer power;
|
||||
|
||||
/**
|
||||
* 主要内容
|
||||
*/
|
||||
@@ -94,4 +95,30 @@ public class ReportVo {
|
||||
* 文件大小
|
||||
*/
|
||||
private String fileSize;
|
||||
|
||||
/**
|
||||
* 报告评级
|
||||
*/
|
||||
private Integer reportRating;
|
||||
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
private Integer thumbUp;
|
||||
|
||||
/**
|
||||
* 点击量
|
||||
*/
|
||||
private Integer clicks;
|
||||
|
||||
/**
|
||||
* 下载量
|
||||
*/
|
||||
private Integer download;
|
||||
|
||||
/**
|
||||
* 报告评级
|
||||
*/
|
||||
private Double rating;
|
||||
|
||||
}
|
||||
|
||||
@@ -103,22 +103,21 @@
|
||||
eo.fileid,
|
||||
eo.confidentialLevel,
|
||||
eo.privacyLevel,
|
||||
eo.createUserId,
|
||||
tu.USNAME,
|
||||
eo.createDate,
|
||||
pa.report_id,
|
||||
pa.user_id,
|
||||
pa.power
|
||||
FROM
|
||||
TT_REPORT_MANAGE eo
|
||||
INNER JOIN ts_report_label AS trl ON eo.id = trl.report_id
|
||||
LEFT JOIN ts_user tu ON tu.USID = eo.createUserId
|
||||
LEFT JOIN tr_report_user ru ON eo.id = ru.reportId
|
||||
LEFT JOIN power_apply pa ON pa.report_id = eo.id
|
||||
WHERE
|
||||
eo.DEL_FLAG = 0
|
||||
<if test="pageVO.usid !='' and pageVO.usid != null">
|
||||
and (ru.userId = #{pageVO.usid}
|
||||
or eo.id in (
|
||||
SELECT tt.report_id from power_apply tt WHERE tt.user_id = #{pageVO.usid})
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="pageVO.name !='' and pageVO.name != null">
|
||||
and name like CONCAT(CONCAT('%',#{pageVO.name}),'%')
|
||||
</if>
|
||||
@@ -243,7 +242,7 @@
|
||||
rm.confidentialLevel AS confidentialLevel,
|
||||
rm.privacyLevel AS privacyLevel
|
||||
FROM `tt_report_manage` AS rm
|
||||
INNER JOIN ts_user AS u ON u.USID = rm.createUserId
|
||||
LEFT JOIN ts_user AS u ON u.USID = rm.createUserId
|
||||
WHERE rm.id = #{reportId}
|
||||
AND rm.del_flag = 0
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user