Search in sources :

Example 21 with LambdaUpdateWrapper

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;
}
Also used : SysAnnouncementSend(org.jeecg.modules.system.entity.SysAnnouncementSend) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) LoginUser(org.jeecg.common.system.vo.LoginUser) Date(java.util.Date) Result(org.jeecg.common.api.vo.Result) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 22 with LambdaUpdateWrapper

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;
}
Also used : SysAnnouncementSend(org.jeecg.modules.system.entity.SysAnnouncementSend) UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) LoginUser(org.jeecg.common.system.vo.LoginUser) Date(java.util.Date) Result(org.jeecg.common.api.vo.Result) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 23 with LambdaUpdateWrapper

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;
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) SysOssConfig(com.ruoyi.system.domain.SysOssConfig) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with LambdaUpdateWrapper

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" + "}");
    }
}
Also used : Scanner(java.util.Scanner) WriteFile(com.qiwenshare.ufop.operation.write.domain.WriteFile) DownloadFile(com.qiwenshare.ufop.operation.download.domain.DownloadFile) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) URL(java.net.URL) IOException(java.io.IOException) NotLoginException(com.qiwenshare.common.exception.NotLoginException) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) HttpURLConnection(java.net.HttpURLConnection) JSONObject(com.alibaba.fastjson.JSONObject) NotLoginException(com.qiwenshare.common.exception.NotLoginException) UserFile(com.qiwenshare.file.domain.UserFile) FileBean(com.qiwenshare.file.domain.FileBean) Writer(com.qiwenshare.ufop.operation.write.Writer) PrintWriter(java.io.PrintWriter) PrintWriter(java.io.PrintWriter)

Example 25 with LambdaUpdateWrapper

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);
        }
    }
}
Also used : UploadException(com.qiwenshare.ufop.exception.operation.UploadException) BufferedImage(java.awt.image.BufferedImage) UploadException(com.qiwenshare.ufop.exception.operation.UploadException) DownloadException(com.qiwenshare.ufop.exception.operation.DownloadException) BufferedImage(java.awt.image.BufferedImage) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) UploadFile(com.qiwenshare.ufop.operation.upload.domain.UploadFile) UploadFileResult(com.qiwenshare.ufop.operation.upload.domain.UploadFileResult) Uploader(com.qiwenshare.ufop.operation.upload.Uploader)

Aggregations

LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)47 Transactional (org.springframework.transaction.annotation.Transactional)11 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)10 Date (java.util.Date)7 Result (org.jeecg.common.api.vo.Result)6 LoginUser (org.jeecg.common.system.vo.LoginUser)6 SysAnnouncementSend (org.jeecg.modules.system.entity.SysAnnouncementSend)6 Test (org.junit.jupiter.api.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 PutMapping (org.springframework.web.bind.annotation.PutMapping)6 OrderItem (cn.lili.modules.order.order.entity.dos.OrderItem)5 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)5 User (com.maxqiu.demo.entity.User)5 DateTime (cn.hutool.core.date.DateTime)4 UserFile (com.qiwenshare.file.domain.UserFile)4 ServiceException (cn.lili.common.exception.ServiceException)3 Order (cn.lili.modules.order.order.entity.dos.Order)3 SysOssConfig (com.ruoyi.system.domain.SysOssConfig)3 DistributionOrder (cn.lili.modules.distribution.entity.dos.DistributionOrder)2 GoodsSku (cn.lili.modules.goods.entity.dos.GoodsSku)2