| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.file.FileUploadDto; |
| | | import com.sandu.common.file.impl.AliOssFileServiceImpl; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.security.annotation.AnonymousAccess; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.LEDProgramFileParam; |
| | | import com.sandu.ximon.admin.service.LEDProgramFileService; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.service.FileOperationRecordService; |
| | | import com.sandu.ximon.admin.service.LedSFileService; |
| | | import com.sandu.ximon.dao.domain.LEDProgramFile; |
| | | import com.sandu.ximon.dao.domain.FileOperationRecord; |
| | | import com.sandu.ximon.dao.domain.LedSFile; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | @Slf4j |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/v1/file") |
| | | @RequestMapping("/v1/xixun/file") |
| | | public class LedSFileController { |
| | | |
| | | private final LedSFileService ledProgramFileService; |
| | | private final AliOssFileServiceImpl aliOssFileService; |
| | | private final FileOperationRecordService fileOperationRecordService; |
| | | private PermissionConfig permissionConfig; |
| | | |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addLEDProgram(@RequestParam("file") MultipartFile file) { |
| | | |
| | | |
| | | //return ResponseUtil.success(ledProgramFileService.addProgramFile(file)); |
| | | return ResponseUtil.success(aliOssFileService.uploadFile(file)); |
| | | return ResponseUtil.success(ledProgramFileService.addProgramFile(file)); |
| | | // return ResponseUtil.success(aliOssFileService.uploadFile(file)); |
| | | } |
| | | |
| | | /* @PostMapping("/delete/{fileId}") |
| | | @PostMapping("/delete/{fileId}") |
| | | public ResponseVO<Object> deleteLEDProgram(@PathVariable Long fileId) { |
| | | return ResponseUtil.success(ledProgramFileService.deleteFile(fileId)); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | public ResponseVO<Object> listfile(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | LambdaQueryWrapper<LEDProgramFile> wrapper = ledProgramFileService.listFile(); |
| | | if (null != keyword) { |
| | | wrapper.like(LEDProgramFile::getName, keyword); |
| | | if (!permissionConfig.check(MenuEnum.LED_FILE_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.successPage(ledProgramFileService.list(wrapper)); |
| | | }*/ |
| | | LambdaQueryWrapper<LedSFile> wrapper = ledProgramFileService.listFile(); |
| | | if (keyword != null && !keyword.isEmpty()) { |
| | | wrapper.like(LedSFile::getOriginName, keyword); |
| | | } |
| | | |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | return ResponseUtil.success(ledProgramFileService.list(wrapper)); |
| | | } |
| | | |
| | | @AnonymousAccess |
| | | @PostMapping("/uploading/{dateType}") |
| | | public ResponseVO<Object> uploadingFile(@RequestParam("file") MultipartFile file, @PathVariable Integer dateType) { |
| | | FileUploadDto fileUploadDto = aliOssFileService.uploadFile(file); |
| | | if ("mp4".equals(fileUploadDto.getFileType())) { |
| | | fileUploadDto.setScreenShot(fileUploadDto.getFileUrl() + "?x-oss-process=video/snapshot,t_10000,m_fast"); |
| | | } |
| | | FileOperationRecord fileOperationRecord = new FileOperationRecord(); |
| | | // if("mp4".equals(fileUploadDto.getFileType())){ |
| | | // fileUploadDto.setScreenShot(fileUploadDto.getFileUrl()+"?x-oss-process=video/snapshot,t_10000,m_fast"); |
| | | // } |
| | | BeanUtils.copyProperties(fileUploadDto, fileOperationRecord); |
| | | fileOperationRecord.setDataType(dateType); |
| | | fileOperationRecordService.save(fileOperationRecord); |
| | | return ResponseUtil.success(fileUploadDto); |
| | | } |
| | | |
| | | } |