| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.sql.SQLIntegrityConstraintViolationException; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | |
| | | Page<ZfClan> pageResult = page(zfClanPage, lqw); |
| | | |
| | | List<ZfClan> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | // System.out.println(beanRecords); |
| | | |
| | | |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords); |
| | | return AjaxResult.success(data); } |
| | | |
| | | @Override |
| | | public AjaxResult selectData() { |
| | | List<ZfClan> lis = this.list(); |
| | | return AjaxResult.success(lis); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ZfClan zfClan){ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfClan> selectByCondition(ZfClan zfClan) { |
| | | |
| | | System.out.println("8008888//"+zfClan.getClanId()); |
| | | LambdaQueryWrapper<ZfClan> lambdaQueryWrapper = buildCondition(zfClan); |
| | | lambdaQueryWrapper.eq(zfClan.getClanId()!=null,ZfClan::getClanId,zfClan.getClanId()); |
| | | |
| | | return list(lambdaQueryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZfClan> selectByIds(Long[] ids) { |
| | | List<ZfClan> list = new ArrayList<>(); |
| | | if(ids.length!=0) |
| | | list = listByIds(Arrays.asList(ids)); |
| | | else |
| | | list = list(); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addData(ZfClan zfClan) { |
| | | LambdaQueryWrapper<ZfClan> lqw = uniqueCondition(zfClan); |
| | | List<ZfClan> list = list(lqw); |
| | | |
| | | |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复家族"); |
| | |
| | | ZfLog zfLog = new ZfLog(); |
| | | zfLog.setUpdateTime(LocalDateTime.now()); |
| | | zfLog.setModule("家族"); |
| | | zfLog.setUpdater(zInfoUserService.getMyself().getNickName()); |
| | | // zfLog.setUpdater(zInfoUserService.getMyself().getNickName()); |
| | | zfLogService.save(zfLog); |
| | | |
| | | LambdaQueryWrapper<ZfClan> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.orderByDesc(ZfClan::getClanId); |
| | | lqw.eq(StringUtils.isNotEmpty(zfClan.getClanName()), ZfClan::getClanName, zfClan.getClanName()); |
| | | List<ZfClan> lis = this.list(lqw); |
| | | // System.out.println("===================================="+meeting); |
| | | if(updateById(zfClan)){ |
| | | //到数据库中查询对应的数据 |
| | | ZfClan dataById = getById(zfClan.getClanId()); |
| | | if(lis.size()>0) |
| | | { |
| | | return AjaxResult.success("家族名称不能重复!"); |
| | | |
| | | //先到es中查询到对应那条数据在es的id |
| | | EsModel esResult = esSer.findByCtId(dataById.getClanId(), "家族"); |
| | | // System.out.println("===================================="+meeting); |
| | | if (esResult == null){ |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | //操作es修改数据 |
| | | EsModel newModel = new EsModel(); |
| | | if(zfClan.getClanName()!=null){ |
| | | newModel.setBy1(zfClan.getClanName()); |
| | | }else { |
| | | newModel.setBy1(dataById.getClanName()); |
| | | } |
| | | // |
| | | |
| | | UpdateRequest updateRequest = new UpdateRequest("allsearchdata", esResult.getId()); |
| | | updateRequest.doc( |
| | | "by1",newModel.getBy1() |
| | | |
| | | ); |
| | | |
| | | try { |
| | | restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | else |
| | | { |
| | | boolean res = updateById(zfClan); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | // if(res){ |
| | | |
| | | // }else { |
| | | // return AjaxResult.success("家族名称不能重复!"); |
| | | // } |
| | | |
| | | |
| | | |
| | | // return AjaxResult.success("家族名称不能重复!"); |
| | | // //到数据库中查询对应的数据 |
| | | // ZfClan dataById = getById(zfClan.getClanId()); |
| | | // |
| | | // //先到es中查询到对应那条数据在es的id |
| | | // EsModel esResult = esSer.findByCtId(dataById.getClanId(), "家族"); |
| | | //// System.out.println("===================================="+meeting); |
| | | // if (esResult == null){ |
| | | // return AjaxResult.success(); |
| | | // } |
| | | // |
| | | // //操作es修改数据 |
| | | // EsModel newModel = new EsModel(); |
| | | // if(zfClan.getClanName()!=null){ |
| | | // newModel.setBy1(zfClan.getClanName()); |
| | | // }else { |
| | | // newModel.setBy1(dataById.getClanName()); |
| | | // } |
| | | //// |
| | | // |
| | | // UpdateRequest updateRequest = new UpdateRequest("allsearchdata", esResult.getId()); |
| | | // updateRequest.doc( |
| | | // "by1",newModel.getBy1() |
| | | // |
| | | // ); |
| | | |
| | | // try { |
| | | // restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT); |
| | | // } catch (IOException e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | 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中的数据 |
| | |
| | | }); |
| | | |
| | | |
| | | |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |