上传包结构

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

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

Loading…
Cancel
Save