| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.config.FileUploadConfig; |
| | | import com.ruoyi.common.core.controller.FileController; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.*; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 数据统计面板 前端控制器 |
| | |
| | | @Autowired |
| | | private WorkPresentationService workPresentationService; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | private FileUploadConfig fileUploadConfig; |
| | | |
| | | @ApiOperation(value = "单文件上传", notes = "单文件上传,rename 默认不重命名") |
| | | @PostMapping(value = "upload", headers = "content-type=multipart/form-data") |
| | | public R<?> uploadImageMany(@RequestParam(value = "file") MultipartFile mf) throws IOException { |
| | | if (mf.isEmpty()) { |
| | | return R.fail("请传入文件!"); |
| | | } |
| | | String TimeDir =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | // String realPath = fileUploadConfig.getLocation() + TimeDir; |
| | | String realPath = "F:\\file\\estate\\files"; |
| | | File file = new File(realPath); |
| | | |
| | | // 没有目录就创建 |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | // 获取文件名称 |
| | | String filename = mf.getOriginalFilename(); |
| | | String originalFilename=filename; |
| | | // 获取文件后缀 |
| | | String ext = filename.substring(filename.lastIndexOf("."), filename.length()); |
| | | // 检查文件类型 |
| | | if (!fileUploadConfig.getAllowExt().contains(ext)) { |
| | | return R.fail("上传文件格式不正确,仅支持" + fileUploadConfig.getAllowExt()); |
| | | } |
| | | filename = UUID.randomUUID()+ ext; |
| | | File targetFile = new File(realPath, filename);//目标文件 |
| | | |
| | | // 获取文件的大小size |
| | | long size = mf.getSize(); |
| | | System.out.println(size); |
| | | //开始从源文件拷贝到目标文件 |
| | | //传图片一步到位 |
| | | mf.transferTo(targetFile); |
| | | //拼接数据 |
| | | // String imgstr = fileUploadConfig.getAccessPath() + TimeDir +"\\"+ filename; |
| | | filename = filename.substring(0, filename.lastIndexOf(".")); |
| | | |
| | | UserFile userFile = new UserFile(); |
| | | userFile.setName(filename); |
| | | userFile.setContentType(mf.getContentType()); |
| | | String s = ext.replaceAll("\\.", ""); |
| | | userFile.setExtension(s); |
| | | userFile.setSize(size); |
| | | userFile.setOriginFileName(originalFilename); |
| | | userFile.setCreateTime(new Date()); |
| | | userFile.setDeleted(false); |
| | | userFile.setUpdateTime(userFile.getCreateTime()); |
| | | userFile.insert(); |
| | | |
| | | |
| | | return R.ok(filename); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取工作展示列表",response = WorkPresentation.class) |
| | |
| | | |
| | | LambdaQueryWrapper<WorkPresentation> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(WorkPresentation::getClientId,query.getClientId()); |
| | | wrapper.eq(WorkPresentation::getState, 1); |
| | | if(query.getState()!=null){ |
| | | wrapper.eq(WorkPresentation::getState, query.getState()); |
| | | } |
| | | if(query.getType()!=null){ |
| | | wrapper.eq(WorkPresentation::getType, query.getType()); |
| | | } |