const userInfoService = require('./../services/user') const userCode = require('./../codes/user') module.exports = { /** * 登录操作 * @param {obejct} ctx 上下文对象 */ async signIn( ctx ) { let formData = ctx.request.body let result = { success: false, message: '', data: null, code: '' } let userResult = await userInfoService.signIn( formData ) if ( userResult ) { if ( formData.userName === userResult.name ) { result.success = true } else { result.message = userCode.FAIL_USER_NAME_OR_PASSWORD_ERROR result.code = 'FAIL_USER_NAME_OR_PASSWORD_ERROR' } } else { result.code = 'FAIL_USER_NAME_OR_PASSWORD_ERROR', result.message = userCode.FAIL_USER_NAME_OR_PASSWORD_ERROR } ctx.body = result }, }