初始化:职引项目 v1.0
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common'
|
||||
import { InjectModel } from '@nestjs/mongoose'
|
||||
import { Model } from 'mongoose'
|
||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
|
||||
import { DailyQuestion, DailyQuestionDocument } from '../schemas/daily-question.schema'
|
||||
|
||||
@Controller('daily-question')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class DailyQuestionController {
|
||||
constructor(
|
||||
@InjectModel(DailyQuestion.name) private dailyQuestionModel: Model<DailyQuestionDocument>,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
async getToday(@Query('position') position?: string) {
|
||||
const filter: any = {}
|
||||
if (position) filter.position = position
|
||||
|
||||
const question = await this.dailyQuestionModel
|
||||
.findOne(filter)
|
||||
.sort({ date: -1 })
|
||||
.exec()
|
||||
|
||||
if (!question) {
|
||||
// Return a default question if no specific one found
|
||||
const defaultQ = await this.dailyQuestionModel.findOne().sort({ date: -1 }).exec()
|
||||
if (defaultQ) return defaultQ
|
||||
|
||||
return {
|
||||
position: '通用',
|
||||
question: '请做一个简单的自我介绍,突出你的核心优势和职业目标。',
|
||||
referenceAnswer: '建议结构:1) 基本信息 2) 教育背景与专业 3) 实习/项目经历中的亮点 4) 为什么选择这个岗位 5) 职业目标。控制在1-2分钟内。',
|
||||
category: 'behavioral',
|
||||
}
|
||||
}
|
||||
|
||||
return question
|
||||
}
|
||||
|
||||
@Get('position/:position')
|
||||
async getByPosition(@Param('position') position: string) {
|
||||
const questions = await this.dailyQuestionModel
|
||||
.find({ position })
|
||||
.sort({ date: -1 })
|
||||
.limit(10)
|
||||
.exec()
|
||||
|
||||
return questions.length > 0 ? questions : [
|
||||
{
|
||||
position,
|
||||
question: `作为${position}岗位的候选人,请分享一个你最有成就感的项目经历。`,
|
||||
referenceAnswer: '使用STAR法则:Situation(背景)、Task(任务)、Action(行动)、Result(结果),重点突出你在项目中的角色和贡献。',
|
||||
category: 'project',
|
||||
},
|
||||
{
|
||||
position,
|
||||
question: `在${position}岗位上,你认为自己最大的优势是什么?最大的不足是什么?`,
|
||||
referenceAnswer: '优势要结合岗位要求,用具体例子支撑;不足要真实但可改进,说明你已经在如何提升。',
|
||||
category: 'behavioral',
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user