1、用户文件表增加下载次数字段;
2、用户文件下载次数自增+1业务接口实现; 3、下载及批量下载接口更新下载次数+1; 4、ES搜索文件接口增加下载次数字段返回
This commit is contained in:
parent
ec82785256
commit
ef4366d148
@ -278,3 +278,10 @@ elasticsearch:
|
||||
host: 8.134.76.66
|
||||
port: 9200
|
||||
scheme: http
|
||||
# 超时配置(毫秒)
|
||||
connectTimeout: 5000
|
||||
socketTimeout: 60000
|
||||
connectionRequestTimeout: 1000
|
||||
# 连接池配置
|
||||
maxConnTotal: 100
|
||||
maxConnPerRoute: 100
|
||||
|
||||
@ -6,6 +6,7 @@ import co.elastic.clients.transport.ElasticsearchTransport;
|
||||
import co.elastic.clients.transport.rest_client.RestClientTransport;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
import org.elasticsearch.client.RestClientBuilder;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -19,12 +20,40 @@ public class ElasticSearchConfig {
|
||||
@Value("${elasticsearch.port}")
|
||||
private int port;
|
||||
|
||||
@Value("${elasticsearch.scheme}")
|
||||
@Value("${elasticsearch.scheme:http}")
|
||||
private String scheme;
|
||||
|
||||
@Value("${elasticsearch.connectTimeout:5000}")
|
||||
private int connectTimeout;
|
||||
|
||||
@Value("${elasticsearch.socketTimeout:60000}")
|
||||
private int socketTimeout;
|
||||
|
||||
@Value("${elasticsearch.connectionRequestTimeout:1000}")
|
||||
private int connectionRequestTimeout;
|
||||
|
||||
@Value("${elasticsearch.maxConnTotal:100}")
|
||||
private int maxConnTotal;
|
||||
|
||||
@Value("${elasticsearch.maxConnPerRoute:100}")
|
||||
private int maxConnPerRoute;
|
||||
|
||||
@Bean
|
||||
public ElasticsearchClient elasticsearchClient() {
|
||||
RestClient client = RestClient.builder(new HttpHost(host, port, scheme)).build();
|
||||
RestClientBuilder builder = RestClient.builder(new HttpHost(host, port, scheme))
|
||||
.setRequestConfigCallback(requestConfigBuilder ->
|
||||
requestConfigBuilder
|
||||
.setConnectTimeout(connectTimeout) // 连接超时
|
||||
.setSocketTimeout(socketTimeout) // 读取超时
|
||||
.setConnectionRequestTimeout(connectionRequestTimeout) // 从连接池获取连接的超时
|
||||
)
|
||||
.setHttpClientConfigCallback(httpClientBuilder ->
|
||||
httpClientBuilder
|
||||
.setMaxConnTotal(maxConnTotal) // 最大连接数
|
||||
.setMaxConnPerRoute(maxConnPerRoute) // 单个路由的最大连接数
|
||||
);
|
||||
|
||||
RestClient client = builder.build();
|
||||
ElasticsearchTransport transport = new RestClientTransport(client, new JacksonJsonpMapper());
|
||||
return new ElasticsearchClient(transport);
|
||||
}
|
||||
|
||||
@ -23,4 +23,5 @@ public class FileSearch {
|
||||
private Integer deleteFlag;
|
||||
private String deleteTime;
|
||||
private String deleteBatchNum;
|
||||
private Long downloadCnt;
|
||||
}
|
||||
|
||||
@ -148,6 +148,8 @@ public class FiletransferController {
|
||||
filetransferService.downloadFile(httpServletResponse, downloadFileDTO);
|
||||
// 保存下载记录
|
||||
downloadRecordService.saveDownloadRecord(Arrays.asList(downloadFileDTO.getUserFileId()));
|
||||
// 增加下载次数
|
||||
userFileService.incrementDownloadCount(Arrays.asList(downloadFileDTO.getUserFileId()));
|
||||
}
|
||||
|
||||
@Operation(summary = "批量下载文件", description = "批量下载文件", tags = {"filetransfer"})
|
||||
@ -198,7 +200,10 @@ public class FiletransferController {
|
||||
String fileName = String.valueOf(date.getTime());
|
||||
httpServletResponse.addHeader("Content-Disposition", "attachment;fileName=" + fileName + ".zip");// 设置文件名
|
||||
filetransferService.downloadUserFileList(httpServletResponse, userFile.getFilePath(), fileName, userFileIds);
|
||||
// 保存下载记录
|
||||
downloadRecordService.saveDownloadRecord(userFileIds);
|
||||
// 增加下载次数
|
||||
userFileService.incrementDownloadCount(userFileIds);
|
||||
}
|
||||
|
||||
@Operation(summary="预览文件", description="用于文件预览", tags = {"filetransfer"})
|
||||
|
||||
@ -69,6 +69,9 @@ public class UserFile {
|
||||
@Column(columnDefinition="char(1) comment '修改用户id'")
|
||||
private String accessPermission;
|
||||
|
||||
@Column(columnDefinition="bigint(0) comment '下载次数'")
|
||||
private Long downloadCnt;
|
||||
|
||||
public UserFile() {};
|
||||
public UserFile(QiwenFile qiwenFile, Long userId, String fileId) {
|
||||
this.userFileId = IdUtil.getSnowflakeNextIdStr();
|
||||
|
||||
@ -19,4 +19,6 @@ public interface UserFileMapper extends BaseMapper<UserFile> {
|
||||
List<UserFile> selectByUserFileId(String userFileId);
|
||||
|
||||
List<UserFileDTO> selectFileTreeByUserId(Long userId);
|
||||
|
||||
int incrementDownloadCount(@Param("userFileIdList") List<String> userFileIdList);
|
||||
}
|
||||
|
||||
@ -29,5 +29,7 @@ public interface IUserFileService extends IService<UserFile> {
|
||||
*
|
||||
* @return 文件树结构信息
|
||||
*/
|
||||
public List<FileTreeSelect> selectUserFileTreeList();
|
||||
List<FileTreeSelect> selectUserFileTreeList();
|
||||
|
||||
int incrementDownloadCount(List<String> asList);
|
||||
}
|
||||
|
||||
@ -304,6 +304,10 @@ public class UserFileServiceImpl extends ServiceImpl<UserFileMapper, UserFile> i
|
||||
return treeSelectList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int incrementDownloadCount(List<String> userFileIdList) {
|
||||
return userFileMapper.incrementDownloadCount(userFileIdList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -43,5 +43,6 @@ public class FileListVO {
|
||||
private Integer imageHeight;
|
||||
|
||||
private String accessPermission;
|
||||
private Long downloadCnt;
|
||||
|
||||
}
|
||||
|
||||
@ -22,4 +22,5 @@ public class SearchFileVO {
|
||||
private Map<String, List<String>> highLight;
|
||||
private Integer isDir;
|
||||
private String uploadTime;
|
||||
private Long downloadCnt;
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
<result property="fileSize" column="fileSize"/>
|
||||
<result property="userId" column="userId"/>
|
||||
<result property="accessPermission" column="accessPermission"/>
|
||||
<result property="downloadCnt" column="downloadCnt"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="UserFileDtoMap" type="com.ruoyi.file.dto.file.UserFileDTO">
|
||||
@ -44,6 +45,7 @@
|
||||
<result property="fileSize" column="fileSize"/>
|
||||
<result property="userId" column="userId"/>
|
||||
<result property="accessPermission" column="accessPermission"/>
|
||||
<result property="downloadCnt" column="downloadCnt"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectPageVo" resultType="com.ruoyi.file.vo.file.FileListVO">
|
||||
@ -105,4 +107,13 @@
|
||||
WHERE userfile.userId = #{userId}
|
||||
</select>
|
||||
|
||||
<update id="incrementDownloadCount">
|
||||
UPDATE userfile
|
||||
SET downloadCnt = downloadCnt + 1
|
||||
WHERE userFileId IN
|
||||
<foreach collection="userFileIdList" item="userFileId" open="(" separator="," close=")">
|
||||
#{userFileId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user