| | |
| | | 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.mapper.ZfShareMapper; |
| | | 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; |
| | |
| | | |
| | | @Slf4j |
| | | @Service |
| | | |
| | | public class ZfCollectionShaServiceImpl extends ServiceImpl<ZfShareMapper, ZfShare> implements ZfCollectionShareService { |
| | | |
| | | |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private ZInfoUserService zInfoUserService; |
| | | @Resource |
| | | private RestHighLevelClient restHighLevelClient; |
| | | |
| | | @Resource |
| | | EsService esService; |
| | | |
| | | private LambdaQueryWrapper<ZfShare> uniqueCondition(ZfShare zfShare) { |
| | | LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); |
| | |
| | | za.setUserId(getUserId()); |
| | | za.setShareContent(shareContent); |
| | | za.setShareId(shareId); |
| | | |
| | | za.setSysMenuId(2018L); |
| | | |
| | | |
| | | addData(za); |
| | | } |
| | | } |
| | |
| | | |
| | | int totalPage = (beanRecord3.size() -1) / pageSize +1; |
| | | |
| | | |
| | | Page<ZfCollection> zfCollectionPage = new Page<>(pageNo, pageSize,totalPage); |
| | | HashMap<String, Object> data = MapUtils.getShareResult(zfCollectionPage, record,beanRecord3.size()); |
| | | |
| | | |
| | | |
| | | |
| | | return AjaxResult.success(data); |
| | | } |
| | |
| | | HashMap<Long,List<ZfCollection>> bs = new HashMap<>(); |
| | | LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfShare::getShareId,getUserId()); |
| | | |
| | | lqw.eq(ZfShare::getSysMenuId,2018L); |
| | | |
| | | |
| | | List<ZfShare> beanRecords = list(lqw); |
| | | List<ZfCollection> b1 = new ArrayList<>(); |
| | | for (ZfShare beanRecord : beanRecords ) { |
| | |
| | | List<ZfCollection> bs = new ArrayList<>(); |
| | | LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfShare::getShareId,getUserId()); |
| | | |
| | | lqw.eq(ZfShare::getSysMenuId,2018L); |
| | | |
| | | List<ZfShare> beanRecords = list(lqw); |
| | | for (ZfShare beanRecord : beanRecords ) { |
| | | ZfCollection bs2 = zfCollectionService.getById(beanRecord.getShareContent()); |
| | |
| | | |
| | | int totalPage = (bs.size() -1) / pageSize +1; |
| | | |
| | | |
| | | Page<ZfCollection> zfCollectionPage = new Page<>(pageNo, pageSize,totalPage); |
| | | |
| | | |
| | | HashMap<String, Object> data = MapUtils.getShareResult(zfCollectionPage, record,bs.size()); |
| | | return AjaxResult.success(data); |
| | | } |
| | |
| | | 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, 2018L); |
| | | |
| | | 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; |
| | | } |
| | | |
| | | } |
| | | } |