|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.sztzjy.forex.trading_trading.service;
|
|
|
|
|
|
|
|
|
|
import com.sztzjy.forex.trading_trading.config.security.JwtUser;
|
|
|
|
|
import com.sztzjy.forex.trading_trading.entity.*;
|
|
|
|
|
import com.sztzjy.forex.trading_trading.mappers.MemberMapper;
|
|
|
|
|
import com.sztzjy.forex.trading_trading.mappers.ReportMapper;
|
|
|
|
@ -7,6 +8,8 @@ import com.sztzjy.forex.trading_trading.util.file.IFileUtil;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
@ -83,6 +86,29 @@ public class ReportService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void uploadReport(MultipartFile file, String fileName, Member member) {
|
|
|
|
|
String filePath = fileUtil.upload(file);
|
|
|
|
|
ReportExample reportExample = new ReportExample();
|
|
|
|
|
reportExample.createCriteria().andMemberIdEqualTo(member.getMemberId());
|
|
|
|
|
List<ReportWithBLOBs> reports = reportsMapper.selectByExampleWithBLOBs(reportExample);
|
|
|
|
|
if(reports!=null&&reports.size()>0){
|
|
|
|
|
ReportWithBLOBs report = reports.get(0);
|
|
|
|
|
if(StringUtils.hasText(report.getFilePath())){
|
|
|
|
|
fileUtil.remove(report.getFilePath());
|
|
|
|
|
}
|
|
|
|
|
report.setFilePath(filePath);
|
|
|
|
|
report.setFileName(fileName);
|
|
|
|
|
reportsMapper.updateByExample(report,reportExample);
|
|
|
|
|
}else{
|
|
|
|
|
ReportWithBLOBs report = new ReportWithBLOBs();
|
|
|
|
|
report.setFileName(fileName);
|
|
|
|
|
report.setFilePath(filePath);
|
|
|
|
|
report.setMemberId(member.getMemberId());
|
|
|
|
|
report.setTrainingId(member.getTrainingId());
|
|
|
|
|
reportsMapper.insert(report);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // 指定服务器目录
|
|
|
|
|
// public String uploadReport(InputStream fileInputStream, String fileName, String memberId,String trainingId) {
|
|
|
|
@ -128,7 +154,6 @@ public class ReportService {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void review(String reportId, Double score) {
|
|
|
|
|
Report report = reportsMapper.selectByPrimaryKey(reportId);
|
|
|
|
|
Assert.isTrue(report != null && report.getMemberId() != null, "报告不存在");
|
|
|
|
@ -146,4 +171,15 @@ public class ReportService {
|
|
|
|
|
Assert.isTrue(report != null && report.getFilePath() != null, "报告不存在");
|
|
|
|
|
fileUtil.download(response, report.getFileName(), report.getFilePath());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Report findByMemberId(String memberId) {
|
|
|
|
|
ReportExample reportExample = new ReportExample();
|
|
|
|
|
ReportExample.Criteria criteria = reportExample.createCriteria();
|
|
|
|
|
criteria.andMemberIdEqualTo(memberId);
|
|
|
|
|
List<Report> reports = reportsMapper.selectByExample(reportExample);
|
|
|
|
|
if (reports != null && reports.size() > 0) {
|
|
|
|
|
return reports.get(0);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|