'use strict'; const { CrudService } = require('naf-framework-mongoose-free/lib/service'); const { BusinessError, ErrorCode } = require('naf-core').Error; const _ = require('lodash'); const assert = require('assert'); // class EmailService extends CrudService { constructor(ctx) { super(ctx, 'email'); this.httpUtil = this.ctx.service.util.httpUtil; this.emailServiceUrl = _.get(this.app, 'config.httpPrefix.email'); this.emailServiceConfig = _.get(this.app, 'config.emailConfig.config'); } async resetPwd(email, password) { const data = { config: this.emailServiceConfig, template: 'resetPwd', receiver: email, params: { password } }; const url = `${this.emailServiceUrl}/sendEmail`; await this.httpUtil.cpost(url, data); } async errorEmail(error) { const data = { config: this.emailServiceConfig, params: error }; const url = `${this.emailServiceUrl}/error`; await this.httpUtil.cpost(url, data); } } module.exports = EmailService;