feige
2024-10-24 4215ced06b40268e9f3c8ef6915998fbe64013b4
zhang-content/src/main/java/com/ruoyi/service/impl/ZPropertyShareServiceImpl.java
@@ -4,20 +4,23 @@
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.ZPropertyService;
import com.ruoyi.service.ZPropertyShareService;
import com.ruoyi.service.ZInfoUserService;
import com.ruoyi.service.*;
import com.ruoyi.service.ZPropertyShareService;
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;
@@ -28,12 +31,18 @@
public class ZPropertyShareServiceImpl extends ServiceImpl<ZfShareMapper,ZfShare> implements ZPropertyShareService {
    
    @Resource
    ZPropertyService zPropertyService;
    @Resource
    private ZInfoUserService zInfoUserService;
    @Resource
    private RestHighLevelClient restHighLevelClient;
    @Resource
    EsService esService;
    private LambdaQueryWrapper<ZfShare> uniqueCondition(ZfShare zfShare) {
        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
@@ -60,15 +69,13 @@
    }
    public void addData(ZfShare za)
    {
    public void addData(ZfShare za) {
        LambdaQueryWrapper<ZfShare> lqw = uniqueCondition(za);
        List<ZfShare> list = list(lqw);
        if(list.size()>0){
            throw new RuntimeException("请勿分享重复数据");
        }
        else {
        } else {
            save(za);
        }
@@ -124,8 +131,7 @@
        Long [] shareIds = shareMore.getShareIds();
        Long [] shareContents =  shareMore.getShareContents();
        for(Long shareId : shareIds)
            for(Long shareContent: shareContents)
            {
            for (Long shareContent : shareContents) {
                LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
                lqw.eq(ZfShare::getShareId,shareId)
                        .eq(ZfShare::getShareContent, shareContent)
@@ -185,9 +191,45 @@
        List<ZfShare> beanRecords = list(lqw);
        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, 2026L);
        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;
        }
    }
}