fix:多材料校验提交

dev
wangxy 12 months ago
parent 7291e1bf54
commit 38f2af6906

@ -120,7 +120,6 @@ public class ApplyInfoListManager {
* @param applyId
* @return boolean
*/
public boolean deleteById(String applyId){
relationService.lambdaUpdate()
.eq(RewFileRelation::getApplyId, applyId)
@ -135,7 +134,6 @@ public class ApplyInfoListManager {
* @param applyId
* @return com.hyp.system.domain.vo.ApplyInfoListVO
*/
public ApplyInfoListVO detail(String applyId){
RewApplyInfoList applyInfoList = applyInfoListService.getById(applyId);
ApplyInfoListVO applyInfoListVO = Convert.convert(ApplyInfoListVO.class, applyInfoList);
@ -154,7 +152,6 @@ public class ApplyInfoListManager {
* @param applyId
* @return boolean
*/
public boolean audit(String applyId){
return applyInfoListService.lambdaUpdate()
.eq(RewApplyInfoList::getApplyId, applyId)
@ -169,7 +166,6 @@ public class ApplyInfoListManager {
* @param applyMsg
* @return boolean
*/
public boolean applyBack(String applyId,String applyMsg){
return applyInfoListService.lambdaUpdate()
.eq(RewApplyInfoList::getApplyId, applyId)

@ -2,14 +2,25 @@ package com.hyp.web.controller.manager;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hyp.common.config.HypConfig;
import com.hyp.common.core.domain.AjaxResult;
import com.hyp.common.exception.ServiceException;
import com.hyp.common.utils.file.FileUploadUtils;
import com.hyp.common.utils.file.FileUtils;
import com.hyp.framework.config.ServerConfig;
import com.hyp.system.domain.RewFileRelation;
import com.hyp.system.domain.RewScoreInfo;
import com.hyp.system.service.RewFileRelationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -28,6 +39,10 @@ public class FileRelationManager {
@Resource
private RewFileRelationService fileRelationService;
@Autowired
private ServerConfig serverConfig;
/**
*
*
@ -66,7 +81,6 @@ public class FileRelationManager {
* @param applyId
* @return com.hyp.common.core.domain.AjaxResult
*/
public AjaxResult checkFile(String applyId){
List<RewFileRelation> list = fileRelationService.lambdaQuery()
.eq(RewFileRelation::getApplyId, applyId)
@ -81,6 +95,16 @@ public class FileRelationManager {
return AjaxResult.success();
}
/**
*
*
* @param applyId
* @param filename
* @param fileCode
* @param url
* @param originalFilename
* @return com.hyp.system.domain.RewFileRelation
*/
@Transactional(rollbackFor = Exception.class)
public RewFileRelation save(String applyId,String filename,String fileCode,String url,String originalFilename){
RewFileRelation rewFileRelation = new RewFileRelation();
@ -93,13 +117,52 @@ public class FileRelationManager {
return rewFileRelation;
}
/**
*
*
* @param files
* @param applyId
* @param filename
* @param fileCode
* @return java.util.List<com.hyp.system.domain.RewFileRelation>
*/
@Transactional(rollbackFor = Exception.class)
public List<RewFileRelation> saveBatch(List<MultipartFile> files,
String applyId,
String filename,
String fileCode) throws IOException {
List<RewFileRelation> fileRelations = new ArrayList<>();
// 上传文件路径
String filePath = HypConfig.getUploadPath();
for (MultipartFile file : files) {
if (!file.isEmpty()) {
// 上传并返回新文件名称
String fileNames = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileNames;
if(StringUtils.isBlank(filename)){
filename = fileNames;
}
RewFileRelation rewFileRelation = new RewFileRelation();
rewFileRelation.setApplyId(applyId);
rewFileRelation.setFileName(filename);
rewFileRelation.setFileCode(fileCode);
rewFileRelation.setFilePath(url);
rewFileRelation.setRealName(FileUtils.getNameNotSuffix(file.getOriginalFilename()));
fileRelations.add(rewFileRelation);
}
}
fileRelationService.saveBatch(fileRelations);
return fileRelations;
}
/**
*
*
* @param fileId
* @return java.lang.String
*/
public String getFilePath(String fileId){
RewFileRelation fileRelation = fileRelationService.getById(fileId);
if(Objects.nonNull(fileRelation)){
@ -114,7 +177,6 @@ public class FileRelationManager {
* @param fileId
* @return java.lang.String
*/
public String getRealName(String fileId){
RewFileRelation fileRelation = fileRelationService.getById(fileId);
if(Objects.nonNull(fileRelation)){
@ -123,6 +185,20 @@ public class FileRelationManager {
return null;
}
/**
*
*
* @param applyId
* @param fileCode
* @return java.util.List<com.hyp.system.domain.RewFileRelation>
*/
public List<RewFileRelation> getFileInfo(String applyId,String fileCode){
LambdaQueryWrapper<RewFileRelation> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RewFileRelation::getApplyId,applyId);
queryWrapper.eq(Objects.nonNull(fileCode), RewFileRelation::getFileCode, fileCode);
return fileRelationService.list(queryWrapper);
}

@ -61,7 +61,6 @@ public class ScoreInfoManager {
* @param createId
* @return java.util.List<com.hyp.system.domain.RewScoreInfo>
*/
public List<RewScoreInfo> getScoreInfo(String applyId,Long createId){
LambdaQueryWrapper<RewScoreInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RewScoreInfo::getApplyId,applyId);

@ -32,7 +32,6 @@ public class SysNoticeManager {
* @param notice
* @return java.util.List<com.hyp.system.domain.SysNotice>
*/
public List<SysNotice> selectNoticeList(SysNotice notice){
return noticeService.selectNoticeList(notice);
}
@ -43,7 +42,6 @@ public class SysNoticeManager {
* @param notice
* @return boolean
*/
public boolean saveOrUpdate(SysNotice notice){
if(StringUtils.isNotEmpty(notice.getNoticeId())){
notice.setUpdateTime(new Date());
@ -59,7 +57,6 @@ public class SysNoticeManager {
* @param noticeId
* @return com.hyp.system.domain.SysNotice
*/
public SysNotice selectNoticeById(String noticeId){
return noticeService.getById(noticeId);
}
@ -70,7 +67,6 @@ public class SysNoticeManager {
* @param ids
* @return boolean
*/
public boolean removeByIds(String ids){
return noticeService.removeByIds(Arrays.asList(Convert.toStrArray(ids)));
}

@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.List;
/**
@ -70,6 +71,21 @@ public class FileRelationController extends BaseController {
}
}
/**
*
*/
@PostMapping("/uploads")
public AjaxResult uploadFiles(List<MultipartFile> files,
@RequestParam String applyId,
@RequestParam(required = false) String filename,
@RequestParam String fileCode){
try {
return AjaxResult.success(fileRelationManager.saveBatch(files,applyId,filename,fileCode));
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
@ApiOperation("材料预览")
@GetMapping("fileView/{fileId}")
public void fileView(@PathVariable String fileId, HttpServletResponse response) throws IOException {
@ -130,8 +146,12 @@ public class FileRelationController extends BaseController {
return fileRelationManager.checkFile(applyId);
}
@ApiOperation("文件查询")
@GetMapping("/getFileInfo")
public AjaxResult getFileInfo(@RequestParam String applyId,
@RequestParam(required = false) String fileCode) {
return success(fileRelationManager.getFileInfo(applyId,fileCode));
}
}

Loading…
Cancel
Save