jhipster:不支持在角度客户端过滤实体的jhipster生成?

时间:2018-12-31 15:33:23

标签: typescript filter jhipster entities

这是我根据他人的工作来解决问题的尝试, 但这不起作用,因为向VkaResource的转移会导致VkaCriteria的所有字段均为空:

摘自VkaResource:

 /**
 * GET  /vkas : get all the vkas.
 *
 * @param pageable the pagination information
 * @param criteria the criterias which the requested entities should match
 * @return the ResponseEntity with status 200 (OK) and the list of vkas in body
 */
@GetMapping("/vkas")
@Timed
public ResponseEntity<List<VkaDTO>> getAllVkas(VkaCriteria criteria, Pageable pageable) {
    log.debug("REST request to get Vkas by criteria: {}", criteria);
    Page<VkaDTO> page = vkaQueryService.findByCriteria(criteria, pageable);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/vkas");
    return ResponseEntity.ok().headers(headers).body(page.getContent());
}

这是vka.Component.ts中的Angular代码:

       this.criteria = {
        mkt1: null,
        vnr: null,
        wirkungGueltigAb: null,
        wirkungGueltigBis: null,
        areSet() {
            return this.mkt1 != null || this.vnr != null || this.wirkungGueltigAb != null || this.wirkungGueltigBis != null;
        },
        clear() {
            this.mkt1 = null;
            this.vnr = null;
            this.wirkungDatAb = null;
            this.wirkungDatBis = null;
        }
    };
 }
    loadAll() {
     const criteria = [];

    if (this.criteria.areSet()) {
        if (this.criteria.mkt1 != null && this.criteria.mkt1 !== '') {
            criteria.push({key: 'mkt1.equals', value: this.criteria.mkt1});
        }
        if (this.criteria.vnr != null && this.criteria.vnr >= 0) {
            criteria.push({key: 'vnr.equals', value: this.criteria.vnr});
        }
       if (this.criteria.wirkungGueltigAb != null && this.criteria.wirkungGueltigAb >= 0) {
            criteria.push({key: 'wirkungGueltigAb.equals', value: this.criteria.wirkungGueltigAb});
        }
       if (this.criteria.wirkungGueltigBis != null && this.criteria.wirkungGueltigBis >= 0) {
            criteria.push({key: 'wirkungGueltigBis.equals', value: this.criteria.wirkungGueltigBis});
        }
    }
        this.vkaService
        .query({
            criteria,
            page: this.page - 1,
            size: this.itemsPerPage,
            sort: this.sort()
        })
        .subscribe(
            (res: HttpResponse<IVkaVka[]>) => this.paginateVkas(res.body, res.headers),
            (res: HttpErrorResponse) => this.onError(res.message)
        );
}

这是来自request-util.ts的代码

import { HttpParams } from '@angular/common/http';

export const createRequestOption = (req?: any): HttpParams => {
    let options: HttpParams = new HttpParams();
    if (req) {
        Object.keys(req).forEach(key => {
            if (key !== 'sort') {
                options = options.set(key, req[key]);
            }
        });
        if (req.sort) {
            req.sort.forEach(val => {
                options = options.append('sort', val);
            });
        }
    }
    return options;
};

那么,怎么了?

0 个答案:

没有答案