feat:我的收藏页面

This commit is contained in:
2023-05-29 10:41:22 +08:00
parent daa0000e75
commit abdda27b12
9 changed files with 329 additions and 33 deletions
@@ -133,7 +133,7 @@ public class ReportLogBookController {
* @return com.adc.da.util.http.ResponseMessage
* @author bu
* @date 2023-05-08
* @description 根据报告id和当前登录用户id获取点赞
* @description 根据报告id和当前登录用户id点赞或取消点赞
*/
@GetMapping("/thumbUpOrDown")
@ApiOperation(value = "点赞或者取消点赞")
@@ -144,4 +144,20 @@ public class ReportLogBookController {
return Result.success(result);
}
/**
* @param reportId
* @return com.adc.da.util.http.ResponseMessage
* @author bu
* @date 2023-05-08
* @description 根据报告id和当前登录用户id点赞或取消点赞
*/
@GetMapping("/collectOrCancelCollect")
@ApiOperation(value = "收藏或取消收藏")
public ResponseMessage collectOrCancelCollect(String reportId){
//根据报告id和当前登录用户id获取点赞数
return reportLogBookService.collectOrCancelCollect(reportId);
}
}
@@ -202,6 +202,18 @@ public class ReportManageConroller {
return reportService.changeUploader(changeUploaderVo);
}
/**
* 报告管理列表
* @param vo
* @return
* @throws Exception
*/
@ApiOperation("报告管理列表")
@PostMapping("/myCollectPage")
public ResponseMessage myCollectPage(@RequestBody ReportQueryVo vo) throws Exception {
IPage<ReportVo> list = reportService.myCollectPage(vo);
return Result.success(list);
}
/**
@@ -48,6 +48,8 @@ public interface ReportDao extends BaseMapper<ReportEntity> {
*/
IPage<ReportVo> page(IPage<ReportEntity> page, @Param("pageVO") ReportQueryVo vo, @Param("idSet") Set<String> idSet);
IPage<ReportVo> myCollectPage(IPage<ReportEntity> page, @Param("pageVO") ReportQueryVo vo, @Param("idSet") Set<String> idSet, @Param("collectReportIds") List<String> collectReportIds);
/**
* 报告列表
*
@@ -4,6 +4,7 @@ import com.adc.da.report.eo.ReportLogBook;
import com.adc.da.report.vo.DeleteParamRequestVO;
import com.adc.da.report.vo.ReportDetailThumbUpVo;
import com.adc.da.report.vo.ReportLogPageVO;
import com.adc.da.util.http.ResponseMessage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
@@ -64,6 +65,13 @@ public interface IReportLogBookService {
*/
Integer getPreviewCount(String reportId);
/**
* 获取收藏量
* @param reportId
* @return
*/
Integer getCollectCount(String reportId);
/**
* 获取点赞量
* @param reportId
@@ -71,4 +79,17 @@ public interface IReportLogBookService {
*/
Integer getThumbUpCount(String reportId);
/**
* 收藏或取消收藏
* @param reportId
* @return
*/
ResponseMessage collectOrCancelCollect(String reportId);
/**
* 根据用户id获取所有报告id
* @param userId
* @return
*/
List<String> getCollectReportIdByUser(String userId);
}
@@ -51,8 +51,25 @@ public interface IReportService {
IPage<ReportVo> addReportPage(ReportQueryVo vo) throws Exception;
/**
* 报告查询页面列表接口
* @param vo
* @return
*/
IPage<ReportVo> page(ReportQueryVo vo);
/**
* 我的收藏页面列表接口
* @param vo
* @return
*/
IPage<ReportVo> myCollectPage(ReportQueryVo vo);
/**
* 报告管理页面列表接口
* @param vo
* @return
*/
IPage<ReportVo> reportManagerPage(ReportQueryVo vo);
List<String> isAct(ReportQueryVo vo);
@@ -102,4 +119,10 @@ public interface IReportService {
void delFile(ReportFile reportFile);
IPage<ReportFile> filePage(ReportFilePageVO ReportFilePageVO);
/**
* 刷新报告内容
* @return
*/
ResponseMessage refreshReportContent();
}
@@ -8,6 +8,8 @@ import com.adc.da.report.service.IReportLogBookService;
import com.adc.da.report.vo.DeleteParamRequestVO;
import com.adc.da.report.vo.ReportDetailThumbUpVo;
import com.adc.da.report.vo.ReportLogPageVO;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.adc.da.util.utils.StringUtils;
import com.adc.da.util.utils.UUID;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -20,6 +22,7 @@ import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author bu
@@ -145,18 +148,35 @@ public class IReportLogBookServiceImpl extends ServiceImpl<ReportLogBookDao, Rep
.eq("type", 1).count();
}
@Override
public Integer getCollectCount(String reportId) {
return query().eq("report_id", reportId)
.eq("type", 4).count();
}
@Override
public Integer getThumbUpCount(String reportId) {
return query().eq("report_id", reportId)
.eq("type", 3).count();
}
private ReportLogBook findCollectLog(String reportId) {
return query().eq("report_id", reportId)
.eq("user_id", UserUtils.getUserId())
.eq("type", 4).one();
}
private ReportLogBook findThumbUpLog(String reportId) {
return query().eq("report_id", reportId)
.eq("user_id", UserUtils.getUserId())
.eq("type", 3).one();
}
/**
* 点赞
* @param reportId
* @return
*/
private String thumbUp(String reportId) {
ReportLogBook reportLogBook = new ReportLogBook();
reportLogBook.setReportId(reportId)
@@ -168,6 +188,10 @@ public class IReportLogBookServiceImpl extends ServiceImpl<ReportLogBookDao, Rep
return reportLogBook.getId();
}
/**
* 取消点赞
* @param reportId
*/
private void thumbDown(String reportId) {
LambdaQueryWrapper<ReportLogBook> reportLogBookLambdaQueryWrapper = new LambdaQueryWrapper<>();
reportLogBookLambdaQueryWrapper.eq(ReportLogBook::getReportId, reportId);
@@ -176,6 +200,34 @@ public class IReportLogBookServiceImpl extends ServiceImpl<ReportLogBookDao, Rep
remove(reportLogBookLambdaQueryWrapper);
}
/**
* 收藏
* @param reportId
* @return
*/
private String collect(String reportId) {
ReportLogBook reportLogBook = new ReportLogBook();
reportLogBook.setReportId(reportId)
.setId(UUID.randomUUID10())
.setType(4)
.setUserId(UserUtils.getUserId())
.setUpdateTime(new Date());
save(reportLogBook);
return reportLogBook.getId();
}
/**
* 取消收藏
* @param reportId
*/
private void cancelCollect(String reportId) {
LambdaQueryWrapper<ReportLogBook> reportLogBookLambdaQueryWrapper = new LambdaQueryWrapper<>();
reportLogBookLambdaQueryWrapper.eq(ReportLogBook::getReportId, reportId);
reportLogBookLambdaQueryWrapper.eq(ReportLogBook::getType, 4);
reportLogBookLambdaQueryWrapper.eq(ReportLogBook::getUserId, UserUtils.getUserId());
remove(reportLogBookLambdaQueryWrapper);
}
@Override
public ReportDetailThumbUpVo thumbUpOrDown(String reportId) {
ReportLogBook entity = findThumbUpLog(reportId);
@@ -191,4 +243,24 @@ public class IReportLogBookServiceImpl extends ServiceImpl<ReportLogBookDao, Rep
reportDetailThumbUpVo.setThumbUpCount(count);
return reportDetailThumbUpVo;
}
@Override
public ResponseMessage collectOrCancelCollect(String reportId) {
ReportLogBook entity = findCollectLog(reportId);
if (entity == null) {
collect(reportId);
} else {
cancelCollect(reportId);
}
return Result.success("操作成功");
}
@Override
public List<String> getCollectReportIdByUser(String userId) {
LambdaQueryWrapper<ReportLogBook> collectWrapper = new LambdaQueryWrapper<>();
collectWrapper.eq(ReportLogBook::getType, 4);
collectWrapper.eq(ReportLogBook::getUserId, userId);
List<String> list = list(collectWrapper).stream().map(ReportLogBook::getReportId).collect(Collectors.toList());
return list;
}
}
@@ -560,39 +560,93 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
}
});
}
return list;
}
// 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());
// });
@Override
public IPage<ReportVo> myCollectPage(ReportQueryVo vo) {
IPage<ReportEntity> page = new Page<>();
page.setCurrent(vo.getPageNo());
page.setSize(vo.getPageSize());
//按照labelId筛选
Set<String> idSet = new HashSet<>();
if (CollectionUtils.isNotEmpty(vo.getLabelId())) {
LambdaQueryWrapper<ReportLabelEntity> reportLabelEntityWrapper = new LambdaQueryWrapper<>();
reportLabelEntityWrapper.in(ReportLabelEntity::getLastLabel, vo.getLabelId());
List<ReportLabelEntity> reportLabelEntities = reportLabelDao.selectList(reportLabelEntityWrapper);
reportLabelEntities.forEach(reportLabelEntity -> {
idSet.add(reportLabelEntity.getReportId());
});
if (CollectionUtils.isEmpty(idSet)) {
idSet.add("默认搜索条件");
}
}
//找到当前用户收藏的reportId
List<String> collectReportIds = reportLogBookService.getCollectReportIdByUser(UserUtils.getUserId());
if (CollectionUtils.isEmpty(collectReportIds)) {
collectReportIds.add("默认搜索条件");
}
vo.setUsid(UserUtils.getUserId());
IPage<ReportVo> list = reportDao.myCollectPage(page, vo, idSet, collectReportIds);
//设置权限
UserEO userEo = userEODao.selectById(UserUtils.getUserId());
String levelId = StringUtils.isEmpty(userEo.getLevelId()) ? "0.8" : userEo.getLevelId();
String employeeTypeId = StringUtils.isEmpty(userEo.getEmployeeTypeId()) ? "0.8" : userEo.getEmployeeTypeId();
//用户级别
double level = Double.parseDouble(levelId);
double employeeType = Double.parseDouble(employeeTypeId);
//总监拥有全部报告的预览和下载权力
if ((level == SPECIAL_LEVEL_ONE || level == SPECIAL_LEVEL_TWO ||
level == SPECIAL_LEVEL_THREE || level == SPECIAL_LEVEL_FOUL) &&
(employeeType == EMPLOYEE_TYPE_ID_ONE)) {
list.getRecords().forEach(reportVo -> {
reportVo.setPower(PREVIEW_DOWNLOAD);
});
} else {
//其余员工
//用户自己申请的权限
List<Integer> powerList = new ArrayList<>();
powerList.add(PREVIEW_DOWNLOAD);
powerList.add(PREVIEW);
powerList.add(DOWNLOAD);
LambdaQueryWrapper<PowerApply> wrapper = new LambdaQueryWrapper<>();
wrapper.in(CollectionUtils.isNotEmpty(list.getRecords()) ,PowerApply::getReportId, list.getRecords().stream().map(ReportVo::getId).collect(Collectors.toList()));
wrapper.in(PowerApply::getPower, powerList);
wrapper.eq(PowerApply::getUserId, UserUtils.getUserId());
wrapper.eq(PowerApply::getDelFlag, 0);
List<PowerApply> powerApplyList = iPowerApplyService.list(wrapper).stream().distinct().collect(Collectors.toList());
Map<String, List<PowerApply>> reportPowerMap = powerApplyList.stream()
.collect(Collectors.groupingBy(PowerApply::getReportId));
//设置权限
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<PowerApply> powerApplies = reportPowerMap.get(reportVo.getId());
if (powerApplies != null) {
//只有当PA表只有一条申请的权限且并不是公开表的时候才给权限
if (powerApplies.size() == 1 && reportVo.getPower().equals(NONE)) {
reportVo.setPower(powerApplies.get(0).getPower());
} else {
reportVo.setPower(PREVIEW_DOWNLOAD);
}
}
//如果上传人是自己也有预览下载权限
if (UserUtils.getUserId().equals(reportVo.getCreateUserId())) {
reportVo.setPower(PREVIEW_DOWNLOAD);
}
});
}
return list;
}
@@ -108,6 +108,11 @@ public class ReportVo {
*/
private Integer download;
/**
* 受否收藏
*/
private Integer collect;
/**
* 创建人id
*/
@@ -40,6 +40,7 @@
<result column="thumbUp" property="thumbUp" />
<result column="clicks" property="clicks" />
<result column="download" property="download" />
<result column="collect" property="collect" />
<result column="reportRating" property="reportRating" />
<result column="isAct" property="isAct" />
<collection property="fileList" ofType="com.adc.da.report.eo.ReportFile">
@@ -154,6 +155,7 @@
clicksCount.clicks AS clicks,
downloadCount.download AS download,
AVG( trur.user_rating ) AS reportRating,
IF(rlb.type = 4, 1, 0) AS collect,
IF(bpn.id is null,1,
IF(bpn.SUBMIT_STATUS = 1 and bpn.CREAT_USER = #{pageVO.usid} ,0,1)
) as isAct
@@ -170,6 +172,88 @@
LEFT JOIN bus_process_name as bpn on bpn.data_id = eo.id and bpn.prc_type != '5'
LEFT JOIN ts_report_file rf on rf.report_id = eo.id and rf.state = 2
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
LEFT JOIN report_log_book AS rlb ON rlb.user_id = #{pageVO.usid} AND rlb.report_id = eo.id AND rlb.type = 4
WHERE
eo.DEL_FLAG = 0
<!--全文模糊搜索-->
<if test="pageVO.keyContent !='' and pageVO.keyContent != null">
and rc.report_content like CONCAT(CONCAT('%',#{pageVO.keyContent}),'%')
</if>
<if test="pageVO.name !='' and pageVO.name != null">
and name like CONCAT(CONCAT('%',#{pageVO.name}),'%')
</if>
<!--年份搜索-->
<if test="pageVO.year != null and pageVO.year.size() > 0">
and year in
<foreach collection="pageVO.year" item="year" open="(" separator="," close=")">
#{year}
</foreach>
</if>
<if test="pageVO.ids != null and pageVO.ids.size() > 0">
and eo.id in
<foreach collection="pageVO.ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<!--id搜索-->
<if test="idSet !=null and idSet.size() > 0">
and eo.id in
<foreach collection="idSet" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
GROUP BY
eo.id
<if test="pageVO.orderByTime == 1">
ORDER BY
eo.createDate DESC
</if>
<if test="pageVO.orderByClicks == 1">
ORDER BY
clicksCount.clicks DESC
</if>
<if test="pageVO.orderByDownload == 1">
ORDER BY
downloadCount.download DESC
</if>
</select>
<select id="myCollectPage" resultMap="BaseResultReportVoMap">
SELECT
eo.id AS id,
eo.`NAME` AS NAME,
eo.keycontent AS keyContent,
eo.maincontent AS mainContent,
eo.DEPARTMENT AS department,
eo.`YEAR` AS `year`,
eo.confidentialLevel AS confidentialLevel,
eo.privacyLevel AS privacyLevel,
eo.createUserId AS createUserId,
tu.USNAME AS uploader,
eo.createDate AS createDate,
thumbUpCount.thumbUp AS thumbUp,
clicksCount.clicks AS clicks,
downloadCount.download AS download,
AVG( trur.user_rating ) AS reportRating,
IF(bpn.id is null,1,
IF(bpn.SUBMIT_STATUS = 1 and bpn.CREAT_USER = #{pageVO.usid} ,0,1)
) as isAct
,
f.FILE_ID as fileId, f.file_name as fileName ,rf.id as rfId
FROM
TT_REPORT_MANAGE eo
LEFT JOIN ts_report_content rc ON eo.id = rc.report_id
LEFT JOIN ts_user tu ON tu.USID = eo.createUserId
LEFT JOIN (SELECT report_id, COUNT(id) AS thumbUp FROM report_log_book WHERE type = 3 GROUP BY report_id) AS thumbUpCount ON eo.id = thumbUpCount.report_id
LEFT JOIN (SELECT report_id, COUNT(id) AS clicks FROM report_log_book WHERE type = 1 GROUP BY report_id) AS clicksCount ON eo.id = clicksCount.report_id
LEFT JOIN (SELECT report_id, COUNT(id) AS download FROM report_log_book WHERE type = 2 GROUP BY report_id) AS downloadCount ON eo.id = downloadCount.report_id
LEFT JOIN ts_report_user_rating AS trur ON eo.id = trur.report_id
LEFT JOIN bus_process_name as bpn on bpn.data_id = eo.id and bpn.prc_type != '5'
LEFT JOIN ts_report_file rf on rf.report_id = eo.id and rf.state = 2
LEFT JOIN ts_file f on f.FILE_ID = rf.file_id
WHERE
eo.DEL_FLAG = 0
<!--全文模糊搜索-->
@@ -201,6 +285,13 @@
#{id}
</foreach>
</if>
<!--collectReportIds搜索-->
<if test="collectReportIds !=null and collectReportIds.size() > 0">
and eo.id in
<foreach collection="collectReportIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
GROUP BY
eo.id
<if test="pageVO.orderByTime == 1">