|
|
@@ -3,8 +3,10 @@ package com.webflux.launchadmin.mysql.service.groupUsers;
|
|
|
import com.webflux.launchadmin.config.BaseContextHandler;
|
|
|
import com.webflux.launchadmin.global.BaseException;
|
|
|
import com.webflux.launchadmin.mysql.controller.groupUsers.res.DeleteRes;
|
|
|
+import com.webflux.launchadmin.mysql.controller.groupUsers.res.GroupUsersRes;
|
|
|
import com.webflux.launchadmin.mysql.entity.groupUsers.Dto.GroupUsersDto;
|
|
|
import com.webflux.launchadmin.mysql.entity.groupUsers.GroupUsers;
|
|
|
+import com.webflux.launchadmin.mysql.entity.planNew.GroupType;
|
|
|
import com.webflux.launchadmin.mysql.entity.planNew.PlanNew;
|
|
|
import com.webflux.launchadmin.mysql.repository.groupUsers.GroupUsersRepository;
|
|
|
import com.webflux.launchcommon.returnObj.Paged;
|
|
|
@@ -22,6 +24,8 @@ import reactor.core.publisher.Mono;
|
|
|
import java.time.ZonedDateTime;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class GroupUsersServiceImpl implements GroupUsersServiceInterface {
|
|
|
@@ -31,7 +35,7 @@ public class GroupUsersServiceImpl implements GroupUsersServiceInterface {
|
|
|
private R2dbcEntityTemplate template;
|
|
|
|
|
|
@Override
|
|
|
- public Mono<RStatus<Paged<GroupUsers>>> page(Integer type, int page, int size) {
|
|
|
+ public Mono<RStatus<Paged<GroupUsersRes>>> page(Integer type, int page, int size) {
|
|
|
Criteria criteria = Criteria.empty();
|
|
|
if (Objects.nonNull(type) &&type>0) {
|
|
|
criteria = criteria.and("group_users_type").is(type);
|
|
|
@@ -46,11 +50,44 @@ public class GroupUsersServiceImpl implements GroupUsersServiceInterface {
|
|
|
.sort(Sort.by(Sort.Order.desc("created_at"))), GroupUsers.class)
|
|
|
.onErrorResume(throwable -> Mono.error(new BaseException("查询失败::error::" + throwable.getMessage())))
|
|
|
.collectList();
|
|
|
- Mono<Paged<GroupUsers>> pagedMono = Mono.zip(count, created_at).flatMap(f -> {
|
|
|
- Paged<GroupUsers> groupUsersPaged = new Paged<>(f.getT1(), f.getT2(), page, size);
|
|
|
- return Mono.just(groupUsersPaged);
|
|
|
+ Mono<Paged<GroupUsersRes>> id1 = Mono.zip(count, created_at).flatMap(f -> {
|
|
|
+ List<GroupUsers> t2 = f.getT2();
|
|
|
+ List<Integer> collect = t2.stream()
|
|
|
+ .filter(f3->Objects.nonNull(f3.groupUsersType()))
|
|
|
+ .map(GroupUsers::groupUsersType)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (collect.isEmpty()) {
|
|
|
+ collect.add(0);
|
|
|
+ }
|
|
|
+ Mono<List<GroupType>> id = template.select(Query.query(Criteria.where("id").in(collect)), GroupType.class)
|
|
|
+ .collectList()
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("查询groupType异常" + throwable.getMessage())));
|
|
|
+ return Mono.zip(id, Mono.just(f.getT1()), Mono.just(f.getT2())).flatMap(fff -> {
|
|
|
+ List<GroupUsers> t3 = fff.getT3();
|
|
|
+ Long t21 = fff.getT2();
|
|
|
+ List<GroupType> t1 = fff.getT1();
|
|
|
+ List<GroupUsersRes> collect1 = t3.stream().map(fm -> {
|
|
|
+ GroupUsersRes groupUsersRes = new GroupUsersRes();
|
|
|
+ groupUsersRes.setGroupUsersId(fm.groupUsersId());
|
|
|
+ groupUsersRes.setGroupUsersHead(fm.groupUsersHead());
|
|
|
+ groupUsersRes.setGroupUsersType(fm.groupUsersType());
|
|
|
+ groupUsersRes.setGroupUsersNickname(fm.groupUsersNickname());
|
|
|
+ groupUsersRes.setCreatedAt(fm.createdAt());
|
|
|
+ groupUsersRes.setCreateUser(fm.createUser());
|
|
|
+ return groupUsersRes;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ collect1.stream().filter(f1 -> Objects.nonNull(f1.getGroupUsersType())).forEach(fe1 -> {
|
|
|
+ Optional<String> first = t1.stream()
|
|
|
+ .filter(f11 -> f11.id() == Long.valueOf(fe1.getGroupUsersType()))
|
|
|
+ .map(GroupType::name).findFirst();
|
|
|
+ first.ifPresent(fe1::setGroupUsersName);
|
|
|
+ });
|
|
|
+ Paged<GroupUsersRes> groupUsersPaged = new Paged<>(t21, collect1, page, size);
|
|
|
+ return Mono.just(groupUsersPaged);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
- return RStatus.successList(pagedMono);
|
|
|
+ return RStatus.successList(id1);
|
|
|
}
|
|
|
|
|
|
@Override
|