guochao.js 630 Bytes
/* eslint-disable array-callback-return */
const { actGuochaoShop } = require('../../../db');

class GuochaoModel extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    list(obj) {

        if (!obj.order.length) {
            obj.order = ['sort', 'desc'];
        }

        return actGuochaoShop.findAll({where: obj.where, order: [obj.order]});
    }

    update(obj) {
        let where = {id: obj.id};

        delete obj.id;
        return actGuochaoShop.update(obj, {where: where});
    }

    findById(id) {
        return actGuochaoShop.findById(id);
    }
}

module.exports = GuochaoModel;