feige
2024-06-11 8a7e33332203a2e1334ba55a4838b6b1060d406c
Merge remote-tracking branch 'origin/master'
2个文件已修改
6个文件已添加
3个文件已删除
503 ■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZDictController.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/MapUtils.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/domain/ShareMore.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/domain/ZfDoctor.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/domain/ZfDoctorShare.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/mapper/ZfDoctorShareMapper.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/ZExperienceServiceImpl.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java 176 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZDictController.java
File was deleted
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java
New file
@@ -0,0 +1,50 @@
package com.ruoyi.web.controller.zhang;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.domain.ShareMore;
import com.ruoyi.service.ZfDoctorShareService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
@RequestMapping("/ZfDoctorShare")
public class ZfDoctorShareController extends BaseController {
    @Resource
    ZfDoctorShareService zfDoctorShareService;
    /**
     * 分享数据
     */
    @PostMapping("/share")
    public AjaxResult share(@RequestBody ShareMore zfDoctor){
        return zfDoctorShareService.saveZa(zfDoctor);
    }
    /**
     * 根据UserId和分享人shareId查看已经授权给那些人那些数据
     */
    @PostMapping("/getInfoByUserId")
    public AjaxResult empowerGetInfo(@RequestBody ShareMore zfDoctor){
        return zfDoctorShareService.listByFidAid(zfDoctor);
    }
    /**
     * 用户自己查看别人分享的数据和分享人
     */
    @GetMapping("/getInfoByShareId")
    public AjaxResult empowerGetInfo2(){
        return zfDoctorShareService.listByUserId();
    }
    /**
     * 根据userId和shareId收回已经授权给那些人
     */
    @PostMapping("/deleteInfoByUserId")
    public AjaxResult deleteEmpower(@RequestBody ShareMore zfDoctor){
        return zfDoctorShareService.deleteZa(zfDoctor);
    }
}
ruoyi-common/src/main/java/com/ruoyi/common/utils/MapUtils.java
File was deleted
zhang-content/src/main/java/com/ruoyi/domain/ShareMore.java
New file
@@ -0,0 +1,27 @@
package com.ruoyi.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
@Data
public class ShareMore implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 用户id
     */
    private Long userId;
    /**
     * 分享的用户id
     */
    private Long[] shareIds;
    /**
     * 分享的内容
     */
    private Long[] shareContents;
}
zhang-content/src/main/java/com/ruoyi/domain/ZfDoctor.java
@@ -94,4 +94,5 @@
    @TableField(exist = false)
    private Integer ownData;
    private Long shareId;
}
zhang-content/src/main/java/com/ruoyi/domain/ZfDoctorShare.java
New file
@@ -0,0 +1,35 @@
package com.ruoyi.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("zf_doctor_share")
public class ZfDoctorShare implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 用户id
     */
    private Long userId;
    /**
     * 分享的用户id
     */
    private Long shareId;
    /**
     * 分享的内容
     */
    private Long shareContent;
}
zhang-content/src/main/java/com/ruoyi/mapper/ZfDoctorShareMapper.java
New file
@@ -0,0 +1,9 @@
package com.ruoyi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.ZfDoctorShare;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ZfDoctorShareMapper extends BaseMapper<ZfDoctorShare> {
}
zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java
New file
@@ -0,0 +1,25 @@
package com.ruoyi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.domain.ShareMore;
import com.ruoyi.domain.ZfDoctor;
import com.ruoyi.domain.ZfDoctorShare;
import java.util.List;
public interface ZfDoctorShareService extends IService<ZfDoctorShare> {
    List<ZfDoctorShare> getAuthority();
    AjaxResult saveZa(ShareMore zfDoctor);
    AjaxResult listByFidAid(ShareMore zfDoctor);
    AjaxResult deleteZa(ShareMore zfDoctor);
    AjaxResult listByUserId();
    List<ZfDoctor> listUserId(Long shareId);
}
zhang-content/src/main/java/com/ruoyi/service/impl/ZExperienceServiceImpl.java
File was deleted
zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java
@@ -6,7 +6,9 @@
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.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.*;
@@ -60,6 +62,10 @@
    @Resource
    private RestHighLevelClient restHighLevelClient;
    @Resource
    ZfDoctorShareService zfDoctorShareService;
    @Override
    public AjaxResult selectDoctorList(ZfDoctor zfDoctor, Integer pageNum, Integer pageSize) {
//        LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor);
@@ -72,8 +78,7 @@
//        return AjaxResult.success(data);
        //要查自己家庭的
        ZInfoUser myself = zInfoUserService.getMyself();
        if(myself==null)
        {
        if (myself == null) {
            //   System.out.println("ssssss");
            return AjaxResult.success("您没加入到对应的家庭,请联系管理员");
        }
@@ -85,8 +90,11 @@
        idList.add(familyId);
//        String familyIds = listFamilyIds();
//        String secondFamilyAuthority = listSecondFamilyIds();
        LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor, idList);
        //查看别人分享
        List<ZfDoctor> bs = zfDoctorShareService.listUserId(myself.getUserId());
        LambdaQueryWrapper<ZfDoctor> lqw = buildCondition(zfDoctor, idList);
        Page<ZfDoctor> zfDoctorPage = new Page<>(pageNum, pageSize);
        Page<ZfDoctor> pageResult = page(zfDoctorPage, lqw);
@@ -94,7 +102,7 @@
        List<ZfDoctor> beanRecords = pageResult.getRecords();//得到查询出来的数据
        List<ZfDoctor> dtoResult = markOwnData(familyId, beanRecords);
        dtoResult.addAll(bs);
        HashMap<String, Object> data = MapUtils.getResult(pageResult, dtoResult);
        return AjaxResult.success(data);
    }
