| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | 'use strict';/** * 初始化控制器 * * @author CaiAoLin * @date 2017/11/24 * @version */module.exports = app => {    class BootController extends app.BaseController {        /**         * 初始化用户信息页面         *         * @param {Object} ctx - egg全局变量         * @return {void}         */        async index(ctx) {            const rule = ctx.service.customer.rule('boot');            const jsValidator = await this.jsValidator.convert(rule).build();            const renderData = {                jsValidator,            };            await ctx.render('boot/index.ejs', renderData);        }        /**         * 初始化用户         *         * @param {Object} ctx - egg全局变量         * @return {void}         */        async boot(ctx) {            try {                const rule = ctx.service.customer.rule('boot');                ctx.validate(rule);                const result = await ctx.service.customer.boot(ctx.request.body);                console.log(result);            } catch (error) {                console.log(error);            }            ctx.body = 'test';        }    }    return BootController;};
 |