const ServiceBase = require("../sve.base");

class DktemplatebusiService extends ServiceBase {
    constructor() {
        super(ServiceBase.getDaoName(DktemplatebusiService));
    }

    async getlist(id) {
        var sql = "SELECT * FROM c_dktemplate_busi WHERE template_id = :template_id";
        var page = await this.customQuery(sql,{template_id:id});
        return page;
    }
    async busiIdsByTemplateId(template_id) {
        var sql = "SELECT busi_id FROM c_dktemplate_busi WHERE template_id = :template_id";
        var list = await this.customQuery(sql, {template_id: template_id});
        let rs = [];
        if (!list || list.length == 0) {
            return rs;
        }
        for (let item of list) {
            rs.push(item.busi_id);
        }
        return rs;
    }

    async getinfo(qobj) {
        var sql = "SELECT * FROM c_dktemplate_busi WHERE template_id = " + qobj.template_id + " AND busi_id = " + qobj.company_id;
        var page = await this.customQuery(sql);
        return page;
    }

    async deleteTetId(qobj) {
        let sql = "DELETE FROM c_dktemplate_busi WHERE id = " + qobj.id;
        await this.customExecAddOrPutSql(sql);
        return 1;
    }

    async suggest(name, ownerIds) {
        return await this.dao.suggest(name, ownerIds);
    }

    async saveto(etebusi) {
        return await this.create(etebusi);

    }
}

module.exports = DktemplatebusiService;
