From 8a7e33332203a2e1334ba55a4838b6b1060d406c Mon Sep 17 00:00:00 2001 From: feige <791364011@qq.com> Date: 星期二, 11 六月 2024 22:14:05 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 176 insertions(+), 0 deletions(-) diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java new file mode 100644 index 0000000..cef2d83 --- /dev/null +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java @@ -0,0 +1,176 @@ +package com.ruoyi.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.domain.ShareMore; +import com.ruoyi.domain.ZInfoUser; +import com.ruoyi.domain.ZfDoctor; +import com.ruoyi.domain.ZfDoctorShare; +import com.ruoyi.mapper.ZfDoctorShareMapper; +import com.ruoyi.service.ZInfoUserService; +import com.ruoyi.service.ZfDoctorService; +import com.ruoyi.service.ZfDoctorShareService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +@Slf4j +@Service +public class ZfDoctorShareServiceImpl extends ServiceImpl<ZfDoctorShareMapper, ZfDoctorShare> 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()); + return lqw; + } + @Override + public List<ZfDoctorShare> getAuthority() { + SysUser user = SecurityUtils.getLoginUser().getUser(); + Long userId = user.getUserId(); + + LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZfDoctorShare::getShareId,userId); + + return list(lqw); + } + + @Resource + ZfDoctorShareService zfDoctorShareService; + + public void addData(ZfDoctorShare za) + { + LambdaQueryWrapper<ZfDoctorShare> lqw = uniqueCondition(za); + List<ZfDoctorShare> list = list(lqw); + + if(list.size()>0){ + throw new RuntimeException("璇峰嬁鍒嗕韩閲嶅鏁版嵁"); + } + else { + zfDoctorShareService.save(za); + } + + } + + + @Override + public AjaxResult saveZa(ShareMore zfDoctor) { + // boolean bl = zAuthorityService.saveOrUpdate(zAuthority); + Long [] shareIds = zfDoctor.getShareIds(); + Long [] shareContents = zfDoctor.getShareContents(); + for (Long shareId : shareIds) { + for (Long shareContent : shareContents) { + ZfDoctorShare za = new ZfDoctorShare(); + za.setUserId(getUserId()); + za.setShareContent(shareContent); + za.setShareId(shareId); + addData(za); + } + } + // Long [] + // if(bl) + return AjaxResult.success("鍒嗕韩鎴愬姛!"); + // else + // return AjaxResult.error("鏉冮檺鏂板澶辫触锛�"); + + + } + /** + * 鏍规嵁UserId鍜屽垎浜汉shareId鏌ョ湅宸茬粡鎺堟潈缁欓偅浜涗汉閭d簺鏁版嵁 + */ + @Override + public AjaxResult listByFidAid(ShareMore zfDoctor) { + //鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭 + Long [] shareIds = zfDoctor.getShareIds(); + 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 ) { + beanRecord3.add(zfDoctorService.getById(beanRecord.getShareContent())); + } + } + } + log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", beanRecord3); + + return AjaxResult.success(beanRecord3); + } + + @Override + public AjaxResult deleteZa(ShareMore zfDoctor) { + Long [] shareIds = zfDoctor.getShareIds(); + Long [] shareContents = zfDoctor.getShareContents(); + 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()); + + zfDoctorShareService.remove(lqw); + // addData(za); + } + return AjaxResult.success("鏁版嵁鏀跺洖鎴愬姛!"); + + } + + /** + * 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹拰鍒嗕韩浜� + */ + @Override + public AjaxResult listByUserId() { + //鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭 + HashMap<Long,ZfDoctor> bs = new HashMap<>(); + LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZfDoctorShare::getShareId,getUserId()); + List<ZfDoctorShare> beanRecords = list(lqw); + for (ZfDoctorShare beanRecord : beanRecords ) { + bs.put(beanRecord.getUserId(),zfDoctorService.getById(beanRecord.getShareContent())); + } + log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", bs); + return AjaxResult.success(bs); + + } + /** + * 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹� + */ + @Override + public List<ZfDoctor> listUserId(Long shareId) { + //鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭 + List<ZfDoctor> bs = new ArrayList<>(); + LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZfDoctorShare::getShareId,shareId); + List<ZfDoctorShare> beanRecords = list(lqw); + for (ZfDoctorShare beanRecord : beanRecords ) { + ZfDoctor bs2 = zfDoctorService.getById(beanRecord.getShareContent()); + bs2.setShareId(beanRecord.getUserId()); + bs.add(bs2); + } + log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", bs); + return bs; + + } + public Long getUserId(){ + ZInfoUser myself = zInfoUserService.getMyself(); + return myself.getUserId(); + + } + +} -- Gitblit v1.9.1