| | |
| | | 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.github.pagehelper.PageHelper; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.file.FileUploadDto; |
| | | import com.sandu.common.file.impl.AliOssFileServiceImpl; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | 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; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author liuhaonan |
| | |
| | | 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); |
| | | FileOperationRecord fileOperationRecord=new FileOperationRecord(); |
| | | 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"); |
| | | } |
| | | BeanUtils.copyProperties(fileUploadDto, fileOperationRecord); |
| | | fileOperationRecordService.save(fileOperationRecord); |
| | | LedSFile sFile = new LedSFile(); |
| | | BeanUtils.copyProperties(fileUploadDto, sFile); |
| | | sFile.setCilentId(SecurityUtils.getClientId()); |
| | | if (SecurityUtils.getClientId() != null) { |
| | | sFile.setUserName(SecurityUtils.getUsername()); |
| | | 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(){ |
| | | LambdaQueryWrapper<LedSFile> ledProgramFileLambdaQueryWrapper = Wrappers.lambdaQuery(LedSFile.class); |
| | | if(SecurityUtils.getClientId()!=null){ |
| | | return ledProgramFileLambdaQueryWrapper.eq(LedSFile::getCilentId,SecurityUtils.getUserId()); |
| | | }else { |
| | | return ledProgramFileLambdaQueryWrapper; |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param baseConditionVO |
| | | * @param keyword |
| | | * @return |
| | | */ |
| | | public List<LedSFile> listfile(BaseConditionVO baseConditionVO, String keyword) { |
| | | LambdaQueryWrapper<LedSFile> wrapper = Wrappers.lambdaQuery(LedSFile.class); |
| | | if (SecurityUtils.getClientId() != null) { |
| | | wrapper.eq(LedSFile::getCilentId, SecurityUtils.getUserId()).or(w -> { |
| | | w.eq(LedSFile::getUserId, SecurityUtils.getUserId()); |
| | | }); |
| | | } |
| | | |
| | | if (keyword != null && !keyword.isEmpty()) { |
| | | wrapper.like(LedSFile::getOriginName, keyword); |
| | | } |
| | | |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | return list(wrapper); |
| | | } |
| | | |
| | | } |