123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- package com.doc.biz.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.doc.biz.domain.DocInfo;
- import com.doc.biz.domain.DocRecent;
- import com.doc.biz.mapper.DocRecentMapper;
- import com.doc.biz.service.IDocInfoService;
- import com.doc.biz.service.IDocRecentService;
- import com.doc.common.utils.DateUtils;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.List;
- /**
- * 最近文件Service业务层处理
- *
- * @author wukai
- * @date 2023-08-15
- */
- @Service
- public class DocRecentServiceImpl implements IDocRecentService {
- @Resource
- private DocRecentMapper docRecentMapper;
- @Resource
- private IDocInfoService infoService;
- /**
- * 查询最近文件
- *
- * @param recentId 最近文件主键
- * @return 最近文件
- */
- @Override
- public DocRecent selectDocRecentByRecentId(Long recentId) {
- return docRecentMapper.selectDocRecentByRecentId(recentId);
- }
- /**
- * 查询最近文件列表
- *
- * @param docRecent 最近文件
- * @return 最近文件
- */
- @Override
- public List<DocRecent> selectDocRecentList(DocRecent docRecent) {
- if ("Y".equals(docRecent.getIsFolder())) {
- return docRecentMapper.selectFolderList(docRecent);
- } else if ("N".equals(docRecent.getIsFolder())) {
- return docRecentMapper.selectFileList(docRecent);
- } else {
- return docRecentMapper.selectDocRecentList(docRecent);
- }
- }
- /**
- * 新增最近文件
- *
- * @param docRecent 最近文件
- * @return 结果
- */
- @Override
- public int insertDocRecent(DocRecent docRecent) {
- docRecent.setCreateTime(DateUtils.getNowDate());
- QueryWrapper<DocRecent> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("is_folder", docRecent.getIsFolder());
- queryWrapper.eq("owner", docRecent.getOwner());
- queryWrapper.eq("rela_id", docRecent.getRelaId());
- docRecentMapper.delete(queryWrapper);
- return docRecentMapper.insertDocRecent(docRecent);
- }
- /**
- * @param uid 用户ID
- * @param fileId 文件ID
- * @return
- */
- @Override
- public int insertDocRecent(Long uid, String fileId) {
- DocInfo info = infoService.selectDocInfoByFileId(fileId);
- if (info != null) {
- //插入最近访问记录
- //如果info=null,则代表是查看历史版本文件,不需要记录
- DocRecent recent = new DocRecent();
- recent.setIsFolder("N");
- recent.setOwner(uid);
- recent.setRelaId(info.getDocId());
- return insertDocRecent(recent);
- }
- return 0;
- }
- /**
- * 修改最近文件
- *
- * @param docRecent 最近文件
- * @return 结果
- */
- @Override
- public int updateDocRecent(DocRecent docRecent) {
- docRecent.setUpdateTime(DateUtils.getNowDate());
- return docRecentMapper.updateDocRecent(docRecent);
- }
- /**
- * 批量删除最近文件
- *
- * @param recentIds 需要删除的最近文件主键
- * @return 结果
- */
- @Override
- public int deleteDocRecentByRecentIds(Long[] recentIds) {
- return docRecentMapper.deleteDocRecentByRecentIds(recentIds);
- }
- /**
- * 删除最近文件信息
- *
- * @param recentId 最近文件主键
- * @return 结果
- */
- @Override
- public int deleteDocRecentByRecentId(Long recentId) {
- return docRecentMapper.deleteDocRecentByRecentId(recentId);
- }
- /**
- * 删除最近文件信息
- *
- * @param isFolder 是否文件夹
- * @param realId 关联ID
- */
- @Override
- public void delete(String isFolder, Long realId) {
- QueryWrapper<DocRecent> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("is_folder", isFolder);
- queryWrapper.eq("rela_id", realId);
- docRecentMapper.delete(queryWrapper);
- }
- }
|