const system = require("../../../system");
const Dao = require("../../dao.base");

class electroniccontractDao extends Dao {
    constructor() {
        super(Dao.getModelName(electroniccontractDao));
    }

    async statCount(companyNames) {
        var result = {};
        if(!companyNames || companyNames.length == 0) {
            return result;
        }
        var sql = "SELECT company_name, COUNT(1) AS num FROM `electronic_contract_info` WHERE company_name IN (:companyNames) GROUP BY company_name";

        let list = await this.customQuery(sql, {companyNames: companyNames});

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

        for (var item of list) {
            result[item.company_name] = item.num || 0;
        }
        return result;
    }
}

module.exports = electroniccontractDao;