use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project kms by mahonelau.
the class SysAnnouncementSendController method readAll.
/**
* @功能:一键已读
* @return
*/
@PutMapping(value = "/readAll")
public Result<SysAnnouncementSend> readAll() {
Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = sysUser.getId();
LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda();
updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
updateWrapper.last("where user_id ='" + userId + "'");
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
sysAnnouncementSendService.update(announcementSend, updateWrapper);
result.setSuccess(true);
result.setMessage("全部已读");
return result;
}
use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project kms by mahonelau.
the class SysAnnouncementSendController method editById.
/**
* @功能:更新用户系统消息阅读状态
* @param json
* @return
*/
@PutMapping(value = "/editByAnntIdAndUserId")
public Result<SysAnnouncementSend> editById(@RequestBody JSONObject json) {
Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
String anntId = json.getString("anntId");
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String userId = sysUser.getId();
LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda();
updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
updateWrapper.last("where annt_id ='" + anntId + "' and user_id ='" + userId + "'");
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
sysAnnouncementSendService.update(announcementSend, updateWrapper);
result.setSuccess(true);
return result;
}
use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project RuoYi-Vue-Plus by JavaLionLi.
the class SysOssConfigServiceImpl method updateOssConfigStatus.
/**
* 启用禁用状态
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int updateOssConfigStatus(SysOssConfigBo bo) {
SysOssConfig sysOssConfig = BeanUtil.toBean(bo, SysOssConfig.class);
int row = baseMapper.update(null, new LambdaUpdateWrapper<SysOssConfig>().set(SysOssConfig::getStatus, "1"));
row += baseMapper.updateById(sysOssConfig);
if (row > 0) {
RedisUtils.setCacheObject(OssConstant.CACHE_CONFIG_KEY, sysOssConfig.getConfigKey());
}
return row;
}
use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project qiwen-file by qiwenshare.
the class OfficeController method IndexServlet.
@RequestMapping(value = "/IndexServlet", method = RequestMethod.POST)
@ResponseBody
public void IndexServlet(HttpServletResponse response, HttpServletRequest request) throws IOException {
String token = request.getParameter("token");
Long userId = userService.getUserIdByToken(token);
if (userId == null) {
throw new NotLoginException();
}
PrintWriter writer = response.getWriter();
Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");
String body = scanner.hasNext() ? scanner.next() : "";
JSONObject jsonObj = JSON.parseObject(body);
log.info("===saveeditedfile:" + jsonObj.get("status"));
;
String status = jsonObj != null ? jsonObj.get("status").toString() : "";
if ("2".equals(status) || "6".equals(status)) {
String type = request.getParameter("type");
String downloadUri = (String) jsonObj.get("url");
if ("edit".equals(type)) {
// 修改报告
String userFileId = request.getParameter("userFileId");
UserFile userFile = userFileService.getById(userFileId);
FileBean fileBean = fileService.getById(userFile.getFileId());
Long pointCount = fileService.getFilePointCount(userFile.getFileId());
if (pointCount > 1) {
// 该场景,暂不支持编辑修改
writer.write("{\"error\":1}");
return;
}
URL url = new URL(downloadUri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
int fileLength = 0;
try {
InputStream stream = connection.getInputStream();
Writer writer1 = ufopFactory.getWriter(fileBean.getStorageType());
WriteFile writeFile = new WriteFile();
writeFile.setFileUrl(fileBean.getFileUrl());
writeFile.setFileSize(connection.getContentLength());
writer1.write(stream, writeFile);
} catch (Exception e) {
log.error(e.getMessage());
} finally {
if ("2".equals(status)) {
LambdaUpdateWrapper<UserFile> userFileUpdateWrapper = new LambdaUpdateWrapper<>();
userFileUpdateWrapper.set(UserFile::getUploadTime, DateUtil.getCurrentTime()).eq(UserFile::getUserFileId, userFileId);
userFileService.update(userFileUpdateWrapper);
}
LambdaUpdateWrapper<FileBean> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
fileLength = connection.getContentLength();
log.info("当前修改文件大小为:" + Long.valueOf(fileLength));
DownloadFile downloadFile = new DownloadFile();
downloadFile.setFileUrl(fileBean.getFileUrl());
InputStream inputStream = ufopFactory.getDownloader(fileBean.getStorageType()).getInputStream(downloadFile);
String md5Str = DigestUtils.md5Hex(inputStream);
lambdaUpdateWrapper.set(FileBean::getIdentifier, md5Str).set(FileBean::getFileSize, Long.valueOf(fileLength)).set(FileBean::getModifyTime, DateUtil.getCurrentTime()).set(FileBean::getModifyUserId, userId).eq(FileBean::getFileId, fileBean.getFileId());
fileService.update(lambdaUpdateWrapper);
connection.disconnect();
}
}
}
if ("3".equals(status) || "7".equals(status)) {
// 不强制手动保存时为6,"6".equals(status)
log.debug("====保存失败:");
writer.write("{\"error\":1}");
} else {
log.debug("状态为:0");
writer.write("{\"error\":" + "0" + "}");
}
}
use of com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper in project qiwen-file by qiwenshare.
the class FiletransferService method uploadFile.
@Override
public void uploadFile(HttpServletRequest request, UploadFileDTO uploadFileDto, Long userId) {
UploadFile uploadFile = new UploadFile();
uploadFile.setChunkNumber(uploadFileDto.getChunkNumber());
uploadFile.setChunkSize(uploadFileDto.getChunkSize());
uploadFile.setTotalChunks(uploadFileDto.getTotalChunks());
uploadFile.setIdentifier(uploadFileDto.getIdentifier());
uploadFile.setTotalSize(uploadFileDto.getTotalSize());
uploadFile.setCurrentChunkSize(uploadFileDto.getCurrentChunkSize());
Uploader uploader = ufopFactory.getUploader();
if (uploader == null) {
log.error("上传失败,请检查storageType是否配置正确");
throw new UploadException("上传失败");
}
List<UploadFileResult> uploadFileResultList;
try {
uploadFileResultList = uploader.upload(request, uploadFile);
} catch (Exception e) {
log.error("上传失败,请检查UFOP连接配置是否正确");
throw new UploadException("上传失败");
}
for (int i = 0; i < uploadFileResultList.size(); i++) {
UploadFileResult uploadFileResult = uploadFileResultList.get(i);
FileBean fileBean = new FileBean();
BeanUtil.copyProperties(uploadFileDto, fileBean);
String relativePath = uploadFileDto.getRelativePath();
if (UploadFileStatusEnum.SUCCESS.equals(uploadFileResult.getStatus())) {
fileBean.setFileUrl(uploadFileResult.getFileUrl());
fileBean.setFileSize(uploadFileResult.getFileSize());
fileBean.setStorageType(uploadFileResult.getStorageType().getCode());
fileBean.setFileStatus(1);
fileBean.setCreateTime(DateUtil.getCurrentTime());
fileBean.setCreateUserId(userId);
fileMapper.insert(fileBean);
UserFile userFile = new UserFile();
if (relativePath.contains("/")) {
userFile.setFilePath(uploadFileDto.getFilePath() + UFOPUtils.getParentPath(relativePath) + "/");
fileDealComp.restoreParentFilePath(uploadFileDto.getFilePath() + UFOPUtils.getParentPath(relativePath) + "/", userId);
fileDealComp.deleteRepeatSubDirFile(uploadFileDto.getFilePath(), userId);
} else {
userFile.setFilePath(uploadFileDto.getFilePath());
}
userFile.setUserId(userId);
userFile.setFileName(uploadFileResult.getFileName());
userFile.setExtendName(uploadFileResult.getExtendName());
userFile.setDeleteFlag(0);
userFile.setIsDir(0);
List<UserFile> userFileList = userFileMapper.selectList(new QueryWrapper<>(userFile));
if (userFileList.size() > 0) {
String fileName = fileDealComp.getRepeatFileName(userFile, userFile.getFilePath());
userFile.setFileName(fileName);
}
userFile.setFileId(fileBean.getFileId());
userFile.setUploadTime(DateUtil.getCurrentTime());
userFileMapper.insert(userFile);
fileDealComp.uploadESByUserFileId(userFile.getUserFileId());
LambdaQueryWrapper<UploadTaskDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UploadTaskDetail::getIdentifier, uploadFileDto.getIdentifier());
uploadTaskDetailMapper.delete(lambdaQueryWrapper);
LambdaUpdateWrapper<UploadTask> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(UploadTask::getUploadStatus, UploadFileStatusEnum.SUCCESS.getCode()).eq(UploadTask::getIdentifier, uploadFileDto.getIdentifier());
uploadTaskMapper.update(null, lambdaUpdateWrapper);
try {
if (UFOPUtils.isImageFile(uploadFileResult.getExtendName())) {
BufferedImage src = uploadFileResult.getBufferedImage();
Image image = new Image();
image.setImageWidth(src.getWidth());
image.setImageHeight(src.getHeight());
image.setFileId(fileBean.getFileId());
imageMapper.insert(image);
}
} catch (Exception e) {
log.error("生成图片缩略图失败!");
}
} else if (UploadFileStatusEnum.UNCOMPLATE.equals(uploadFileResult.getStatus())) {
UploadTaskDetail uploadTaskDetail = new UploadTaskDetail();
uploadTaskDetail.setFilePath(uploadFileDto.getFilePath());
if (relativePath.contains("/")) {
uploadTaskDetail.setFilePath(uploadFileDto.getFilePath() + UFOPUtils.getParentPath(relativePath) + "/");
} else {
uploadTaskDetail.setFilePath(uploadFileDto.getFilePath());
}
uploadTaskDetail.setFilename(uploadFileDto.getFilename());
uploadTaskDetail.setChunkNumber(uploadFileDto.getChunkNumber());
uploadTaskDetail.setChunkSize((int) uploadFileDto.getChunkSize());
uploadTaskDetail.setRelativePath(uploadFileDto.getRelativePath());
uploadTaskDetail.setTotalChunks(uploadFileDto.getTotalChunks());
uploadTaskDetail.setTotalSize((int) uploadFileDto.getTotalSize());
uploadTaskDetail.setIdentifier(uploadFileDto.getIdentifier());
uploadTaskDetailMapper.insert(uploadTaskDetail);
} else if (UploadFileStatusEnum.FAIL.equals(uploadFileResult.getStatus())) {
LambdaQueryWrapper<UploadTaskDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UploadTaskDetail::getIdentifier, uploadFileDto.getIdentifier());
uploadTaskDetailMapper.delete(lambdaQueryWrapper);
LambdaUpdateWrapper<UploadTask> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(UploadTask::getUploadStatus, UploadFileStatusEnum.FAIL.getCode()).eq(UploadTask::getIdentifier, uploadFileDto.getIdentifier());
uploadTaskMapper.update(null, lambdaUpdateWrapper);
}
}
}
Aggregations