Skip to content

Commit

Permalink
Merge pull request #1044 from ever-co/feat/#1039-edit-experience-for-…
Browse files Browse the repository at this point in the history
…candidate

Feat/#1039 edit experience for candidate
  • Loading branch information
rmagon committed Apr 23, 2020
2 parents 5b2dfb5 + 848a563 commit ff9bf28
Show file tree
Hide file tree
Showing 33 changed files with 633 additions and 276 deletions.
12 changes: 12 additions & 0 deletions apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CandidateSkillModule } from './candidate-skill/candidate-skill.module';
import { InvoiceModule } from './invoice/invoice.module';
import { InvoiceItemModule } from './invoice-item/invoice-item.module';
import { TagModule } from './tags/tag.module';
Expand Down Expand Up @@ -61,6 +62,7 @@ import { IntegrationEntitySettingTiedEntityModule } from './integration-entity-s
import { CandidateCvModule } from './candidate-cv/candidate-cv.module';
import { CandidateEducationModule } from './candidate-education/candidate-education.module';
import { CandidateSourceModule } from './candidate_source/candidate_source.module';
import { CandidateExperienceModule } from './candidate-experience/candidate-experience.module';

@Module({
imports: [
Expand All @@ -76,6 +78,14 @@ import { CandidateSourceModule } from './candidate_source/candidate_source.modul
path: '/candidate-educations',
module: CandidateEducationModule
},
{
path: '/candidate-experience',
module: CandidateExperienceModule
},
{
path: '/candidate-skills',
module: CandidateSkillModule
},
{
path: '/candidate-cv',
module: CandidateCvModule
Expand Down Expand Up @@ -244,6 +254,8 @@ import { CandidateSourceModule } from './candidate_source/candidate_source.modul
CandidateCvModule,
CandidateSourceModule,
CandidateEducationModule,
CandidateExperienceModule,
CandidateSkillModule,
ExportAllModule,
ImportAllModule,
EmployeeSettingModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
import { CandidateEducationService } from './candidate-education.service';
import {
Controller,
UseGuards,
Get,
Query,
HttpStatus,
HttpCode,
Delete,
Param,
Put,
Body
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { CrudController } from '../core/crud/crud.controller';
import { AuthGuard } from '@nestjs/passport';
import { CandidateEducation } from './candidate-education.entity';
import { IPagination } from '../core';
import { Education } from 'libs/models/src/lib/candidate-education.model';

@ApiTags('candidate_educations')
@UseGuards(AuthGuard('jwt'))
@Controller()
export class CandidateEducationController extends CrudController<
CandidateEducation
Expand All @@ -29,68 +14,4 @@ export class CandidateEducationController extends CrudController<
) {
super(candidateEducationService);
}
////// GET
@ApiOperation({
summary: 'Find all candidate education.'
})
@ApiResponse({
status: HttpStatus.OK,
description: 'Found candidate education',
type: CandidateEducation
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
description: 'Record not found'
})
@Get()
async findEducations(
@Query('data') data: string
): Promise<IPagination<CandidateEducation>> {
const { findInput } = JSON.parse(data);
return this.candidateEducationService.findAll({ where: findInput });
}

///////// UPDATE
@ApiOperation({ summary: 'Update an education' })
@ApiResponse({
status: HttpStatus.CREATED,
description: 'The education has been successfully edited.'
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
description: 'Education not found'
})
@ApiResponse({
status: HttpStatus.BAD_REQUEST,
description:
'Invalid input, The response body may contain clues as to what went wrong'
})
@HttpCode(HttpStatus.ACCEPTED)
@Put(':id')
async update(
@Param('id') id: string,
@Body() entity: Education
): Promise<any> {
return this.candidateEducationService.update(id, { ...entity });
}

/////// DELETE
@ApiOperation({ summary: 'Delete record' })
@ApiResponse({
status: HttpStatus.NO_CONTENT,
description: 'The record has been successfully deleted'
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
description: 'Record not found'
})
@ApiResponse({
status: HttpStatus.BAD_REQUEST,
description: "This Education can't be deleted"
})
@HttpCode(HttpStatus.ACCEPTED)
@Delete(':id')
async delete(@Param('id') id: string, ...options: any[]): Promise<any> {
return this.candidateEducationService.deleteEducation(id);
}
}
13 changes: 10 additions & 3 deletions apps/api/src/app/candidate-education/candidate-education.entity.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Column, Entity } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { Education } from 'libs/models/src/lib/candidate-education.model';
import { Base } from '../core/entities/base';
import { IsString, IsNotEmpty } from 'class-validator';
import { IEducation } from '@gauzy/models';

@Entity('candidate_educations')
export class CandidateEducation extends Base implements Education {
export class CandidateEducation extends Base implements IEducation {
@ApiProperty({ type: String })
@Column()
schoolName: string;
Expand All @@ -22,6 +23,12 @@ export class CandidateEducation extends Base implements Education {
completionDate: Date;

@ApiProperty({ type: String })
@Column()
@Column({ nullable: true })
notes?: string;

@ApiProperty({ type: String })
@IsString()
@IsNotEmpty()
@Column()
candidateId?: string;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, BadRequestException } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { CrudService } from '../core/crud/crud.service';
Expand All @@ -14,15 +14,4 @@ export class CandidateEducationService extends CrudService<CandidateEducation> {
) {
super(candidateEducationRepository);
}
async deleteEducation(educationId) {
const education = await this.candidateEducationRepository
.createQueryBuilder('education')
.getOne();

if (education) {
throw new BadRequestException("This Education can't be deleted ");
}

return await this.delete(educationId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { CrudController } from '../core/crud/crud.controller';
import { CandidateExperienceService } from './candidate-experience.service';
import { CandidateExperience } from './candidate-experience.entity';

@ApiTags('candidate_experience')
@Controller()
export class CandidateExperienceController extends CrudController<
CandidateExperience
> {
constructor(
private readonly candidateExperienceService: CandidateExperienceService
) {
super(candidateExperienceService);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Column, Entity } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { Base } from '../core/entities/base';
import { IsString, IsNotEmpty } from 'class-validator';
import { IExperience } from '@gauzy/models';

@Entity('candidate_experience')
export class CandidateExperience extends Base implements IExperience {
@ApiProperty({ type: String })
@Column()
occupation: string;

@ApiProperty({ type: String })
@Column()
organization: string;

@ApiProperty({ type: String })
@Column()
duration: string;

@ApiProperty({ type: String })
@Column({ nullable: true })
description?: string;

@ApiProperty({ type: String })
@IsString()
@IsNotEmpty()
@Column()
candidateId?: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CandidateExperience } from './candidate-experience.entity';
import { CandidateExperienceService } from './candidate-experience.service';
import { CandidateExperienceController } from './candidate-experience.controller';

@Module({
imports: [TypeOrmModule.forFeature([CandidateExperience])],
providers: [CandidateExperienceService],
controllers: [CandidateExperienceController],
exports: [CandidateExperienceService]
})
export class CandidateExperienceModule {}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { CrudService } from '../core/crud/crud.service';
import { CandidateExperience } from './candidate-experience.entity';

@Injectable()
export class CandidateExperienceService extends CrudService<
CandidateExperience
> {
constructor(
@InjectRepository(CandidateExperience)
private readonly candidateExperienceRepository: Repository<
CandidateExperience
>
) {
super(candidateExperienceRepository);
}
}
13 changes: 13 additions & 0 deletions apps/api/src/app/candidate-skill/candidate-skill.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { CrudController } from '../core/crud/crud.controller';
import { CandidateSkill } from './candidate-skill.entity';
import { CandidateSkillService } from './candidate-skill.service';

@ApiTags('candidate_skills')
@Controller()
export class CandidateSkillController extends CrudController<CandidateSkill> {
constructor(private readonly candidateSkillService: CandidateSkillService) {
super(candidateSkillService);
}
}
18 changes: 18 additions & 0 deletions apps/api/src/app/candidate-skill/candidate-skill.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Column, Entity } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { Base } from '../core/entities/base';
import { IsString, IsNotEmpty } from 'class-validator';
import { ISkill } from '@gauzy/models';

@Entity('candidate_skills')
export class CandidateSkill extends Base implements ISkill {
@ApiProperty({ type: String })
@Column()
name: string;

@ApiProperty({ type: String })
@IsString()
@IsNotEmpty()
@Column()
candidateId?: string;
}
13 changes: 13 additions & 0 deletions apps/api/src/app/candidate-skill/candidate-skill.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CandidateSkill } from './candidate-skill.entity';
import { CandidateSkillService } from './candidate-skill.service';
import { CandidateSkillController } from './candidate-skill.controller';

@Module({
imports: [TypeOrmModule.forFeature([CandidateSkill])],
providers: [CandidateSkillService],
controllers: [CandidateSkillController],
exports: [CandidateSkillService]
})
export class CandidateSkillModule {}
Empty file.
15 changes: 15 additions & 0 deletions apps/api/src/app/candidate-skill/candidate-skill.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { CrudService } from '../core/crud/crud.service';
import { CandidateSkill } from './candidate-skill.entity';

@Injectable()
export class CandidateSkillService extends CrudService<CandidateSkill> {
constructor(
@InjectRepository(CandidateSkill)
private readonly candidateSkillRepository: Repository<CandidateSkill>
) {
super(candidateSkillRepository);
}
}

0 comments on commit ff9bf28

Please sign in to comment.