WebReportTableController.java
3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package com.lhcredit.project.webbusiness.controller;
import cn.hutool.core.util.ObjectUtil;
import com.github.pagehelper.PageHelper;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.framework.aspectj.lang.annotation.Log;
import com.lhcredit.framework.aspectj.lang.enums.BusinessType;
import com.lhcredit.framework.aspectj.lang.enums.OperatorType;
import com.lhcredit.framework.web.controller.BaseController;
import com.lhcredit.framework.web.domain.AjaxResult;
import com.lhcredit.framework.web.service.FastDFSClient;
import com.lhcredit.framework.web.service.FdfsService;
import com.lhcredit.project.business.frontUser.domain.FrontUser;
import com.lhcredit.project.business.frontUser.domain.FrontUserMon;
import com.lhcredit.project.business.frontUser.service.IFrontUserService;
import com.lhcredit.project.business.frontUser.service.RedisTokenManager;
import com.lhcredit.project.business.reportTable.domain.ReportTable;
import com.lhcredit.project.business.reportTable.service.ReportTableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
@Api(tags = "企业信用报告")
@RestController
@RequestMapping("/web/reportTable")
@RequiredArgsConstructor
public class WebReportTableController extends BaseController {
@Autowired
private ReportTableService reportTableService;
@Autowired
private RedisTokenManager redisTokenManager;
@Autowired
private FastDFSClient fastDFSClient;
@Autowired
private IFrontUserService frontUserService;
@ResponseBody
@ApiOperation(value = "企业信用报告列表")
@Log(title = "企业信用报告列表", businessType = BusinessType.LIST, operatorType = OperatorType.WEB)
@GetMapping("/list")
public AjaxResult list() {
PageHelper.startPage(1, 10);
String isDel = null;
List<ReportTable> list = reportTableService.findAllReportTable(isDel);
return toAjax(list);
}
@ApiOperation(value = "修改企业信用报告列表")
@PostMapping("/updateReport")
public AjaxResult upLoad(ReportTable reportTable , @RequestParam("file") MultipartFile file) throws Exception {
try {
if (!ObjectUtil.isEmpty(file)){
//通过名称判断图片是那种类型的并存入库中
String fileName = file.getOriginalFilename();
String suffix = null;
Integer id = null;
int lastIndex = fileName.lastIndexOf('.');
if (lastIndex != -1) {
suffix = fileName.substring(0, lastIndex);
if (suffix.equals("标注版")){
id = 378;
}
if (suffix.equals("实地调查")){
id = 380;
}
if (suffix.equals("招投标")){
id = 381;
}
if (suffix.equals("企业债")){
id = 382;
}
if (suffix.equals("尽职调查报告")){
id = 383;
}
if (suffix.equals("海外报告")){
id = 384;
}
}
String s = fastDFSClient.uploadFile(file);
reportTable.setId(id);
reportTable.setImageUrl(s);
}
reportTableService.updateReport(reportTable);
} catch (IOException e) {
e.printStackTrace();
return AjaxResult.error();
}
return AjaxResult.success();
}
}