boot_controller.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. /**
  3. * 初始化控制器
  4. *
  5. * @author CaiAoLin
  6. * @date 2017/11/24
  7. * @version
  8. */
  9. module.exports = app => {
  10. class BootController extends app.BaseController {
  11. /**
  12. * 初始化用户信息页面
  13. *
  14. * @param {Object} ctx - egg全局变量
  15. * @return {void}
  16. */
  17. async index(ctx) {
  18. const rule = ctx.service.customer.rule('boot');
  19. const jsValidator = await this.jsValidator.convert(rule).build();
  20. const renderData = {
  21. jsValidator,
  22. };
  23. await ctx.render('boot/index.ejs', renderData);
  24. }
  25. /**
  26. * 初始化用户
  27. *
  28. * @param {Object} ctx - egg全局变量
  29. * @return {void}
  30. */
  31. async boot(ctx) {
  32. try {
  33. const rule = ctx.service.customer.rule('boot');
  34. ctx.validate(rule);
  35. const result = await ctx.service.customer.boot(ctx.request.body);
  36. } catch (error) {
  37. this.log(err);
  38. }
  39. ctx.body = 'test';
  40. }
  41. }
  42. return BootController;
  43. };