"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.JobHuntingService = void 0; const common_1 = require("@nestjs/common"); const typeorm_1 = require("@nestjs/typeorm"); const job_hunting_model_1 = require("../../../model/job_hunting.model"); const typeorm_2 = require("typeorm"); const user_id_context_1 = require("../../common/context/user_id.context"); const api_1 = require("../../common/api"); let JobHuntingService = class JobHuntingService { jobHuntingModel; constructor(jobHuntingModel) { this.jobHuntingModel = jobHuntingModel; } async info(dto) { const userId = (0, user_id_context_1.getUserIdContext)(); const info = await this.jobHuntingModel.findOneBy({ userId, type: dto.type, }); return api_1.Api.success(info); } async apply(dto) { const userId = (0, user_id_context_1.getUserIdContext)(); const existingRecord = await this.jobHuntingModel.findOneBy({ userId, type: dto.type, }); if (existingRecord && existingRecord.status === job_hunting_model_1.JobHuntingStatus.Approved) { return api_1.Api.error('已审核通过,无法重复提交'); } if (existingRecord) { await this.jobHuntingModel.update({ id: existingRecord.id }, dto); } else { const verifyRecord = this.jobHuntingModel.create({ ...dto, status: job_hunting_model_1.JobHuntingStatus.Pending, userId, }); await this.jobHuntingModel.save(verifyRecord); } return api_1.Api.success(); } }; exports.JobHuntingService = JobHuntingService; exports.JobHuntingService = JobHuntingService = __decorate([ (0, common_1.Injectable)(), __param(0, (0, typeorm_1.InjectRepository)(job_hunting_model_1.JobHuntingModel)), __metadata("design:paramtypes", [typeorm_2.Repository]) ], JobHuntingService); //# sourceMappingURL=job_hunting.service.js.map