@@ -116,8 +124,12 @@
        //加上自己家庭的id
        idList.add(familyId);
        //查看别人分享
        List<ZfDoctor> bs = zfDoctorShareService.listUserId(myself.getUserId());
        LambdaQueryWrapper<ZfDoctor> lambdaQueryWrapper = buildCondition(zfDoctor, idList);
        List<ZfDoctor> beanRecords = list(lambdaQueryWrapper);
        beanRecords.addAll(bs);
        log.info("从数据库中查到的为:{}", beanRecords);
        return markOwnData(familyId, beanRecords);
    }
@@ -159,8 +171,7 @@
        for (ZfDoctor zfDoctor : dataList) {
            if (zfDoctor.getSymptom().length() == 0 || zfDoctor.getSymptom() == null) {
                throw new RuntimeException("症状为空,导入数据失败");
            }
            else {
            } else {
                zfDoctorService.addData(zfDoctor);
            }
        }
@@ -180,6 +191,10 @@
        List<ZAuthority> authority = zAuthorityService.getAuthority();
        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(DOCTOR_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
        familyIdList.add(familyId);
//        List<ZfDoctorShare> authority1 = zfDoctorShareService.getAuthority();
//        List<Long> idList1 = authority1.stream().filter(auth -> auth.getShareContent().toString().equals(DOCTOR_LIST)).map(ZfDoctorShare::getShareId).collect(Collectors.toList());
        zfDoctorService.addData(zfDoctor);
        if (zfDoctor.getFamilyId()!=null && !familyIdList.contains(zfDoctor.getFamilyId())) {
            throw new RuntimeException("你没有权限操作此家庭的数据");
@@ -213,8 +228,11 @@
            esModel.setBy5("/family/zfDoctor");
            esModel.setBy6(zfDoctor.getCmedical());
            esModel.setBy7(zfDoctor.getWmedical());
//            esModel.setBy7();
            esModel.setRemark(zfDoctor.getRemark());
            esModel.setFid(familyId);
            //这里存储查询详情的路径
            esService.insertTable(esModel);
            return AjaxResult.success();
@@ -222,6 +240,7 @@
            return AjaxResult.error();
        }
    }
    @Resource
    ZfLogService zfLogService;
@@ -427,4 +446,21 @@
        }
        return lqw;
    }
//        private List<Long> buildCondition1(){
//        List<ZfDoctorShare> authority1 = zfDoctorShareService.getAuthority();
//        List<Long> idList1 = authority1.stream().filter(auth -> auth.getShareContent().toString().equals(DOCTOR_LIST)).map(ZfDoctorShare::getShareId).collect(Collectors.toList());
//        return idList1;
//    }
//    private LambdaQueryWrapper<ZfDoctor> buildCondition2(ZfDoctor zfDoctor, List<Long> IdList) {
//        LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
//        lqw.in(ZfDoctorShare::getShareId, IdList);
//        List<ZfDoctorShare> beanRecords = list(lqw);
//        for (ZfDoctorShare shareContent : beanRecords){
//            zfDoctorService.getById(shareContent);
//        }
//
//    }
}
zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java
New file
@@ -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查看已经授权给那些人那些数据
     */
    @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();
    }
}