studentApplyForSchool.js 791 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose-free/lib/service');
  3. const { BusinessError, ErrorCode } = require('naf-core').Error;
  4. const _ = require('lodash');
  5. const assert = require('assert');
  6. //
  7. class StudentApplyForSchoolService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'studentapplyforschool');
  10. this.model = this.ctx.model.Relation.StudentApplyForSchool;
  11. this.rssModel = this.ctx.model.Relation.RelationStudentSchool;
  12. }
  13. async afterUpdate(filter, body, data) {
  14. const { result, student_id, school_id } = data;
  15. if (result !== '1') return data;
  16. // 审核通过,建立关系
  17. const obj = { school_id, student_id };
  18. await this.rssModel.create(obj);
  19. return data;
  20. }
  21. }
  22. module.exports = StudentApplyForSchoolService;