上传包结构

newBigdata
yz 1 year ago
parent db85b51715
commit 09eb0ebc86

@ -0,0 +1,51 @@
package com.sztzjy.financial_bigdata.controller.tea;
import com.sztzjy.financial_bigdata.entity.TeaResourceCenter;
import com.sztzjy.financial_bigdata.service.tea.ITeaResourceCenterService;
import com.sztzjy.financial_bigdata.util.ResultEntity;
import com.sztzjy.financial_bigdata.util.file.IFileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
//资源中心
@RestController
@Api(tags = "教师端--资源中心-资源列表")
@RequestMapping("api/tch/resourceCenter")
public class TeaResourceCenterController {
@Autowired
IFileUtil fileUtil;
@Autowired
ITeaResourceCenterService resourceCenterService;
//上传资源文件
@GetMapping("uploadResource")
@ApiOperation("上传资源文件")
public ResultEntity uploadResource(@RequestParam MultipartFile file,
@ApiParam("学校id") @RequestParam(required = false) String schoolId,
@ApiParam("章节Id") String chapterId){
Boolean flag=resourceCenterService.uploadResource(file,schoolId,chapterId);
if (flag){
return new ResultEntity<>(HttpStatus.OK,"新增成功");
}else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST,"新增失败");
}
}
//查看资源文件
@GetMapping("selectResource")
@ApiOperation("查看资源文件")
public ResultEntity uploadResourceCenter(@ApiParam("学校id") @RequestParam(required = false) String schoolId,
@ApiParam("章节Id") String chapterId){
List<TeaResourceCenter> list=resourceCenterService.selectResource(schoolId,chapterId);
return new ResultEntity(HttpStatus.OK, "相对估值法-PS市盈率法展示成功", list);
}
}

