zqy
2024-07-30 c35d9c6311b6f9ef75b49559a5c6db75e0a43ac6
zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java
@@ -1,6 +1,5 @@
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -10,7 +9,7 @@
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.*;
import com.ruoyi.mapper.ZfDoctorShareMapper;
import com.ruoyi.mapper.ZfShareMapper;
import com.ruoyi.service.ZInfoUserService;
import com.ruoyi.service.ZfDoctorService;
import com.ruoyi.service.ZfDoctorShareService;
@@ -27,26 +26,27 @@
@Slf4j
@Service
public class ZfDoctorShareServiceImpl extends ServiceImpl<ZfDoctorShareMapper, ZfDoctorShare> implements ZfDoctorShareService {
public class ZfDoctorShareServiceImpl extends ServiceImpl<ZfShareMapper, ZfShare> implements ZfDoctorShareService {
    @Resource
    private ZfDoctorService zfDoctorService;
    @Resource
    private ZInfoUserService zInfoUserService;
    private LambdaQueryWrapper<ZfDoctorShare> uniqueCondition(ZfDoctorShare zfDoctorShare) {
        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
        lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfDoctorShare.getShareId())), ZfDoctorShare::getShareId, zfDoctorShare.getShareId());
        lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfDoctorShare.getShareContent())), ZfDoctorShare::getShareContent, zfDoctorShare.getShareContent());
    private LambdaQueryWrapper<ZfShare> uniqueCondition(ZfShare zfShare) {
        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
        lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfShare.getShareId())), ZfShare::getShareId, zfShare.getShareId());
        lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfShare.getShareContent())), ZfShare::getShareContent, zfShare.getShareContent());
        lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfShare.getSysMenuId())), ZfShare::getSysMenuId, zfShare.getSysMenuId());
        return lqw;
    }
    @Override
    public List<ZfDoctorShare> getAuthority() {
    public List<ZfShare> getAuthority() {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        Long userId = user.getUserId();
        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ZfDoctorShare::getShareId,userId);
        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ZfShare::getShareId,userId);
        return list(lqw);
    }
@@ -54,10 +54,10 @@
    @Resource
    ZfDoctorShareService zfDoctorShareService;
    public void addData(ZfDoctorShare za)
    public void addData(ZfShare za)
    {
        LambdaQueryWrapper<ZfDoctorShare> lqw = uniqueCondition(za);
        List<ZfDoctorShare> list = list(lqw);
        LambdaQueryWrapper<ZfShare> lqw = uniqueCondition(za);
        List<ZfShare> list = list(lqw);
        if(list.size()>0){
            throw new RuntimeException("请勿分享重复数据");
@@ -76,10 +76,11 @@
        Long [] shareContents =  zfDoctor.getShareContents();
        for (Long shareId : shareIds) {
            for (Long shareContent : shareContents) {
                ZfDoctorShare za = new ZfDoctorShare();
                ZfShare za = new ZfShare();
                za.setUserId(getUserId());
                za.setShareContent(shareContent);
                za.setShareId(shareId);
                za.setSysMenuId(2019L);
                addData(za);
            }
        }
@@ -101,11 +102,12 @@
        List<ZfDoctor> beanRecord3 = new ArrayList<>();
        for (Long shareId : shareIds) {
            {
                LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
                lqw.eq(ZfDoctorShare::getShareId,shareId)
                        .eq(ZfDoctorShare::getUserId, getUserId());
                List<ZfDoctorShare> beanRecords = list(lqw);
                for (ZfDoctorShare beanRecord : beanRecords ) {
                LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
                lqw.eq(ZfShare::getShareId,shareId)
                    .eq(ZfShare::getSysMenuId,zfDoctor.getSysMenuId())
                        .eq(ZfShare::getUserId, getUserId());
                List<ZfShare> beanRecords = list(lqw);
                for (ZfShare beanRecord : beanRecords ) {
                    beanRecord3.add(zfDoctorService.getById(beanRecord.getShareContent()));
                }
            }
@@ -127,10 +129,11 @@
        for(Long shareId : shareIds)
            for(Long shareContent: shareContents)
            {
                LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
                lqw.eq(ZfDoctorShare::getShareId,shareId)
                        .eq(ZfDoctorShare::getShareContent, shareContent)
                        .eq(ZfDoctorShare::getUserId, getUserId());
                LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
                lqw.eq(ZfShare::getShareId,shareId)
                        .eq(ZfShare::getShareContent, shareContent)
                        .eq(ZfShare::getSysMenuId, zfDoctor.getSysMenuId())
                        .eq(ZfShare::getUserId, getUserId());
                zfDoctorShareService.remove(lqw);
                //   addData(za);
@@ -146,11 +149,12 @@
    public AjaxResult listByUserId() {
        //找到对应的赋予数据的用户以及数据内容
        HashMap<Long,List<ZfDoctor>>  bs = new HashMap<>();
        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ZfDoctorShare::getShareId,getUserId());
        List<ZfDoctorShare> beanRecords = list(lqw);
        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ZfShare::getShareId,getUserId());
        lqw.eq(ZfShare::getSysMenuId,2019L);
        List<ZfShare> beanRecords = list(lqw);
        List<ZfDoctor> b1 = new ArrayList<>();
        for (ZfDoctorShare beanRecord : beanRecords ) {
        for (ZfShare beanRecord : beanRecords ) {
                b1.add(zfDoctorService.getById(beanRecord.getShareContent()));
                bs.put(beanRecord.getUserId(),b1);
        }
@@ -165,10 +169,11 @@
    public AjaxResult listUserId(Integer pageNo ,Integer pageSize) {
        //找到对应的赋予数据的用户以及数据内容
        List<ZfDoctor>  bs = new ArrayList<>();
        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ZfDoctorShare::getShareId,getUserId());
        List<ZfDoctorShare> beanRecords = list(lqw);
        for (ZfDoctorShare beanRecord : beanRecords ) {
        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ZfShare::getShareId,getUserId());
        lqw.eq(ZfShare::getSysMenuId,2019L);
        List<ZfShare> beanRecords = list(lqw);
        for (ZfShare beanRecord : beanRecords ) {
            ZfDoctor bs2 = zfDoctorService.getById(beanRecord.getShareContent());
            bs2.setShareId(beanRecord.getUserId());
            bs.add(bs2);
@@ -189,11 +194,12 @@
    }
    @Override
    public Long getShareId(ZfDoctorDownload zfDoctorDownload){
        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ZfDoctorShare::getShareId,zfDoctorDownload.getDownloadId())
                .eq(ZfDoctorShare::getShareContent,zfDoctorDownload.getDownloadContent());
        List<ZfDoctorShare> beanRecords = list(lqw);
    public Long getShareId(ZfDownload zfDownload){
        LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ZfShare::getShareId, zfDownload.getDownloadId())
                .eq(ZfShare::getShareContent, zfDownload.getDownloadContent())
                .eq(ZfShare::getSysMenuId, zfDownload.getSysMenuId());
        List<ZfShare> beanRecords = list(lqw);
        if (beanRecords.size() != 0){
            return beanRecords.get(0).getUserId();
        }