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

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


    async allList(params) {
        var currentPage = Number(params.currentPage || 0);
        var pageSize = Number(params.pageSize || 10);

        var where = {};
        if (params.appId) {
            where.appId = {
                [this.db.Op.eq]: params.appId
            };
        }
        if (params.mchtId) {
            where.mchtId = {
                [this.db.Op.eq]: params.mchtId
            };
        }

        var orderby = [
            ["id", 'desc']
        ];

        var page = await this.getPageList(currentPage, pageSize, where, orderby);
        if (page && page.rows) {
            for (var row of page.rows) {
                this.handleDate(row, ["created_at"]);
            }
        }
        return page;
    }
}

module.exports = EcompanybusiService;
