文件上传修改
parent
05a3ac1707
commit
9010e1e205
|
|
@ -17,6 +17,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
@ -171,9 +172,15 @@ public class PersonnelPlanController extends AbstractCommonFileController{
|
|||
|
||||
List<PersonnelPlan> plans = util.importExcel(file.getInputStream());
|
||||
|
||||
return R.ok(plans);
|
||||
if (CollectionUtils.isNotEmpty(plans)) {
|
||||
boolean b = service.saveBatch(plans);
|
||||
if (!b) {
|
||||
throw new IllegalArgumentException("上传失败");
|
||||
}
|
||||
}
|
||||
|
||||
return R.ok(plans);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/download")
|
||||
|
|
|
|||
|
|
@ -49,12 +49,12 @@ public interface FileAssociationsMapper extends BaseMapper<FileAssociations> {
|
|||
fa.del = '1'
|
||||
AND fa.business_id = #{businessId}
|
||||
AND fa."table_name" = #{tableName}
|
||||
AND fa.type = #{type}
|
||||
AND fd.group_id = #{tableName}
|
||||
AND fd.type = #{type}
|
||||
ORDER BY fa.tm desc
|
||||
</script>
|
||||
""")
|
||||
List<FileAssociations> getFiles(@Param("tableName") String tableName,@Param("businessId") String businessId,@Param("type") String type);
|
||||
List<FileAssociations> getFiles1(@Param("tableName") String tableName,@Param("businessId") String businessId,@Param("type") String type);
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.gunshi.project.xyt.mapper.FileAssociationsMapper;
|
|||
import com.gunshi.project.xyt.model.FileAssociations;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -90,6 +91,7 @@ public class FileAssociationsService extends ServiceImpl<FileAssociationsMapper,
|
|||
public void saveFile(List<FileAssociations> files, String tableName, String businessId, String type) {
|
||||
if (CollectionUtils.isEmpty(files)) {
|
||||
log.info("fileIds is null!");
|
||||
files = Lists.newArrayList();
|
||||
}
|
||||
|
||||
// 查询是否添加
|
||||
|
|
@ -210,7 +212,7 @@ public class FileAssociationsService extends ServiceImpl<FileAssociationsMapper,
|
|||
|
||||
@Cacheable(value = THIS_REDIS_KEY, key = "#p0 +':'+ #p1 +':'+ #p2", unless = "false")
|
||||
public List<FileAssociations> getFiles(String tName, String bId,String num) {
|
||||
return this.baseMapper.getFiles(tName,bId,num);
|
||||
return this.baseMapper.getFiles1(tName,bId,num);
|
||||
}
|
||||
|
||||
public void save(List<FileAssociations> attachList,String businessId, String tableName,String type) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue