我想创建一个服务以填充数据库中的下拉列表。我尝试过:
商人阶层:
export class Merchant {
constructor(
public id: string,
public name: string,
public state_raw: string,
public users: string,
) {}
}
商家服务:
getList(): Observable<Merchant> {
return this.http.get<Merchant>(environment.api.urls.merchants.base, {});
}
Rest Api展示:
@GetMapping
public ResponseEntity<?> get() {
return merchantRepository
.findAll()
.map(mapper::toDTO)
.map(ResponseEntity::ok)
.orElseGet(() -> notFound().build());
}
SQL查询:
@Override
public Iterable<Merchants> findAll() {
String hql = "select e from " + Merchants.class.getName() + " e";
TypedQuery<Merchants> query = entityManager.createQuery(hql, Merchants.class);
List<Merchants> merchants = query.getResultList();
return merchants;
}
我这个错误:
The method map(mapper::toDTO) is undefined for the type Iterable<Merchants>
我应如何正确实施此响应?