ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfAncestorController.java
@@ -14,13 +14,16 @@ import com.ruoyi.domain.ZfClan; import com.ruoyi.service.ZInfoUserService; import com.ruoyi.service.ZfAncestorService; import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.SysUserRoleMapper; import com.ruoyi.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import static com.ruoyi.common.core.page.TableSupport.*; @@ -39,6 +42,9 @@ @Resource ZInfoUserService zInfoUserService; @Resource private SysUserRoleMapper sysUserRoleMapper; @GetMapping("/all/{clanId}") public AjaxResult listAll(@PathVariable Integer clanId){ @@ -67,13 +73,21 @@ us.setPassword(SecurityUtils.encryptPassword(us.getPassword())); userService.insertUser(us); SysUserRole sysUserRole = new SysUserRole(); sysUserRole.setUserId(us.getUserId()); sysUserRole.setRoleId(102L); List<SysUserRole> sysUserRoles = new ArrayList<>(); sysUserRoles.add(sysUserRole); sysUserRoleMapper.batchUserRole(sysUserRoles); ZInfoUser infoUser = new ZInfoUser(); infoUser.setClanId(zfAncestor.getClanId()); infoUser.setSex(zfAncestor.getSex()); infoUser.setNickName(zfAncestor.getName()); infoUser.setSysId(us.getUserId()); infoUser.setRoleId(Long.valueOf(zfAncestor.getRoleId())); infoUser.setRoleId(zfAncestor.getRoleId().longValue()); infoUser.setIsMyFamily(zfAncestor.getSex() == 0?1:0); infoUser.setSpouseId(zfAncestor.getSpouseId().longValue()); @@ -99,6 +113,8 @@ // us.setRemark(zfAncestor.getRemark()); userService.updateUser(us); Long userId1 = zfAncestor.getSysId(); SysUserRole sysUserRole=sysUserRoleMapper.selectUserById(userId1); // System.out.println(user.getFamilyId()); // System.out.println("[[[[]]]]]]"); ZInfoUser infoUser = new ZInfoUser(); @@ -139,8 +155,7 @@ Long sysId = zfAncestorService.addData(zfAncestor); zfAncestor.setSpouseId(sysId.intValue()); zfAncestor.setSysId(addAncestor(zfAncestor)); zfAncestorService.updateById(zfAncestor); zfAncestorService.updateById(zfAncestor); return AjaxResult.success(); ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfClanController.java
@@ -7,10 +7,18 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.domain.Meeting; import com.ruoyi.domain.ZInfoUser; import com.ruoyi.domain.ZfClan; import com.ruoyi.service.ZInfoUserService; import com.ruoyi.service.ZfClanService; import com.ruoyi.system.mapper.SysUserRoleMapper; import com.ruoyi.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; import static com.ruoyi.common.core.page.TableSupport.*; @@ -19,6 +27,15 @@ public class ZfClanController { @Autowired ZfClanService zfClanService; @Autowired private ISysUserService userService; @Resource ZInfoUserService zInfoUserService; @Resource private SysUserRoleMapper sysUserRoleMapper; @GetMapping("/all") public AjaxResult listAll(ZfClan zfClan){ @@ -53,6 +70,12 @@ return zfClanService.updateData(zfClan); } private void deleteUser(Long clanId){ List<ZInfoUser> allMember = zInfoUserService.selectByClanId(clanId.intValue()); for (ZInfoUser member: allMember) { userService.deleteUserById(member.getSysId()); } } /** * 批量删除家族 @@ -60,6 +83,7 @@ @Log(title = "家族", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long ids) { deleteUser(ids); return zfClanService.deleteData(ids); } ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEventShareController.java
@@ -16,7 +16,7 @@ import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; @RestController @RequestMapping("/familyShare") @RequestMapping("/family/zfEventShare") public class ZfEventShareController extends BaseController { @Resource ZfEventShareService zfEventShareService; ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyShareController.java
New file @@ -0,0 +1,83 @@ package com.ruoyi.web.controller.zhang; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.domain.ShareMore; import com.ruoyi.domain.ZfDownload; import com.ruoyi.service.ZfEventDownloadService; import com.ruoyi.service.ZfEventShareService; import com.ruoyi.service.impl.IZfPropertyDownloadServiceImpl; import com.ruoyi.service.impl.IZfPropertyShareServiceImpl; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import static com.ruoyi.common.core.page.TableSupport.PAGE_NO; import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE; @RestController @RequestMapping("/family/propertyShare") public class ZfPropertyShareController extends BaseController { @Resource IZfPropertyShareServiceImpl iZfPropertyShareService; @Resource IZfPropertyDownloadServiceImpl iZfPropertyDownloadService; @PostMapping("/share") public AjaxResult share(@RequestBody ShareMore zfDoctor){ zfDoctor.setSysMenuId(2002L); return iZfPropertyShareService.saveZa(zfDoctor); } /** * 根据UserId和分享人shareId查看已经授权给那些人那些数据 */ @PostMapping("/getInfoByUserId") public AjaxResult empowerGetInfo(@RequestBody ShareMore zfDoctor){ zfDoctor.setSysMenuId(2002L); Integer pageNo = Convert.toInt(ServletUtils.getParameter(PAGE_NO), 1); Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); return iZfPropertyShareService.listByFidAid(zfDoctor,pageNo,pageSize) ; } /** * 用户自己查看别人分享的数据和分享人 */ @GetMapping("/getInfoByShareId") public AjaxResult empowerGetInfo2(){ Integer pageNo = Convert.toInt(ServletUtils.getParameter(PAGE_NO), 1); Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); return iZfPropertyShareService.listUserId(pageNo ,pageSize); } /** * 根据userId和shareId收回已经授权给那些人 */ @PostMapping("/deleteInfoByUserId") public AjaxResult deleteEmpower(@RequestBody ShareMore zfDoctor){ zfDoctor.setSysMenuId(2002L); return iZfPropertyShareService.deleteZa(zfDoctor); } /** * 下载分享的数据 */ @PostMapping("/downloadDate") public AjaxResult ifDownLoad(@RequestBody ZfDownload zfDownload){ zfDownload.setSysMenuId(2002L); return iZfPropertyDownloadService.addData(zfDownload); } /** * 展示下载分享的数据 */ @GetMapping("/all") public AjaxResult data(ZfDownload zfDownload){ zfDownload.setSysMenuId(2002L); Integer pageNo = Convert.toInt(ServletUtils.getParameter(PAGE_NO), 1); Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); return iZfPropertyDownloadService.selectDoctorList(zfDownload,pageNo ,pageSize); } } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -472,7 +472,7 @@ userRoleMapper.deleteUserRoleByUserId(userId); // 删除用户与岗位表 userPostMapper.deleteUserPostByUserId(userId); return userMapper.deleteUserById(userId); return userMapper.deleteById(userId); } /** zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java
@@ -98,4 +98,6 @@ @TableField(exist = false) private Date happenEndTime; private Integer shareId; } zhang-content/src/main/java/com/ruoyi/service/IZfPropertyDownloadService.java
New file @@ -0,0 +1,13 @@ package com.ruoyi.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ZfDownload; public interface IZfPropertyDownloadService extends IService<ZfDownload> { AjaxResult addData(ZfDownload zfDownload); AjaxResult deleteData(Long[] ids); AjaxResult selectDoctorList(ZfDownload zfDownload, Integer pageNo , Integer pageSize); } zhang-content/src/main/java/com/ruoyi/service/IZfPropertyShareService.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.ZfDownload; import com.ruoyi.domain.ZfShare; import java.util.List; public interface IZfPropertyShareService extends IService<ZfShare> { List<ZfShare> getAuthority(); AjaxResult saveZa(ShareMore shareMore); AjaxResult listByFidAid(ShareMore shareMore,Integer pageNo ,Integer pageSize); AjaxResult deleteZa(ShareMore shareMore); AjaxResult listByUserId(); AjaxResult listUserId(Integer pageNo ,Integer pageSize); Long getShareId(ZfDownload zfDownload); } zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyDownloadServiceImpl.java
New file @@ -0,0 +1,142 @@ package com.ruoyi.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.utils.MapUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.domain.ZInfoUser; import com.ruoyi.domain.ZfDownload; import com.ruoyi.domain.ZfEvent; import com.ruoyi.domain.ZfProperty; import com.ruoyi.mapper.ZfDownloadMapper; import com.ruoyi.service.*; 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.*; import java.util.stream.Collectors; @Service public class IZfPropertyDownloadServiceImpl extends ServiceImpl<ZfDownloadMapper, ZfDownload> implements IZfPropertyDownloadService { @Resource EsService esService; @Resource IZfPropertyShareService iZfPropertyShareService; @Resource IZfPropertyService iZfPropertyService; @Resource ZInfoUserService zInfoUserService; @Resource private RestHighLevelClient restHighLevelClient; private LambdaQueryWrapper<ZfDownload> buildCondition(ZfDownload zfDownload, Long userId) { LambdaQueryWrapper<ZfDownload> lqw = new LambdaQueryWrapper<>(); lqw.in(ZfDownload::getDownloadId,userId); lqw.orderByDesc(ZfDownload::getDownloadId); lqw.like(zfDownload.getDownloadId() != null, ZfDownload::getDownloadId, zfDownload.getDownloadId()) .like(zfDownload.getDownloadContent() != null, ZfDownload::getDownloadContent, zfDownload.getDownloadContent()) .eq( ZfDownload::getSysMenuId, zfDownload.getSysMenuId()); return lqw; } private LambdaQueryWrapper<ZfDownload> uniqueCondition(ZfDownload zfDownload) { LambdaQueryWrapper<ZfDownload> lqw = new LambdaQueryWrapper<>(); lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfDownload.getDownloadId())), ZfDownload::getDownloadId, zfDownload.getDownloadId()) .eq(StringUtils.isNotEmpty(String.valueOf(zfDownload.getDownloadContent())), ZfDownload::getDownloadContent, zfDownload.getDownloadContent()) .eq(ZfDownload::getSysMenuId, zfDownload.getSysMenuId()); return lqw; } public Long getUserId() { ZInfoUser myself = zInfoUserService.getMyself(); return myself.getUserId(); } @Override public AjaxResult addData(ZfDownload zfDownload) { zfDownload.setDownloadId(getUserId()); LambdaQueryWrapper<ZfDownload> lqw = uniqueCondition(zfDownload); List<ZfDownload> list = list(lqw); if (list.size() > 0) { throw new RuntimeException("请勿重复下载数据"); } zfDownload.setDownloadId(getUserId()); zfDownload.setShareId(iZfPropertyShareService.getShareId(zfDownload)); if (save(zfDownload)) { EsModel esModel = new EsModel(); Integer inte = zfDownload.getId().intValue(); String uuid = UUID.randomUUID().toString().replace("-", ""); esModel.setId(uuid); esModel.setCtId(Long.valueOf(inte)); esModel.setCtTableName("家庭小医生"); esModel.setBy1(String.valueOf(zfDownload.getDownloadId())); esModel.setBy2(String.valueOf(zfDownload.getDownloadContent())); esModel.setBy3(String.valueOf(zfDownload.getShareId())); //这里存储查询详情的路径 esService.insertTable(esModel); return AjaxResult.success(); } else { return AjaxResult.error(); } } @Override public AjaxResult deleteData(Long[] ids) { List<ZfDownload> zfDownloads = listByIds(Arrays.asList(ids)); if (iZfPropertyShareService.removeByIds(Arrays.asList(ids))) { //删除es中的数据 zfDownloads.stream().forEach(zfDoctorDownload -> { EsModel esModel = esService.findByCtId(zfDoctorDownload.getId().intValue(), "家庭小医生下载"); if (esModel != null) { DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId()); try { restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT); } catch (IOException e) { throw new RuntimeException(e); } } }); return AjaxResult.success(); } else { return AjaxResult.error(); } } @Override public AjaxResult selectDoctorList(ZfDownload zfDownload, Integer pageNo, Integer pageSize) { ZInfoUser myself = zInfoUserService.getMyself(); LambdaQueryWrapper<ZfDownload> lqw = buildCondition(zfDownload,myself.getUserId()); List<ZfDownload> beanRecords = list(lqw); List<ZfProperty> bs = new ArrayList<>(); for (ZfDownload a: beanRecords) { if (iZfPropertyService.getById(a.getDownloadContent()) != null) { ZfProperty ds = iZfPropertyService.getById(a.getDownloadContent()); ds.setShareId(a.getShareId().intValue()); bs.add(ds); } } List<ZfProperty> record = bs.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList()); int totalPage = (bs.size() -1) / pageSize +1; Page<ZfProperty> zfEventPage = new Page<>(pageNo, pageSize,totalPage); HashMap<String, Object> data = MapUtils.getShareResult(zfEventPage, record,bs.size()); return AjaxResult.success(data); } } zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyShareServiceImpl.java
New file @@ -0,0 +1,190 @@ package com.ruoyi.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.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.*; 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; import java.util.stream.Collectors; @Slf4j @Service public class IZfPropertyShareServiceImpl extends ServiceImpl<ZfShareMapper,ZfShare> implements IZfPropertyShareService { @Resource IZfPropertyShareService iZfPropertyShareService; @Resource IZfPropertyService iZfPropertyService; @Resource private ZInfoUserService zInfoUserService; 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<ZfShare> getAuthority() { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZfShare::getShareId,userId); return list(lqw); } public Long getUserId(){ ZInfoUser myself = zInfoUserService.getMyself(); return myself.getUserId(); } public void addData(ZfShare za) { LambdaQueryWrapper<ZfShare> lqw = uniqueCondition(za); List<ZfShare> list = list(lqw); if(list.size()>0){ throw new RuntimeException("请勿分享重复数据"); } else { iZfPropertyShareService.save(za); } } @Override public AjaxResult saveZa(ShareMore shareMore) { Long [] shareIds = shareMore.getShareIds(); Long [] shareContents = shareMore.getShareContents(); for (Long shareId : shareIds) { for (Long shareContent : shareContents) { ZfShare za = new ZfShare(); za.setUserId(getUserId()); za.setShareContent(shareContent); za.setShareId(shareId); za.setSysMenuId(2002L); addData(za); } } // Long [] // if(bl) return AjaxResult.success("分享成功!"); } @Override public AjaxResult listByFidAid(ShareMore shareMore, Integer pageNo, Integer pageSize) { Long [] shareIds = shareMore.getShareIds(); List<ZfProperty> beanRecord3 = new ArrayList<>(); for (Long shareId : shareIds) { { LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZfShare::getShareId,shareId) .eq(ZfShare::getSysMenuId,shareMore.getSysMenuId()) .eq(ZfShare::getUserId, getUserId()); List<ZfShare> beanRecords = list(lqw); for (ZfShare beanRecord : beanRecords ) { beanRecord3.add(iZfPropertyService.getById(beanRecord.getShareContent())); } } } List<ZfProperty> record = beanRecord3.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList()); int totalPage = (beanRecord3.size() -1) / pageSize +1; Page<ZfProperty> zfPropertyPage = new Page<>(pageNo, pageSize,totalPage); HashMap<String, Object> data = MapUtils.getShareResult(zfPropertyPage, record,beanRecord3.size()); return AjaxResult.success(data); } @Override public AjaxResult deleteZa(ShareMore shareMore) { Long [] shareIds = shareMore.getShareIds(); Long [] shareContents = shareMore.getShareContents(); for(Long shareId : shareIds) for(Long shareContent: shareContents) { LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZfShare::getShareId,shareId) .eq(ZfShare::getShareContent, shareContent) .eq(ZfShare::getSysMenuId, shareMore.getSysMenuId()) .eq(ZfShare::getUserId, getUserId()); iZfPropertyShareService.remove(lqw); // addData(za); } return AjaxResult.success("数据收回成功!"); } @Override public AjaxResult listByUserId() { HashMap<Long,List<ZfProperty>> bs = new HashMap<>(); LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZfShare::getShareId,getUserId()); lqw.eq(ZfShare::getSysMenuId,2002L); List<ZfShare> beanRecords = list(lqw); List<ZfProperty> b1 = new ArrayList<>(); for (ZfShare beanRecord : beanRecords ) { b1.add(iZfPropertyService.getById(beanRecord.getShareContent())); bs.put(beanRecord.getUserId(),b1); } log.info("从数据库中查到的为:{}", bs); return AjaxResult.success(bs); } @Override public AjaxResult listUserId(Integer pageNo, Integer pageSize) { List<ZfProperty> bs = new ArrayList<>(); LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZfShare::getShareId,getUserId()); lqw.eq(ZfShare::getSysMenuId,2002L); List<ZfShare> beanRecords = list(lqw); for (ZfShare beanRecord : beanRecords ) { ZfProperty bs2 = iZfPropertyService.getById(beanRecord.getShareContent()); bs2.setShareId(beanRecord.getUserId().intValue()); bs.add(bs2); } log.info("从数据库中查到的为:{}", bs); List<ZfProperty> record = bs.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList()); int totalPage = (bs.size() -1) / pageSize +1; Page<ZfProperty> zfPropertyPage = new Page<>(pageNo, pageSize,totalPage); HashMap<String, Object> data = MapUtils.getShareResult(zfPropertyPage, record,bs.size()); return AjaxResult.success(data); } @Override 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(); } else { return null; } } } zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java
@@ -10,10 +10,14 @@ import com.ruoyi.domain.ZfClan; import com.ruoyi.mapper.ZfAncestorMapper; import com.ruoyi.service.*; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.IOException; import java.util.*; @Service @@ -111,9 +115,11 @@ LambdaQueryWrapper<ZfAncestor> lqw = buildCondition(zfAncestor); List<ZfAncestor> list = list(lqw); Long sysID = 0L; System.out.println("15dniwru/"+list); if(list.size()>2){ throw new RuntimeException("请勿重复添加祖先"); } else if (list.size() == 1){ if (list.get(0).getSex().equals(zfAncestor.getSex())){ throw new RuntimeException("两位祖先不能为同性"); @@ -240,47 +246,45 @@ */ @Override public void deleteMember(Long ids) { // LambdaQueryWrapper<ZfAncestor> lqw = new LambdaQueryWrapper<>(); // lqw.eq(ZfAncestor::getClanId,ids); // List<ZfAncestor> zfAncestors =list(lqw) ; //// for (ZfClanManage zfClanManage : zfClanManages) { //// if (!zfClanManages.getAdminId().equals(getUserId())) { //// throw new RuntimeException("您不是管理员,没有权力删除该家族"); //// } //// } // //// if (!Long.valueOf(zfClanService.getById(zfClanManages.get(0).getClanId()).getAdminId()).equals(getUserId())) { //// throw new RuntimeException("您不是管理员,没有权力删除成员"); //// } // List<Integer> id = new ArrayList<>() ; // for (ZfAncestor zfAncestor : zfAncestors) { // ZInfoUser zInfoUser = zInfoUserService.getById(Long.valueOf(zfAncestor.getMemberId())); // zInfoUser.setClanId(0); // System.out.println(zInfoUser); // zInfoUserService.saveOrUpdate(zInfoUser); // id.add(zfAncestor.getId()); LambdaQueryWrapper<ZfAncestor> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZfAncestor::getClanId,ids); List<ZfAncestor> zfAncestors =list(lqw) ; // for (ZfClanManage zfClanManage : zfClanManages) { // if (!zfClanManages.getAdminId().equals(getUserId())) { // throw new RuntimeException("您不是管理员,没有权力删除该家族"); // } // } } // if (!Long.valueOf(zfClanService.getById(zfClanManages.get(0).getClanId()).getAdminId()).equals(getUserId())) { // throw new RuntimeException("您不是管理员,没有权力删除成员"); // } List<Integer> id = new ArrayList<>() ; for (ZfAncestor zfAncestor : zfAncestors) { ZInfoUser zInfoUser = zInfoUserService.getInfoBysysId(zfAncestor.getSysId()); zInfoUser.setClanId(0); zInfoUserService.saveOrUpdate(zInfoUser); id.add(zfAncestor.getId()); // // } /** * 在用户信息表删除家族号 */ if (zfAncestorService.removeByIds(id)) { //删除es中的数据 zfAncestors.stream().forEach(zfAncestor1 -> { EsModel esModel = esSer.findByCtId((zfAncestor1.getId().intValue()), "家族管理"); if (esModel != null) { DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId()); try { restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT); } catch (IOException e) { throw new RuntimeException(e); } } }); // if (zfAncestorService.removeByIds(id)) { // //删除es中的数据 // zfAncestors.stream().forEach(zfAncestor -> { // EsModel esModel = esSer.findByCtId((zfAncestor.getId().intValue()), "家族管理"); // if (esModel != null) { // DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId()); // try { // restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // }); // // // }} }}} } zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanServiceImpl.java
@@ -190,7 +190,7 @@ public AjaxResult deleteData(Long ids) { List<ZfClan> zfClans = listByIds(Arrays.asList(ids)); // zfClanManageService.deleteMember(ids); zfAncestorService.deleteMember(ids); if (zfClanService.removeByIds(Arrays.asList(ids))) { //删除es中的数据 @@ -207,6 +207,7 @@ }); return AjaxResult.success(); } else { return AjaxResult.error();