| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.execption.BusinessException; |
| | |
| | | import com.sandu.common.file.impl.AliOssFileServiceImpl; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils; |
| | | import com.sandu.ximon.dao.domain.FileOperationRecord; |
| | | import com.sandu.ximon.dao.domain.LedSFile; |
| | | import com.sandu.ximon.dao.mapper.LedSFileMapper; |
| | |
| | | private final LedSFileMapper ledSFileMapper; |
| | | private final AliOssFileServiceImpl aliOssFileService; |
| | | private final FileOperationRecordService fileOperationRecordService; |
| | | private final ClientService clientService; |
| | | |
| | | public boolean addProgramFile(MultipartFile file) { |
| | | FileUploadDto fileUploadDto = aliOssFileService.uploadFile(file); |
| | | if("mp4".equals(fileUploadDto.getFileType())){ |
| | | fileUploadDto.setScreenShot(fileUploadDto.getFileUrl()+"?x-oss-process=video/snapshot,t_10000,m_fast"); |
| | | 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())){ |
| | | fileOperationRecord.setScreenShot(fileUploadDto.getFileUrl()+"?x-oss-process=video/snapshot,t_10000,m_fast"); |
| | | FileOperationRecord fileOperationRecord = new FileOperationRecord(); |
| | | if ("mp4".equals(fileUploadDto.getFileType())) { |
| | | fileOperationRecord.setScreenShot(fileUploadDto.getFileUrl() + "?x-oss-process=video/snapshot,t_10000,m_fast"); |
| | | } |
| | | BeanUtils.copyProperties(fileUploadDto, fileOperationRecord); |
| | | fileOperationRecordService.save(fileOperationRecord); |
| | |
| | | BeanUtils.copyProperties(fileUploadDto, sFile); |
| | | sFile.setCilentId(SecurityUtils.getClientId()); |
| | | if (SecurityUtils.getClientId() != null) { |
| | | sFile.setUserId(SecurityUtils.getUserId()); |
| | | sFile.setUserName(SecurityUtils.getUsername()); |
| | | if (clientService.findClientId()) { |
| | | sFile.setCilentId(clientService.getClientId()); |
| | | } |
| | | } |
| | | // save(sFile); |
| | | /** |
| | | * 熙汛文件上传 日志记录开始 |
| | | */ |
| | | String content = "文件内容:"+ JSON.toJSONString(fileUploadDto); |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "熙汛文件上传", content); |
| | | /** |
| | | * 熙汛文件上传 日志记录结束 |
| | | */ |
| | | return save(sFile); |
| | | // return fileUploadDto; |
| | | } |
| | | |
| | | public boolean deleteFile(Long id) { |
| | |
| | | if (byId == null) { |
| | | throw new BusinessException("未找到该节目"); |
| | | } |
| | | |
| | | /** |
| | | * 熙汛文件删除 日志记录开始 |
| | | */ |
| | | String content = "文件内容id:"+ id+"文件内容:"+ JSON.toJSONString(byId); |
| | | StoreOperationRecordsUtils.storeOperationData(null, null, "熙汛文件删除", content); |
| | | /** |
| | | * 熙汛文件删除 日志记录结束 |
| | | */ |
| | | return removeById(id); |
| | | } |
| | | |
| | | public LambdaQueryWrapper<LedSFile> listFile(){ |
| | | public LambdaQueryWrapper<LedSFile> listFile() { |
| | | LambdaQueryWrapper<LedSFile> ledProgramFileLambdaQueryWrapper = Wrappers.lambdaQuery(LedSFile.class); |
| | | if(SecurityUtils.getClientId()!=null){ |
| | | return ledProgramFileLambdaQueryWrapper.eq(LedSFile::getCilentId,SecurityUtils.getUserId()); |
| | | }else { |
| | | if (SecurityUtils.getClientId() != null) { |
| | | return ledProgramFileLambdaQueryWrapper.eq(LedSFile::getCilentId, SecurityUtils.getUserId()).or(w -> { |
| | | w.eq(LedSFile::getUserId, SecurityUtils.getUserId()); |
| | | }); |
| | | } else { |
| | | return ledProgramFileLambdaQueryWrapper; |
| | | } |
| | | |