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

  async mapAll(attrs) {
    var result = {};
    attrs = attrs || "*";
    var sql = "SELECT " + attrs + " FROM `o_process`";
    var list = await this.customQuery(sql);
    if (!list || list.length == 0) {
      return result;
    }
    for (var item of list) {
      result[item.id] = item;
    }
    return result;
  }

  async findMapByIds(ids, attrs) {
    var result = {};
    if (!ids || ids.length == 0) {
      return result;
    }
    attrs = attrs || "*";
    var sql = "SELECT " + attrs + " FROM `o_process` WHERE id IN (:ids)";

    var list = await this.customQuery(sql, {
      ids: ids
    });

    if (!list || list.length == 0) {
      return result;
    }

    for (var item of list) {
      result[item.id] = item;
    }
    return result;
  }
}
module.exports = OprocessDao;