feat:实现全异步改造

This commit is contained in:
wangyu 2021-12-07 23:03:21 +08:00
parent 6d088e20a9
commit 1c51ec78ab

View File

@ -8,26 +8,27 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.stream.Collectors;
import com.flyfish.framework.bean.Result;
import com.flyfish.framework.configuration.annotations.PagedQuery;
import com.flyfish.framework.domain.base.Vo;
import com.flyfish.framework.service.BaseService;
import com.flyfish.framework.service.BaseReactiveService;
@RestController
@RequestMapping("#{uri}")
public class #{className} {
@Autowired
protected BaseService<#{beanClassName}> service;
protected BaseReactiveService<#{beanClassName}> service;
@GetMapping("views")
public Result<List<Vo<#{beanClassName}>>> getVoList(@PagedQuery #{queryBeanClassName}#{queryBeanSuffix} qo) {
public Mono<Result<List<Vo<#{beanClassName}>>>> getVoList(@PagedQuery #{queryBeanClassName}#{queryBeanSuffix} qo) {
if (null != qo.getPageable()) {
return Result.accept(service.getPageList(qo).map(item -> new #{listViewClassName}().from(item)));
return service.getPageList(qo).map(page -> page.map(item -> new #{listViewClassName}().from(item)))
.map(Result::accept);
}
return Result.accept(service.getList(qo).stream()
.map(item -> new #{listViewClassName}().from(item)).collect(Collectors.toList()));
return service.getList(qo).map(item -> new #{listViewClassName}().from(item))
.collectList()
.map(Result::accept);
}
}