25 lines
603 B
TypeScript
25 lines
603 B
TypeScript
![]() |
import { Context, Inject, Provide } from '@midwayjs/core';
|
||
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||
|
import { Repository } from 'typeorm';
|
||
|
import { Guide } from '../entity/guide.entity';
|
||
|
|
||
|
@Provide()
|
||
|
export class GuideService {
|
||
|
@Inject()
|
||
|
ctx: Context;
|
||
|
|
||
|
@InjectEntityModel(Guide)
|
||
|
guideModel: Repository<Guide>;
|
||
|
|
||
|
async create(guide: Guide) {
|
||
|
const guideCreateRes = await this.guideModel.save(guide);
|
||
|
return guideCreateRes.guide_id;
|
||
|
}
|
||
|
|
||
|
async select(course_id: string) {
|
||
|
return await this.guideModel.findOne({
|
||
|
where: { guide_course_id: course_id },
|
||
|
});
|
||
|
}
|
||
|
}
|