category.js 379 B

123456789101112131415
  1. 'use strict';
  2. /**
  3. * model
  4. */
  5. export default class extends think.model.base {
  6. async getChildCategoryId(parentId){
  7. return await this.where({parent_id: parentId}).getField('id', 10000);
  8. }
  9. async getCategoryWhereIn(categoryId){
  10. let childIds = await this.getChildCategoryId(categoryId);
  11. childIds.push(categoryId);
  12. return childIds;
  13. }
  14. }