@ -3,8 +3,10 @@ package com.sztzjy.financial_bigdata.mapper;
import com.sztzjy.financial_bigdata.entity.TeaResourceCenter;
import com.sztzjy.financial_bigdata.entity.TeaResourceCenterExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface TeaResourceCenterMapper {
long countByExample(TeaResourceCenterExample example);

@ -0,0 +1,12 @@
package com.sztzjy.financial_bigdata.service.tea;
import com.sztzjy.financial_bigdata.entity.TeaResourceCenter;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public interface ITeaResourceCenterService {
Boolean uploadResource(MultipartFile file, String schoolId,String chapterId);
List<TeaResourceCenter> selectResource(String schoolId, String chapterId);
}

@ -0,0 +1,47 @@
package com.sztzjy.financial_bigdata.service.tea.impl;
import com.sztzjy.financial_bigdata.entity.TeaResourceCenter;
import com.sztzjy.financial_bigdata.entity.TeaResourceCenterExample;
import com.sztzjy.financial_bigdata.mapper.TeaResourceCenterMapper;
import com.sztzjy.financial_bigdata.service.tea.ITeaResourceCenterService;
import com.sztzjy.financial_bigdata.util.file.IFileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.UUID;
@Service
public class TeaResourceCenterServiceImpl implements ITeaResourceCenterService {
@Autowired
IFileUtil fileUtil;
@Autowired
TeaResourceCenterMapper resourceCenterMapper;
@Override
public Boolean uploadResource(MultipartFile file, String schoolId,String chapterId) {
String uploadUrl = fileUtil.upload(file);
TeaResourceCenter resourceCenter=new TeaResourceCenter();
resourceCenter.setResourceId(String.valueOf(UUID.randomUUID()));
resourceCenter.setResourceName(file.getOriginalFilename());
resourceCenter.setResourceUrl(uploadUrl);
resourceCenter.setChapterId(chapterId);
resourceCenter.setSchoolId(schoolId);
int insert = resourceCenterMapper.insert(resourceCenter);
if(insert!=0){
return true;
}else {
return false;
}
}
@Override
public List<TeaResourceCenter> selectResource(String schoolId, String chapterId) {
// TeaResourceCenterExample example=new TeaResourceCenterExample();
// TeaResourceCenterExample.Criteria criteria = example.createCriteria();
// criteria.andChapterIdEqualTo(chapterId).andSc
// resourceCenterMapper.selectByExample()
return null;
}
}

@ -1,62 +1,65 @@
package com.sztzjy.financial_bigdata.util;
import cn.hutool.core.util.IdUtil;
import com.sztzjy.financial_bigdata.util.seal.SealCircle;
import com.sztzjy.financial_bigdata.util.seal.SealFont;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
/**
* @author 17803
* @date 2023-12-05 15:11
*/
@Component
public class SealUtil {
@Value("${file.path}")
private String filePath;
public String genertSealB(String name) throws Exception {
String file = filePath + "/seal/";
// 创建 File 对象
File infoFile = new File(file);
if (!infoFile.exists()) {
infoFile.mkdir();
}
String s = IdUtil.fastSimpleUUID();
com.sztzjy.financial_bigdata.util.seal.SealUtil.builder()
.size(200)
.borderCircle(SealCircle.builder().line(4).width(95).height(95).build())
.mainFont(SealFont.builder().text(name + "有限公司").size(22).space(30.0).margin(4).build())
.centerFont(SealFont.builder().text("★").size(60).build())
.titleFont(SealFont.builder().text("电子签章").size(16).space(8.0).margin(54).build())
.build()
.draw(filePath + "/seal/" + s + ".png");
System.out.println(name + "公章已生成");
return s;
}
public String genertSealA(String name) throws Exception {
String file = filePath + "/seal/";
// 创建 File 对象
File infoFile = new File(file);
if (!infoFile.exists()) {
infoFile.mkdir();
}
String s = IdUtil.fastSimpleUUID();
com.sztzjy.financial_bigdata.util.seal.SealUtil.builder()
.size(200)
.borderCircle(SealCircle.builder().line(4).width(95).height(95).build())
.mainFont(SealFont.builder().text(name).size(22).space(30.0).margin(4).build())
.centerFont(SealFont.builder().text("★").size(60).build())
.titleFont(SealFont.builder().text("电子签章").size(16).space(8.0).margin(54).build())
.build()
.draw(filePath + "/seal/" + s + ".png");
System.out.println(name + "公章已生成");
return s;
}
}
//package com.sztzjy.financial_bigdata.util;
//
//import cn.hutool.core.util.IdUtil;
//import com.sztzjy.financial_bigdata.util.file.LocalFileUtil;
//import com.sztzjy.financial_bigdata.util.seal.SealCircle;
//import com.sztzjy.financial_bigdata.util.seal.SealFont;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.io.File;
//
///**
// * @author 17803
// * @date 2023-12-05 15:11
// */
//
//@Component
//public class SealUtil {
//
// @Resource
// LocalFileUtil localFileUtil;
//
// @Value("${file.path}")
// private String filePath;
//
// public String genertSealB(String name) throws Exception{
// String file = filePath+"/seal/";
// // 创建 File 对象
// File infoFile = new File(file);
// if (!infoFile.exists()) {
// infoFile.mkdir();
// }
// String s = IdUtil.fastSimpleUUID();
// com.sztzjy.financial_bigdata.util.seal.SealUtil.builder()
// .size(200)
// .borderCircle(SealCircle.builder().line(4).width(95).height(95).build())
// .mainFont(SealFont.builder().text(name+"有限公司").size(22).space(30.0).margin(4).build())
// .centerFont(SealFont.builder().text("★").size(60).build())
// .titleFont(SealFont.builder().text("电子签章").size(16).space(8.0).margin(54).build())
// .build()
// .draw(filePath+"/seal/"+ s +".png");
// System.out.println(name+"公章已生成");
// return s;
// }
// public String genertSealA(String name) throws Exception{
// String file = filePath+"/seal/";
// // 创建 File 对象
// File infoFile = new File(file);
// if (!infoFile.exists()) {
// infoFile.mkdir();
// }
// String s = IdUtil.fastSimpleUUID();
// com.sztzjy.financial_bigdata.util.seal.SealUtil.builder()
// .size(200)
// .borderCircle(SealCircle.builder().line(4).width(95).height(95).build())
// .mainFont(SealFont.builder().text(name).size(22).space(30.0).margin(4).build())
// .centerFont(SealFont.builder().text("★").size(60).build())
// .titleFont(SealFont.builder().text("电子签章").size(16).space(8.0).margin(54).build())
// .build()
// .draw(filePath+"/seal/"+ s +".png");
// System.out.println(name+"公章已生成");
// return s;
// }
//}

@ -118,7 +118,6 @@ public class LocalFileUtil implements IFileUtil{
@Override
public String getSuffix(String fileName) {
Assert.hasText(fileName, "文件名不存在!");
if (fileName.lastIndexOf(".") < 0) {
return null;
}
@ -147,6 +146,7 @@ public class LocalFileUtil implements IFileUtil{
return path.toString();
}
private String upload(String fileName, MultipartFile file, String relativePath) {
Assert.isTrue(!file.isEmpty(), "文件不存在");
String originalFilename = file.getOriginalFilename();

Loading…
Cancel
Save