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

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

    async infoById(id) {
        let sql = [];
        sql.push("SELECT");
        sql.push("t1.*,");
        sql.push("t2.`name` AS merchant_name");
        sql.push("FROM `e_merchant_api` t1");
        sql.push("INNER JOIN `e_merchant` t2 ON t1.`merchant_id` = t2.`id`");
        sql.push("WHERE t1.id = :id");
        sql.push("LIMIT 1");

        let list = await this.customQuery(sql.join(" "), {id: id});
        if (!list || list.length == 0) {
            return null;
        }
        return list[0];
    }

}

module.exports = MerchantapiDao;

