web-backset.cn/apps/server/src/service/guide.service.ts

25 lines
603 B
TypeScript
Raw Normal View History

2023-03-12 22:30:09 +08:00
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 },
});
}
}