| | |
| | | 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.ZfClan; |
| | | import com.ruoyi.domain.ZfLog; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.mapper.ZfClanMapper; |
| | | import com.ruoyi.service.EsService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfClanService; |
| | | import com.ruoyi.service.ZfLogService; |
| | | import com.ruoyi.service.*; |
| | | import org.elasticsearch.action.delete.DeleteRequest; |
| | | import org.elasticsearch.action.update.UpdateRequest; |
| | | import org.elasticsearch.client.RequestOptions; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class ZfClanServiceImpl extends ServiceImpl<ZfClanMapper,ZfClan> implements ZfClanService { |
| | |
| | | @Resource |
| | | private ZfClanService zfClanService; |
| | | |
| | | @Resource |
| | | private ZfClanManageService zfClanManageService; |
| | | |
| | | |
| | | private LambdaQueryWrapper<ZfClan> buildCondition(ZfClan zfClan) { |
| | | LambdaQueryWrapper<ZfClan> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfClan::getClanId); |
| | | lqw.like(StringUtils.isNotEmpty(zfClan.getClanName()), ZfClan::getClanName, zfClan.getClanName()) |
| | | .like(zfClan.getAdminId() !=0, ZfClan::getAdminId, zfClan.getAdminId()) |
| | | .like(zfClan.getDadId() !=0 , ZfClan::getDadId, zfClan.getDadId()) |
| | | .like(zfClan.getMomId() !=0, ZfClan::getMomId, zfClan.getMomId()); |
| | | .like(zfClan.getAdminId() != null, ZfClan::getAdminId, zfClan.getAdminId()) |
| | | .like(zfClan.getMomId() != null, ZfClan::getDadId, zfClan.getDadId()) |
| | | .like(zfClan.getDadId() != null, ZfClan::getMomId, zfClan.getMomId()); |
| | | return lqw; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZfClan> uniqueCondition(ZfClan zfClan){ |
| | | LambdaQueryWrapper<ZfClan> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(!StringUtils.isEmpty(zfClan.getClanName()), ZfClan::getClanName, zfClan.getClanName()); |
| | | lqw.eq(zfClan.getAdminId() !=0, ZfClan::getAdminId, zfClan.getAdminId()); |
| | | lqw.eq(zfClan.getDadId() !=0 , ZfClan::getDadId, zfClan.getDadId()); |
| | | lqw.eq(zfClan.getMomId() !=0, ZfClan::getMomId, zfClan.getMomId()); |
| | | lqw.eq(zfClan.getAdminId() !=null, ZfClan::getAdminId, zfClan.getAdminId()); |
| | | lqw.eq(zfClan.getDadId() !=null , ZfClan::getDadId, zfClan.getDadId()); |
| | | lqw.eq(zfClan.getMomId() !=null, ZfClan::getMomId, zfClan.getMomId()); |
| | | return lqw; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | |
| | | */ |
| | | public Long getUserId(){ |
| | | ZInfoUser myself = zInfoUserService.getMyself(); |
| | | |
| | | return myself.getUserId(); |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfClan zfClan, Integer pageNum, Integer pageSize) { |
| | | LambdaQueryWrapper<ZfClan> lqw = buildCondition(zfClan); |
| | | List<ZfClan> beanRecords = list(lqw); |
| | | |
| | | List<ZfClanDate> zfClanDates=new ArrayList<>(); |
| | | |
| | | Page<ZfClan> zfClanPage = new Page<>(pageNum, pageSize); |
| | | Page<ZfClan> pageResult = page(zfClanPage, lqw); |
| | | List<ZfClan> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | // System.out.println(beanRecords); |
| | | System.out.println(beanRecords); |
| | | for (ZfClan zfClan1: beanRecords) { |
| | | ZfClanDate zfClanDate = new ZfClanDate(); |
| | | HashMap<Integer,String> adminName = new HashMap<>(); |
| | | adminName.put(zfClan1.getAdminId(),zInfoUserService.getById(zfClan1.getAdminId()).getNickName()); |
| | | zfClanDate.setAdminName(adminName); |
| | | HashMap<Integer,String> momName = new HashMap<>(); |
| | | momName.put(zfClan1.getMomId(),zInfoUserService.getById(zfClan1.getMomId()).getNickName()); |
| | | zfClanDate.setMomName(momName); |
| | | HashMap<Integer,String> dadName = new HashMap<>(); |
| | | dadName.put(zfClan1.getDadId(),zInfoUserService.getById(zfClan1.getDadId()).getNickName()); |
| | | zfClanDate.setDadName(dadName); |
| | | zfClanDate.setClanId(zfClan1.getClanId()); |
| | | zfClanDate.setClanName(zfClan1.getClanName()); |
| | | zfClanDates.add(zfClanDate); |
| | | } |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords); |
| | | return AjaxResult.success(data); |
| | | return AjaxResult.success(zfClanDates); |
| | | |
| | | } |
| | | |
| | |
| | | LambdaQueryWrapper<ZfClan> lqw = uniqueCondition(zfClan); |
| | | List<ZfClan> list = list(lqw); |
| | | |
| | | |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复家族"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | if (save(zfClan)) { |
| | | EsModel esModel = new EsModel(); |
| | |
| | | // esModel.setFid(familyId); |
| | | esSer.insertTable(esModel); |
| | | // System.out.println(esModel); |
| | | zfClanManageService.addA(zfClan.getClanId(),zfClan.getDadId(),2); |
| | | zfClanManageService.addA(zfClan.getClanId(),zfClan.getMomId(),2); |
| | | // if (!zfClan.getDadId().equals(zfClan.getAdminId()) && !zfClan.getMomId().equals(zfClan.getAdminId()) ) |
| | | zfClanManageService.addA(zfClan.getClanId(),zfClan.getAdminId(),1); |
| | | |
| | | return AjaxResult.success(); |
| | | } else { |
| | |
| | | @Override |
| | | public AjaxResult updateData(ZfClan zfClan) { |
| | | |
| | | List<ZfClan> lqw = list(buildCondition(zfClan)); |
| | | |
| | | // if (!Long.valueOf(zfClanService.getById(zfClan.getClanId()).getAdminId()).equals(getUserId())) { |
| | | // throw new RuntimeException("您不是管理员,没有权力修改该家族信息"); |
| | | // |
| | | // } |
| | | ZfLog zfLog = new ZfLog(); |
| | | zfLog.setUpdateTime(LocalDateTime.now()); |
| | | zfLog.setModule("家族"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deleteData(Long[] ids) { |
| | | public AjaxResult deleteData(Long ids) { |
| | | List<ZfClan> zfClans = listByIds(Arrays.asList(ids)); |
| | | for (ZfClan zfClan : zfClans) { |
| | | if (!zfClan.getAdminId().equals(getUserId())) { |
| | | throw new RuntimeException("您不是管理员,没有权力删除该家族"); |
| | | } |
| | | } |
| | | |
| | | zfClanManageService.deleteMember(ids); |
| | | if (zfClanService.removeByIds(Arrays.asList(ids))) { |
| | | |
| | | //删除es中的数据 |
| | |
| | | } |
| | | }); |
| | | |
| | | |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |