feat(communityCenter): 社区文件下载记录功能
parent
f90bc03b48
commit
502fcb3072
|
@ -31,6 +31,12 @@ public class CommunityFilePageListRes extends PageDomain {
|
|||
@NotNull(message = "社区id不能为空")
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 查询条件
|
||||
*/
|
||||
@ApiModelProperty(value = "查询条件")
|
||||
private String search;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -46,6 +46,12 @@ public class CommunityFileVo {
|
|||
@ApiModelProperty(value = "文件名称")
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
@ApiModelProperty(value = "文件大小")
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* 上传人
|
||||
*/
|
||||
|
@ -53,6 +59,13 @@ public class CommunityFileVo {
|
|||
private String uploadUserName;
|
||||
|
||||
|
||||
/**
|
||||
* 下载记录
|
||||
*/
|
||||
@ApiModelProperty(value = "用户下载记录")
|
||||
private DownloadFileUserVo downloadFileUser;
|
||||
|
||||
|
||||
/**
|
||||
* 上传时间
|
||||
*/
|
||||
|
@ -60,10 +73,5 @@ public class CommunityFileVo {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 下载记录
|
||||
*/
|
||||
@ApiModelProperty(value = "用户下载记录")
|
||||
private DownloadFileUserVo downloadFileUser;
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.List;
|
|||
public class DownloadFileUserVo {
|
||||
|
||||
@ApiModelProperty(value = "用户头像")
|
||||
private List<String> avatarUrlList;
|
||||
private List<String> avatarList;
|
||||
|
||||
@ApiModelProperty(value = "下载用户数")
|
||||
private Integer count;
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.communityCenter.domain.CommunityFile;
|
||||
import com.mcwl.communityCenter.domain.CommunityFileLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CommunityFileLogMapper extends BaseMapper<CommunityFileLog> {
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<String> getUserAvatarList(@Param("tenantId")
|
||||
Long tenantId,
|
||||
@Param("communityId")
|
||||
Long communityId,
|
||||
@Param("communityFileId")
|
||||
Long communityFileId);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
Integer getDownloadCount(Long tenantId, Long communityId, Long communityFileId);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.domain.CommunityFile;
|
||||
import com.mcwl.communityCenter.domain.dto.CommunityFilePageListRes;
|
||||
import com.mcwl.communityCenter.domain.vo.CommunityFileVo;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -18,5 +19,5 @@ import java.util.Map;
|
|||
public interface CommunityFileMapper extends BaseMapper<CommunityFile> {
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<CommunityFile> getCommunityFileList(Page<CommunityFile> page, @Param("communityFilePageListRes") CommunityFilePageListRes communityFilePageListRes);
|
||||
List<CommunityFileVo> getCommunityFileList(Page<CommunityFile> page, @Param("communityFilePageListRes") CommunityFilePageListRes communityFilePageListRes);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.mcwl.communityCenter.domain.CommunityFile;
|
||||
import com.mcwl.communityCenter.domain.CommunityFileLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CommunityFileLogService extends IService<CommunityFileLog> {
|
||||
|
||||
List<String> getUserAvatarList(Long tenantId, Long communityId, Long communityFileId);
|
||||
|
||||
Integer getDownloadCount(Long tenantId, Long communityId, Long communityFileId);
|
||||
}
|
||||
|
|
|
@ -10,11 +10,22 @@ import com.mcwl.communityCenter.service.CommunityFileService;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CommunityFileLogServiceImpl extends ServiceImpl<CommunityFileLogMapper, CommunityFileLog> implements CommunityFileLogService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getUserAvatarList(Long tenantId, Long communityId, Long communityFileId) {
|
||||
return baseMapper.getUserAvatarList(tenantId, communityId, communityFileId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDownloadCount(Long tenantId, Long communityId, Long communityFileId) {
|
||||
return baseMapper.getDownloadCount(tenantId, communityId, communityFileId);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -10,8 +11,12 @@ import com.mcwl.common.utils.SecurityUtils;
|
|||
import com.mcwl.common.utils.obs.ObsUtils;
|
||||
import com.mcwl.communityCenter.domain.CommunityFile;
|
||||
import com.mcwl.communityCenter.domain.dto.*;
|
||||
import com.mcwl.communityCenter.domain.vo.CommunityFileVo;
|
||||
import com.mcwl.communityCenter.domain.vo.DownloadFileUserVo;
|
||||
import com.mcwl.communityCenter.mapper.CommunityFileMapper;
|
||||
import com.mcwl.communityCenter.service.CommunityFileLogService;
|
||||
import com.mcwl.communityCenter.service.CommunityFileService;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
@ -23,6 +28,12 @@ import java.util.*;
|
|||
public class CommunityFileServiceImpl extends ServiceImpl<CommunityFileMapper, CommunityFile> implements CommunityFileService {
|
||||
|
||||
private final ObsUtils obsUtils;
|
||||
|
||||
private final ISysUserService userService;
|
||||
|
||||
private final CommunityFileLogService communityFileLogService;
|
||||
|
||||
|
||||
@Override
|
||||
public void upload(CommunityUploadFileRes communityUploadFileRes) {
|
||||
Long tenantId = communityUploadFileRes.getTenantId();
|
||||
|
@ -47,11 +58,26 @@ public class CommunityFileServiceImpl extends ServiceImpl<CommunityFileMapper, C
|
|||
@Override
|
||||
public TableDataInfo getCommunityFileList(CommunityFilePageListRes communityFilePageListRes) {
|
||||
Page<CommunityFile> page = new Page<>(communityFilePageListRes.getPageNum(), communityFilePageListRes.getPageSize());
|
||||
List<CommunityFile> publishList = baseMapper.getCommunityFileList(page, communityFilePageListRes);
|
||||
List<CommunityFileVo> communityFileList = baseMapper.getCommunityFileList(page, communityFilePageListRes);
|
||||
for (CommunityFileVo communityFileVo : communityFileList) {
|
||||
DownloadFileUserVo downloadFileUserVo = new DownloadFileUserVo();
|
||||
|
||||
List<String> avatarList = communityFileLogService.getUserAvatarList(communityFileVo.getTenantId(),
|
||||
communityFileVo.getCommunityId(),
|
||||
communityFileVo.getId());
|
||||
Integer count = communityFileLogService.getDownloadCount(communityFileVo.getTenantId(),
|
||||
communityFileVo.getCommunityId(),
|
||||
communityFileVo.getId());
|
||||
|
||||
downloadFileUserVo.setAvatarList(avatarList);
|
||||
downloadFileUserVo.setCount(count);
|
||||
|
||||
|
||||
communityFileVo.setDownloadFileUser(downloadFileUserVo);
|
||||
}
|
||||
// 封装返回
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setRows(publishList);
|
||||
tableDataInfo.setRows(communityFileList);
|
||||
tableDataInfo.setTotal(page.getTotal());
|
||||
tableDataInfo.setCode(HttpStatus.SUCCESS);
|
||||
tableDataInfo.setMsg("查询成功");
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mcwl.communityCenter.mapper.CommunityFileLogMapper">
|
||||
|
||||
<select id="getUserAvatarList" resultType="java.lang.String">
|
||||
select su.avatar
|
||||
from cc_community_file_log cfl
|
||||
left join sys_user su on cfl.download_user_id = su.user_id
|
||||
where tenant_id = #{tenantId}
|
||||
and community_id = #{communityId}
|
||||
and community_file_id = #{communityFileId}
|
||||
order by cfl.create_time desc
|
||||
</select>
|
||||
<select id="getDownloadCount" resultType="java.lang.Integer">
|
||||
select count(*)
|
||||
from cc_community_file_log
|
||||
where tenant_id = #{tenantId}
|
||||
and community_id = #{communityId}
|
||||
and community_file_id = #{communityFileId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -5,12 +5,16 @@
|
|||
<mapper namespace="com.mcwl.communityCenter.mapper.CommunityFileMapper">
|
||||
|
||||
|
||||
<select id="getCommunityFileList" resultType="com.mcwl.communityCenter.domain.CommunityFile">
|
||||
select *
|
||||
from cc_community_file
|
||||
where del_flag = '0'
|
||||
and tenant_id = #{communityFilePageListRes.tenantId}
|
||||
and community_id = #{communityFilePageListRes.communityId}
|
||||
order by create_time desc
|
||||
<select id="getCommunityFileList" resultType="com.mcwl.communityCenter.domain.vo.CommunityFileVo">
|
||||
select cf.*, su.nick_name as upload_user_name
|
||||
from cc_community_file cf left join sys_user su on cf.user_id = su.user_id
|
||||
where cf.del_flag = '0'
|
||||
and tenant_id = #{communityFilePageListRes.tenantId}
|
||||
and community_id = #{communityFilePageListRes.communityId}
|
||||
<if test="communityFilePageListRes.search != null and communityFilePageListRes.search != ''">
|
||||
and (cf.file_name like concat('%', #{communityFilePageListRes.search}, '%')
|
||||
or su.nick_name like concat('%', #{communityFilePageListRes.search}, '%'))
|
||||
</if>
|
||||
order by cf.create_time desc
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue