|
@@ -11,12 +11,24 @@ class ProductService extends CrudService {
|
|
|
this.organization = this.ctx.model.Organization;
|
|
|
}
|
|
|
async query({ skip = 0, limit = 0, ...query } = {}) {
|
|
|
- const { code, ...oq } = query;
|
|
|
+ const { code, company, ...oq } = query;
|
|
|
let res = [];
|
|
|
let total = 0;
|
|
|
if (!code) {
|
|
|
- res = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit));
|
|
|
- total = await this.model.count(query);
|
|
|
+ if (!company) {
|
|
|
+ res = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit));
|
|
|
+ total = await this.model.count(query);
|
|
|
+ } else {
|
|
|
+ // 处理company特殊的情况
|
|
|
+ let nquery = {};
|
|
|
+ if (company === '中科系') nquery.company = [ '中科院长春分院', '中国科学院东北地理与农业生态研究所', '中国科学院长春应用化学研究所', '中科院长春光学精密机械与物理研究所' ];
|
|
|
+ else if (company === '其他')nquery.company = { $nin: [ '中科院长春分院', '中国科学院东北地理与农业生态研究所', '中国科学院长春应用化学研究所', '中科院长春光学精密机械与物理研究所', '吉林大学', '长春工业大学' ] };
|
|
|
+ else nquery.company = company;
|
|
|
+ nquery = { ...oq, ...nquery };
|
|
|
+ res = await this.model.find(nquery).skip(parseInt(skip)).limit(parseInt(limit));
|
|
|
+ total = await this.model.count(nquery);
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
// 使用code查出个人,专家,机构下的产品,skip和limit限制的是最后产品,而不是角色那部分
|
|
|
let pl = await this.personal.find({ code }, '_id');
|