From 2723e04976f006ace42c6c53627b87e1cc95ff07 Mon Sep 17 00:00:00 2001 From: zqy <2522236926@qq.com> Date: 星期三, 31 七月 2024 12:27:48 +0800 Subject: [PATCH] 修改bug&分享 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfClanController.java | 24 ++ zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyShareServiceImpl.java | 190 +++++++++++++++++++ ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 2 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfAncestorController.java | 21 + zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyDownloadServiceImpl.java | 142 ++++++++++++++ ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyShareController.java | 83 ++++++++ ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEventShareController.java | 2 zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java | 2 zhang-content/src/main/java/com/ruoyi/service/IZfPropertyDownloadService.java | 13 + zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java | 76 ++++--- zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanServiceImpl.java | 3 zhang-content/src/main/java/com/ruoyi/service/IZfPropertyShareService.java | 25 ++ 12 files changed, 541 insertions(+), 42 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfAncestorController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfAncestorController.java index 7fadc32..f25f866 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfAncestorController.java +++ b/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(); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfClanController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfClanController.java index 3591202..7264cab 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfClanController.java +++ b/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); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEventShareController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEventShareController.java index ae06b73..2b501b8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfEventShareController.java +++ b/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; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyShareController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyShareController.java new file mode 100644 index 0000000..403fc25 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfPropertyShareController.java @@ -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鏌ョ湅宸茬粡鎺堟潈缁欓偅浜涗汉閭d簺鏁版嵁 + */ + @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鍜宻hareId鏀跺洖宸茬粡鎺堟潈缁欓偅浜涗汉 + */ + @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); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 4b35655..ac7b368 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/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); } /** diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java b/zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java index 536b087..7916f7e 100644 --- a/zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java +++ b/zhang-content/src/main/java/com/ruoyi/domain/ZfProperty.java @@ -98,4 +98,6 @@ @TableField(exist = false) private Date happenEndTime; + private Integer shareId; + } diff --git a/zhang-content/src/main/java/com/ruoyi/service/IZfPropertyDownloadService.java b/zhang-content/src/main/java/com/ruoyi/service/IZfPropertyDownloadService.java new file mode 100644 index 0000000..8610bf1 --- /dev/null +++ b/zhang-content/src/main/java/com/ruoyi/service/IZfPropertyDownloadService.java @@ -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); +} diff --git a/zhang-content/src/main/java/com/ruoyi/service/IZfPropertyShareService.java b/zhang-content/src/main/java/com/ruoyi/service/IZfPropertyShareService.java new file mode 100644 index 0000000..1f39965 --- /dev/null +++ b/zhang-content/src/main/java/com/ruoyi/service/IZfPropertyShareService.java @@ -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); +} diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyDownloadServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyDownloadServiceImpl.java new file mode 100644 index 0000000..51d6644 --- /dev/null +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyDownloadServiceImpl.java @@ -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); + } +} diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyShareServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyShareServiceImpl.java new file mode 100644 index 0000000..f4dd082 --- /dev/null +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyShareServiceImpl.java @@ -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; + } + } +} diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java index 39214c0..158945a 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfAncestorServiceImpl.java +++ b/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); -// } -// } -// }); -// -// -// }} + + }}} } diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanServiceImpl.java index 9c72768..ab4f6e0 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfClanServiceImpl.java +++ b/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(); -- Gitblit v1.9.1