lrf 2 år sedan
förälder
incheckning
29989cf0e8

+ 41 - 0
app/controller/business/config/.lesson.js

@@ -0,0 +1,41 @@
+module.exports = {
+  create: {
+    requestBody: ['school_id', 'coach_id', 'class_hour', 'money', 'type'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['school_id', 'coach_id', 'class_hour', 'money', 'type'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        school_id: 'school_id',
+        coach_id: 'coach_id',
+        type: 'type',
+        student: 'student',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 13 - 0
app/controller/business/lesson.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.lesson.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+//
+class LessonController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.business.lesson;
+  }
+}
+module.exports = CrudController(LessonController, meta);

+ 39 - 0
app/controller/relation/config/.relationCoachSchool.js

@@ -0,0 +1,39 @@
+module.exports = {
+  create: {
+    requestBody: ['!coach_id', '!school_id', 'doc'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['coach_id', 'school_id', 'doc'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        coach_id: 'coach_id',
+        school_id: 'school_id',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 39 - 0
app/controller/relation/config/.relationStudentCoach.js

@@ -0,0 +1,39 @@
+module.exports = {
+  create: {
+    requestBody: ['!student_id', '!coach_id', 'doc', 'config'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['student_id', 'coach_id', 'doc', 'config'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        student_id: 'student_id',
+        coach_id: 'coach_id',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 37 - 0
app/controller/relation/config/.relationStudentSchool.js

@@ -0,0 +1,37 @@
+module.exports = {
+  create: {
+    requestBody: ['student_id', 'school_id', 'doc'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['student_id', 'school_id', 'doc'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 13 - 0
app/controller/relation/relationCoachSchool.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.relationCoachSchool.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+//
+class RelationCoachSchoolController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.relation.relationCoachSchool;
+  }
+}
+module.exports = CrudController(RelationCoachSchoolController, meta);

+ 13 - 0
app/controller/relation/relationStudentCoach.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.relationStudentCoach.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+// 
+class RelationStudentCoachController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.relation.relationStudentCoach;
+  }
+}
+module.exports = CrudController(RelationStudentCoachController, meta);

+ 13 - 0
app/controller/relation/relationStudentSchool.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.relationStudentSchool.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+//
+class RelationStudentSchoolController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.relation.relationStudentSchool;
+  }
+}
+module.exports = CrudController(RelationStudentSchoolController, meta);

+ 2 - 2
app/controller/user/config/.school.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ['yyzz', 'name', 'brief', 'img_url', 'address', 'phone', 'coach_num', 'student_num', 'past_student', 'honor', 'url', 'user_id'],
+    requestBody: ['name', 'brief', 'phone', 'address', 'coach_num', 'student_num', 'honor', 'url', 'yyzz', 'img_url', 'user_id'],
   },
   destroy: {
     params: ['!id'],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['yyzz', 'name', 'brief', 'img_url', 'address', 'phone', 'coach_num', 'student_num', 'past_student', 'honor', 'url', 'user_id'],
+    requestBody: ['name', 'brief', 'phone', 'address', 'coach_num', 'student_num', 'honor', 'url', 'yyzz', 'img_url', 'user_id'],
   },
   show: {
     parameters: {

+ 25 - 0
app/model/business/lesson.js

@@ -0,0 +1,25 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 课程表
+const lesson = {
+  school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
+  coach_id: { type: String, required: false, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
+  class_hour: { type: Number, required: false, zh: '课时' }, //
+  money: { type: Number, required: false, zh: '金额' }, //
+  student: { type: Array, ref: 'Student', getProp: [ 'name' ], zh: '学员' },
+  type: { type: String, required: false, zh: '类型' }, // 0-公开课;1-私教课
+};
+const schema = new Schema(lesson, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ school_id: 1 });
+schema.index({ coach_id: 1 });
+schema.index({ type: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Lesson', schema, 'lesson');
+};

+ 21 - 0
app/model/relation/relationCoachSchool.js

@@ -0,0 +1,21 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 教练与学校的关系表
+const relationCoachSchool = {
+  coach_id: { type: String, required: true, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
+  school_id: { type: String, required: true, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
+  doc: { type: Object, required: false, zh: '教练档案' }, //
+};
+const schema = new Schema(relationCoachSchool, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ coach_id: 1 });
+schema.index({ school_id: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('RelationCoachSchool', schema, 'relationCoachSchool');
+};

+ 22 - 0
app/model/relation/relationStudentCoach.js

@@ -0,0 +1,22 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 学员与教练关系表
+const relationStudentCoach = {
+  student_id: { type: String, required: true, zh: '学生id', ref: 'Student', getProp: [ 'name' ] }, //
+  coach_id: { type: String, required: true, zh: '教练id', ref: 'Coach', getProp: [ 'name' ] }, //
+  doc: { type: Object, required: false, zh: '档案' }, //
+  config: { type: Object, required: false, zh: '设置' }, //
+};
+const schema = new Schema(relationStudentCoach, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ student_id: 1 });
+schema.index({ coach_id: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('RelationStudentCoach', schema, 'relationStudentCoach');
+};

+ 21 - 0
app/model/relation/relationStudentSchool.js

@@ -0,0 +1,21 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 学员与学校关系表
+const relationStudentSchool = {
+  student_id: { type: String, required: false, zh: '学员id', ref: 'Student', getProp: [ 'name' ] }, //
+  school_id: { type: String, required: false, zh: '学校id', ref: 'School', getProp: [ 'name' ] }, //
+  doc: { type: Object, required: false, zh: '档案' }, //
+};
+const schema = new Schema(relationStudentSchool, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ student_id: 1 });
+schema.index({ school_id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('RelationStudentSchool', schema, 'relationStudentSchool');
+};

+ 3 - 5
app/model/user/school.js

@@ -2,20 +2,18 @@
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 
-
 // 学校
 const school = {
-  yyzz: { type: Array, required: false, zh: '营业执照' }, //
   name: { type: String, required: false, zh: '名称' }, //
   brief: { type: String, required: false, zh: '简介' }, //
-  img_url: { type: Array, required: false, zh: '图片' }, //
-  address: { type: String, required: false, zh: '训练地址' }, //
   phone: { type: String, required: false, zh: '联系方式' }, //
+  address: { type: String, required: false, zh: '训练地址' }, //
   coach_num: { type: Number, required: false, default: '0', zh: '教练人数' }, //
   student_num: { type: Number, required: false, default: '0', zh: '学员人数' }, //
-  past_student: { type: String, required: false, zh: '历届学员' }, //
   honor: { type: String, required: false, zh: '过往荣誉' }, //
   url: { type: String, required: false, zh: '网址' }, //
+  yyzz: { type: Array, required: false, zh: '营业执照' }, //
+  img_url: { type: Array, required: false, zh: '图片' }, //
   user_id: { type: String, required: false, zh: '用户表信息', ref: 'User', getProp: [ 'name' ] }, //
 };
 const schema = new Schema(school, { toJSON: { virtuals: true } });

+ 4 - 0
app/router.js

@@ -29,4 +29,8 @@ module.exports = app => {
   require('./z_router/user/coach')(app); // 教练
   require('./z_router/user/school')(app); // 学院
   require('./z_router/user/student')(app); // 学员
+  require('./z_router/relation/relationCoachSchool')(app); // 教练与学校关系
+  require('./z_router/relation/relationStudentSchool')(app); // 学员与学校关系
+  require('./z_router/relation/relationStudentCoach')(app); // 学员与教练关系
+  require('./z_router/business/lesson')(app); // 课程
 };

+ 15 - 0
app/service/business/lesson.js

@@ -0,0 +1,15 @@
+'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 LessonService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'lesson');
+    this.model = this.ctx.model.Business.Lesson;
+  }
+}
+
+module.exports = LessonService;

+ 15 - 0
app/service/relation/relationCoachSchool.js

@@ -0,0 +1,15 @@
+'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 RelationCoachSchoolService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'relationcoachschool');
+    this.model = this.ctx.model.Relation.RelationCoachSchool;
+  }
+}
+
+module.exports = RelationCoachSchoolService;

+ 15 - 0
app/service/relation/relationStudentCoach.js

@@ -0,0 +1,15 @@
+'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 RelationStudentCoachService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'relationstudentcoach');
+    this.model = this.ctx.model.RelationStudentCoach;
+  }
+}
+
+module.exports = RelationStudentCoachService;

+ 15 - 0
app/service/relation/relationStudentSchool.js

@@ -0,0 +1,15 @@
+'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 RelationStudentSchoolService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'relationstudentschool');
+    this.model = this.ctx.model.Relation.RelationStudentSchool;
+  }
+}
+
+module.exports = RelationStudentSchoolService;

+ 19 - 0
app/z_router/business/lesson.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'lesson';
+const ckey = 'business.lesson';
+const keyZh = '课程表';
+const routes = [
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  routerRegister(app, routes, keyZh, rkey, ckey);
+};

+ 19 - 0
app/z_router/relation/relationCoachSchool.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'rcs';
+const ckey = 'relation.relationCoachSchool';
+const keyZh = '教练与学校关系';
+const routes = [
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  routerRegister(app, routes, keyZh, rkey, ckey);
+};

+ 19 - 0
app/z_router/relation/relationStudentCoach.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'rsc';
+const ckey = 'relation.relationStudentCoach';
+const keyZh = '学员与教练关系';
+const routes = [
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  routerRegister(app, routes, keyZh, rkey, ckey);
+};

+ 19 - 0
app/z_router/relation/relationStudentSchool.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'rss';
+const ckey = 'relation.relationStudentSchool';
+const keyZh = '学员与学校关系';
+const routes = [
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  routerRegister(app, routes, keyZh, rkey, ckey);
+};

+ 1 - 1
package.json

@@ -14,7 +14,7 @@
     "egg-scripts": "^2.11.0",
     "lodash": "^4.17.21",
     "moment": "^2.29.1",
-    "naf-framework-mongoose-free": "^0.0.23"
+    "naf-framework-mongoose-free": "^0.0.24"
   },
   "devDependencies": {
     "autod": "^3.0.1",