| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.EsModel; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.mapper.ZfShareMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfCollectionService; |
| | | import com.ruoyi.service.ZfContactService; |
| | | import com.ruoyi.service.ZfContactShraService; |
| | | import com.ruoyi.service.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.elasticsearch.action.delete.DeleteRequest; |
| | | import org.elasticsearch.client.RequestOptions; |
| | | import org.elasticsearch.client.RestHighLevelClient; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | |
| | | @Resource |
| | | private ZInfoUserService zInfoUserService; |
| | | |
| | | @Resource |
| | | private RestHighLevelClient restHighLevelClient; |
| | | |
| | | @Resource |
| | | EsService esService; |
| | | |
| | | private LambdaQueryWrapper<ZfShare> uniqueCondition(ZfShare zfShare) { |
| | | LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); |
| | |
| | | Long userId = user.getUserId(); |
| | | |
| | | LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfShare::getShareId,userId); |
| | | lqw.eq(ZfShare::getShareId, userId); |
| | | |
| | | return list(lqw); |
| | | } |
| | | |
| | | public Long getUserId(){ |
| | | public Long getUserId() { |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | return myself.getUserId(); |
| | | |
| | | } |
| | | |
| | | public void addData(ZfShare za) |
| | | { |
| | | public void addData(ZfShare za) { |
| | | LambdaQueryWrapper<ZfShare> lqw = uniqueCondition(za); |
| | | List<ZfShare> list = list(lqw); |
| | | |
| | | if(list.size()>0){ |
| | | if (list.size() > 0) { |
| | | throw new RuntimeException("请勿分享重复数据"); |
| | | } |
| | | else { |
| | | } else { |
| | | save(za); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public AjaxResult saveZa(ShareMore shareMore) { |
| | | Long [] shareIds = shareMore.getShareIds(); |
| | | Long [] shareContents = shareMore.getShareContents(); |
| | | Long[] shareIds = shareMore.getShareIds(); |
| | | Long[] shareContents = shareMore.getShareContents(); |
| | | for (Long shareId : shareIds) { |
| | | for (Long shareContent : shareContents) { |
| | | ZfShare za = new ZfShare(); |
| | |
| | | |
| | | @Override |
| | | public AjaxResult listByFidAid(ShareMore shareMore, Integer pageNo, Integer pageSize) { |
| | | Long [] shareIds = shareMore.getShareIds(); |
| | | Long[] shareIds = shareMore.getShareIds(); |
| | | List<ZfContact> beanRecord3 = new ArrayList<>(); |
| | | for (Long shareId : shareIds) { |
| | | { |
| | | LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfShare::getShareId,shareId) |
| | | .eq(ZfShare::getSysMenuId,shareMore.getSysMenuId()) |
| | | lqw.eq(ZfShare::getShareId, shareId) |
| | | .eq(ZfShare::getSysMenuId, shareMore.getSysMenuId()) |
| | | .eq(ZfShare::getUserId, getUserId()); |
| | | List<ZfShare> beanRecords = list(lqw); |
| | | for (ZfShare beanRecord : beanRecords ) { |
| | | for (ZfShare beanRecord : beanRecords) { |
| | | beanRecord3.add(zfContactService.getById(beanRecord.getShareContent())); |
| | | } |
| | | } |
| | | } |
| | | List<ZfContact> record = beanRecord3.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList()); |
| | | List<ZfContact> record = beanRecord3.stream().skip((pageNo - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); |
| | | |
| | | int totalPage = (beanRecord3.size() -1) / pageSize +1; |
| | | int totalPage = (beanRecord3.size() - 1) / pageSize + 1; |
| | | |
| | | Page<ZfContact> zfContactPage = new Page<>(pageNo, pageSize,totalPage); |
| | | HashMap<String, Object> data = MapUtils.getShareResult(zfContactPage, record,beanRecord3.size()); |
| | | Page<ZfContact> zfContactPage = new Page<>(pageNo, pageSize, totalPage); |
| | | HashMap<String, Object> data = MapUtils.getShareResult(zfContactPage, record, beanRecord3.size()); |
| | | |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deleteZa(ShareMore shareMore) { |
| | | Long [] shareIds = shareMore.getShareIds(); |
| | | Long [] shareContents = shareMore.getShareContents(); |
| | | for(Long shareId : shareIds) |
| | | for(Long shareContent: shareContents) |
| | | { |
| | | Long[] shareIds = shareMore.getShareIds(); |
| | | Long[] shareContents = shareMore.getShareContents(); |
| | | for (Long shareId : shareIds) |
| | | for (Long shareContent : shareContents) { |
| | | LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfShare::getShareId,shareId) |
| | | lqw.eq(ZfShare::getShareId, shareId) |
| | | .eq(ZfShare::getShareContent, shareContent) |
| | | .eq(ZfShare::getSysMenuId, shareMore.getSysMenuId()) |
| | | .eq(ZfShare::getUserId, getUserId()); |
| | |
| | | |
| | | @Override |
| | | public AjaxResult listByUserId() { |
| | | HashMap<Long,List<ZfContact>> bs = new HashMap<>(); |
| | | HashMap<Long, List<ZfContact>> bs = new HashMap<>(); |
| | | LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfShare::getShareId,getUserId()); |
| | | lqw.eq(ZfShare::getSysMenuId,2021L); |
| | | lqw.eq(ZfShare::getShareId, getUserId()); |
| | | lqw.eq(ZfShare::getSysMenuId, 2021L); |
| | | List<ZfShare> beanRecords = list(lqw); |
| | | List<ZfContact> b1 = new ArrayList<>(); |
| | | for (ZfShare beanRecord : beanRecords ) { |
| | | for (ZfShare beanRecord : beanRecords) { |
| | | b1.add(zfContactService.getById(beanRecord.getShareContent())); |
| | | bs.put(beanRecord.getUserId(),b1); |
| | | bs.put(beanRecord.getUserId(), b1); |
| | | } |
| | | log.info("从数据库中查到的为:{}", bs); |
| | | return AjaxResult.success(bs); |
| | |
| | | |
| | | @Override |
| | | public AjaxResult listUserId(Integer pageNo, Integer pageSize) { |
| | | List<ZfContact> bs = new ArrayList<>(); |
| | | List<ZfContact> bs = new ArrayList<>(); |
| | | LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfShare::getShareId,getUserId()); |
| | | lqw.eq(ZfShare::getSysMenuId,2021L); |
| | | lqw.eq(ZfShare::getShareId, getUserId()); |
| | | lqw.eq(ZfShare::getSysMenuId, 2021L); |
| | | List<ZfShare> beanRecords = list(lqw); |
| | | for (ZfShare beanRecord : beanRecords ) { |
| | | for (ZfShare beanRecord : beanRecords) { |
| | | ZfContact bs2 = zfContactService.getById(beanRecord.getShareContent()); |
| | | bs2.setShareId(beanRecord.getUserId().intValue()); |
| | | bs.add(bs2); |
| | | } |
| | | log.info("从数据库中查到的为:{}", bs); |
| | | List<ZfContact> record = bs.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList()); |
| | | List<ZfContact> record = bs.stream().skip((pageNo - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); |
| | | |
| | | int totalPage = (bs.size() -1) / pageSize +1; |
| | | int totalPage = (bs.size() - 1) / pageSize + 1; |
| | | |
| | | Page<ZfContact> zfCollectionPage = new Page<>(pageNo, pageSize,totalPage); |
| | | HashMap<String, Object> data = MapUtils.getShareResult(zfCollectionPage, record,bs.size()); |
| | | Page<ZfContact> zfCollectionPage = new Page<>(pageNo, pageSize, totalPage); |
| | | HashMap<String, Object> data = MapUtils.getShareResult(zfCollectionPage, record, bs.size()); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | |
| | | .eq(ZfShare::getShareContent, zfDownload.getDownloadContent()) |
| | | .eq(ZfShare::getSysMenuId, zfDownload.getSysMenuId()); |
| | | List<ZfShare> beanRecords = list(lqw); |
| | | if (beanRecords.size() != 0){ |
| | | if (beanRecords.size() != 0) { |
| | | return beanRecords.get(0).getUserId(); |
| | | } |
| | | else { |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Boolean deleteByContentId(Long[] ids) { |
| | | List<Long> id = new ArrayList<>(); |
| | | |
| | | LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.in(ids != null, ZfShare::getShareContent, ids) |
| | | .eq(ZfShare::getSysMenuId, 2021L); |
| | | |
| | | List<ZfShare> zfShares = list(lqw); |
| | | if (zfShares.size() == 0) { |
| | | return true; |
| | | } |
| | | for (ZfShare zfShare : zfShares) { |
| | | id.add(zfShare.getId()); |
| | | } |
| | | |
| | | System.out.println(id); |
| | | if (removeByIds(id)) { |
| | | //删除es中的数据 |
| | | zfShares.forEach(zfDoctorDownload -> { |
| | | EsModel esModel = esService.findByCtId(zfDoctorDownload.getId().intValue(), "通讯录分享删除"); |
| | | if (esModel != null) { |
| | | DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId()); |
| | | System.out.println(deleteRequest); |
| | | try { |
| | | restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | }); |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |