| | |
| | | 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.domain.*; |
| | | import com.ruoyi.mapper.ZfShareDataMapper; |
| | | import com.ruoyi.service.EsService; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class ZfShareDataServiceImpl extends ServiceImpl<ZfShareDataMapper, ZfShareData> implements ZfShareDataService { |
| | |
| | | private RestHighLevelClient restHighLevelClient; |
| | | |
| | | @Resource |
| | | private ZfClanService zfClanService; |
| | | |
| | | |
| | | @Resource |
| | | private EsService esSer; |
| | | |
| | | private LambdaQueryWrapper<ZfShareData> buildCondition(Long userId) { |
| | | LambdaQueryWrapper<ZfShareData> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfShareData::getId); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfShareData> selectList() { |
| | | public List<ZfShareData> selectList(ZfShareData zfShareData) { |
| | | LambdaQueryWrapper<ZfShareData> lqw = buildCondition(getUserId()); |
| | | |
| | | return list(lqw); |
| | |
| | | return myself.getUserId(); |
| | | |
| | | } |
| | | @Override |
| | | public Long getSource(Long userId){ |
| | | LambdaQueryWrapper<ZfShareData> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfShareData::getId); |
| | | lqw.eq(ZfShareData::getSharedId,userId); |
| | | if (list(lqw).size() == 0){ |
| | | return userId; |
| | | } |
| | | return getSource(list(lqw).get(0).getUserId().longValue()); |
| | | } |
| | | @Override |
| | | public Long getEnd(Long userId){ |
| | | LambdaQueryWrapper<ZfShareData> lqw1 = new LambdaQueryWrapper<>(); |
| | | lqw1.eq(ZfShareData::getUserId,userId); |
| | | if (list(lqw1).size() == 0){ |
| | | return userId; |
| | | } |
| | | return getEnd(list(lqw1).get(list(lqw1).size()-1).getSharedId().longValue()); |
| | | } |
| | | |
| | | // public Long getSource(Long userId){ |
| | | // LambdaQueryWrapper<ZfShareData> lqw = new LambdaQueryWrapper<>(); |
| | | // lqw.orderByDesc(ZfShareData::getId); |
| | | // lqw.eq(ZfShareData::getSharedId,userId); |
| | | // if (list(lqw).size() == 0){ |
| | | // return userId; |
| | | // } |
| | | // return getSource(userId); |
| | | // } |
| | | @Override |
| | | public AjaxResult addData(Long[] userIds) { |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | private LambdaQueryWrapper<ZfShareData> selectByUserId(List<Long> userId) { |
| | | LambdaQueryWrapper<ZfShareData> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.in(ZfShareData::getSharedId,userId); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfShareData> selectBySharedId(List<Long> userId) { |
| | | LambdaQueryWrapper<ZfShareData> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.in(ZfShareData::getUserId,userId); |
| | | return lqw; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult setAdmin(Long id) { |
| | | List<ZfShareData> list = list(buildCondition(getUserId())); |
| | | list.addAll(getShareId(getUserId())); |
| | | for (ZfShareData zfShareData1:list){ |
| | | public List<Long> getAllPerson(List<Long> userIds){ |
| | | List<ZfShareData> lists = new ArrayList<>(list(selectByUserId(userIds))); |
| | | lists.addAll(list(selectBySharedId(userIds))); |
| | | |
| | | if (userIds.contains(getEnd(getSource(userIds.get(0))))){ |
| | | return userIds; |
| | | } |
| | | |
| | | return getAllPerson(lists.stream().map(ZfShareData::getSharedId).map(Integer::longValue).collect(Collectors.toList())); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult setAdmin(Long userId,Long id) { |
| | | Long source = getSource(userId); |
| | | List<Long> all = getAllPerson(Collections.singletonList(source)); |
| | | List<Long> collect = all.stream().distinct().collect(Collectors.toList()); |
| | | collect.add(source); |
| | | |
| | | List<ZfShareData> list = list(selectByUserId(collect)); |
| | | list.addAll(list(selectBySharedId(collect))); |
| | | List<ZfShareData> collect1 = list.stream().distinct().collect(Collectors.toList()); |
| | | for (ZfShareData zfShareData1:collect1){ |
| | | zfShareData1.setMasterAccount(id.intValue()); |
| | | updateById(zfShareData1); |
| | | } |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult allUser(Long id) { |
| | | List<ZfShareData> list = list(buildCondition(id)); |
| | | list.addAll(getShareId(id)); |
| | | for (ZfShareData zfShareData1:list){ |
| | | Long source = getSource(id); |
| | | List<Long> all = getAllPerson(Collections.singletonList(source)); |
| | | List<Long> collect = all.stream().distinct().collect(Collectors.toList()); |
| | | collect.add(source); |
| | | |
| | | List<ZfShareData> list = list(selectByUserId(collect)); |
| | | list.addAll(list(selectBySharedId(collect))); |
| | | List<ZfShareData> collect1 = list.stream().distinct().collect(Collectors.toList()); |
| | | for (ZfShareData zfShareData1:collect1){ |
| | | zfShareData1.setMasterAccount(0); |
| | | updateById(zfShareData1); |
| | | } |
| | |
| | | lqw.eq(ZfShareData::getSharedId,id); |
| | | return list(lqw); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfShareData> getByShareId(List<Long> id) { |
| | | LambdaQueryWrapper<ZfShareData> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfShareData::getId); |
| | | lqw.in(ZfShareData::getSharedId,id); |
| | | return list(lqw); |
| | | } |
| | | } |