|
@@ -11,6 +11,7 @@ class GroupService extends CrudService {
|
|
|
constructor(ctx) {
|
|
|
super(ctx, 'group');
|
|
|
this.model = this.ctx.model.Group;
|
|
|
+ this.smodel = this.ctx.model.Student;
|
|
|
}
|
|
|
|
|
|
async insert(data) {
|
|
@@ -39,6 +40,27 @@ class GroupService extends CrudService {
|
|
|
}
|
|
|
await group.save();
|
|
|
}
|
|
|
+
|
|
|
+ // 设置学生为组长或组员
|
|
|
+ async sethead(data) {
|
|
|
+ const { groupid, stuid, type } = data;
|
|
|
+ const group = await this.model.findById(groupid);
|
|
|
+ const students = group.students;
|
|
|
+ for (const student of students) {
|
|
|
+ if (student.stuid === stuid) {
|
|
|
+ student.type = type;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ await group.save();
|
|
|
+ const student = await this.smodel.findById(stuid);
|
|
|
+ if (type === '1') {
|
|
|
+ student.jod = '组长';
|
|
|
+ }
|
|
|
+ if (type === '0') {
|
|
|
+ student.jod = '普通学生';
|
|
|
+ }
|
|
|
+ await student.save();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|