const Dao = require("../../dao.base");
class productDao extends Dao {
  constructor() {
    super(Dao.getModelName(productDao));
  }

  async getPage (page = 1, offset = 10, type = [0, 1]) {
    return await this.model.findAndCountAll({
      where: { product_type: { [this.db.Op.in]: type } },
      limit: offset,
      offset: (page - 1) * offset
    })
  }

  async getAllDic (type = [0, 1]) {
    // TODO: 筛选字段
    return await this.model.findAll({
      where: { product_type: { [this.db.Op.in]: type } }
    })
  }

  async getByIds (ids) {
    return await this.model.getAll({
      where: { id: { [this.db.Op.in]: ids } }
    })
  }
}
module.exports = productDao;