123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package com.wtkj.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.wtkj.entity.FileRead;
- import com.wtkj.mapper.FileReadMapper;
- import com.wtkj.service.IFileReadService;
- import lombok.AllArgsConstructor;
- import org.springblade.core.mp.base.BaseServiceImpl;
- import org.springblade.core.secure.utils.AuthUtil;
- import org.springblade.core.tool.api.R;
- import org.springblade.system.user.entity.User;
- import org.springblade.system.user.feign.IUserClient;
- import org.springframework.stereotype.Service;
- import org.springframework.util.CollectionUtils;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Set;
- import java.util.stream.Collectors;
- /**
- * @author Blizzard
- * @create at 2023-09-15 11:15
- * @describe
- */
- @Service
- @AllArgsConstructor
- public class FileReadServiceImpl extends BaseServiceImpl<FileReadMapper, FileRead> implements IFileReadService {
- private final IUserClient userClient;
- @Override
- public boolean readFile(FileRead read) {
- read.setUserId(AuthUtil.getUserId());
- return save(read);
- }
- @Override
- public List<FileRead> getByUser(Long userId) {
- return baseMapper.selectByFileIds(userId);
- }
- @Override
- public List<User> fileRead(String bladeFileId) {
- List<User> res = new ArrayList<>();
- List<Long> userIds = baseMapper.getReadUser(bladeFileId);
- if (!CollectionUtils.isEmpty(userIds)) {
- Set<User> users = userIds.stream().map(userClient::userInfoById).filter(userR1 -> userR1.isSuccess()).map(R::getData).collect(Collectors.toSet());
- res.addAll(users);
- }
- return res;
- }
- @Override
- public boolean isRead(String bladeFileId, Long userId) {
- boolean flag = false;
- LambdaQueryWrapper<FileRead> lqw = new LambdaQueryWrapper<>();
- lqw.eq(FileRead::getBladeFileId, bladeFileId);
- lqw.eq(FileRead::getUserId, userId);
- List<FileRead> list = this.list(lqw);
- if (!CollectionUtils.isEmpty(list)) {
- flag = true;
- }
- return flag;
- }
- }
|