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

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

    async statCount(companyNames, sign_body_id) {
        var result = {};
        var sql = "SELECT company_name, COUNT(1) AS num FROM recruit_info WHERE 1=1  ";


        if (sign_body_id) {
           sql = sql + "AND sign_body_id = :sign_body_id";
        }

        sql = sql + " GROUP BY company_name"

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

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

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

module.exports = RecruitDao;
