home.js 1011 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. const Base = require('../base');
  3. /**
  4. * 项目首页
  5. */
  6. class HomeController extends Base {
  7. /**
  8. * [loginValidate 登录验证]
  9. * @author szjcomo
  10. * @createTime 2020-08-03
  11. * @return {[type]} [description]
  12. */
  13. get loginValidate() {
  14. const that = this;
  15. return {
  16. username: that.ctx.rules.name('用户名')
  17. .required(),
  18. };
  19. }
  20. /**
  21. * [index 访问首页]
  22. * @author szjcomo
  23. * @createTime 2020-08-03
  24. * @return {[type]} [description]
  25. */
  26. async index() {
  27. const that = this;
  28. try {
  29. // let result = await that.app.model.AdminUser.query('select * from szj_admin_user');
  30. const data = await that.ctx.validate(that.loginValidate, await that.ctx.getParse());
  31. return that.ctx.appJson(that.app.szjcomo.appResult('hi,szjcomo', data, false));
  32. } catch (err) {
  33. console.log(err);
  34. return that.ctx.appJson(that.app.szjcomo.appResult(err.message));
  35. }
  36. }
  37. }
  38. module.exports = HomeController;