40 lines
1.4 KiB
Smarty
40 lines
1.4 KiB
Smarty
package #{packageName};
|
|
|
|
import #{beanClass};
|
|
import #{queryBeanClass};
|
|
import #{listViewClass};
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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 com.flyfish.framework.bean.Result;
|
|
import com.flyfish.framework.configuration.annotations.PagedQuery;
|
|
import com.flyfish.framework.domain.base.Vo;
|
|
import com.flyfish.framework.service.BaseReactiveService;
|
|
import reactor.core.publisher.Mono;
|
|
import reactor.core.publisher.Flux;
|
|
|
|
@RestController
|
|
@RequestMapping("#{uri}")
|
|
public class #{className} {
|
|
|
|
@Autowired
|
|
protected BaseReactiveService<#{beanClassName}> service;
|
|
|
|
@GetMapping("views")
|
|
public Mono<Result<List<Vo<#{beanClassName}>>>> getVoList(@PagedQuery #{queryBeanClassName}#{queryBeanSuffix} qo) {
|
|
if (null != qo.getPageable()) {
|
|
return service.getPageList(qo)
|
|
.map(Result::accept)
|
|
.flatMap(result -> result.flatMap(list -> Flux.fromIterable(list)
|
|
.flatMap(item -> new #{listViewClassName}().retrieve(item))
|
|
.collectList()));
|
|
}
|
|
return service.getList(qo).flatMap(item -> new #{listViewClassName}().retrieve(item))
|
|
.collectList()
|
|
.map(Result::accept);
|
|
}
|
|
|
|
}
|