|
@@ -1,14 +1,18 @@
|
|
|
package com.dragon.tj.portal.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.dragon.tj.portal.auth.model.LoginUser;
|
|
|
import com.dragon.tj.portal.auth.util.SecurityUtils;
|
|
|
import com.dragon.tj.portal.common.util.UploadUtils;
|
|
|
import com.dragon.tj.portal.entity.FileInfo;
|
|
|
import com.dragon.tj.portal.entity.PageParam;
|
|
|
+import com.dragon.tj.portal.entity.SysLog;
|
|
|
import com.dragon.tj.portal.mapper.FileManageMapper;
|
|
|
import com.dragon.tj.portal.service.FileManageService;
|
|
|
+import com.dragon.tj.portal.service.SysLogService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -34,6 +38,9 @@ public class FileManageServiceImpl implements FileManageService {
|
|
|
@Autowired
|
|
|
private FileManageMapper fileManageMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysLogService sysLogServices;
|
|
|
+
|
|
|
@Override
|
|
|
public FileInfo upload(MultipartFile file,Integer type) {
|
|
|
String originalFilename = file.getOriginalFilename();
|
|
@@ -111,4 +118,27 @@ public class FileManageServiceImpl implements FileManageService {
|
|
|
List<String> list = Arrays.asList(type.split(","));
|
|
|
return fileManageMapper.getTop(list,num);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void fileLog(String uri,String ip) {
|
|
|
+ QueryWrapper<FileInfo> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.like(StringUtils.isNotEmpty(uri), "url", uri);
|
|
|
+ FileInfo fileInfo = fileManageMapper.selectOne(wrapper);
|
|
|
+ fileInfo.setDownloads(fileInfo.getDownloads() + 1);
|
|
|
+
|
|
|
+ fileManageMapper.updateById(fileInfo);
|
|
|
+
|
|
|
+ //添加日志
|
|
|
+ SysLog sysLog = new SysLog();
|
|
|
+ sysLog.setRemoteAddr(ip);
|
|
|
+ sysLog.setRequestUri(uri);
|
|
|
+// LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
+// sysLog.setCreateBy(loginUser);
|
|
|
+
|
|
|
+ sysLog.setTitle("file_download");
|
|
|
+ sysLog.setParams(JSON.toJSONString(fileInfo));
|
|
|
+
|
|
|
+ sysLogServices.save(sysLog);
|
|
|
+
|
|
|
+ }
|
|
|
}
|