43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from "@nestjs/common";
|
|
|
|
import { CreateIndustryDto } from "./DTO/create-industry.dto";
|
|
import { IndustryListQueryDto } from "./DTO/industry-list-query.dto";
|
|
import { UpdateIndustryDto } from "./DTO/update-industry.dto";
|
|
import { IndustriesService } from "./services/industries.service";
|
|
import { ParamDto } from "../../common/DTO/param.dto";
|
|
|
|
@Controller("industries")
|
|
export class IndustriesController {
|
|
constructor(private readonly industriesService: IndustriesService) {}
|
|
|
|
@Post()
|
|
create(@Body() createIndustryDto: CreateIndustryDto) {
|
|
return this.industriesService.create(createIndustryDto);
|
|
}
|
|
|
|
@Get(":id")
|
|
getIndustryById(@Param() paramDto: ParamDto) {
|
|
return this.industriesService.getIndustriesById(paramDto.id);
|
|
}
|
|
|
|
@Patch(":id")
|
|
updateIndustry(@Param() paramDto: ParamDto, @Body() updateIndustryDto: UpdateIndustryDto) {
|
|
return this.industriesService.updateIndustry(paramDto.id, updateIndustryDto);
|
|
}
|
|
|
|
@Delete(":id")
|
|
deleteIndustry(@Param() paramDto: ParamDto) {
|
|
return this.industriesService.deleteIndustry(paramDto.id);
|
|
}
|
|
|
|
@Get("list")
|
|
getIndustriesForAdmin(@Query() query: IndustryListQueryDto) {
|
|
return this.industriesService.getIndustriesListForAdmin(query);
|
|
}
|
|
|
|
@Patch(":id/toggle-status")
|
|
toggleStatus(@Param() paramDto: ParamDto) {
|
|
return this.industriesService.toggleStatus(paramDto.id);
|
|
}
|
|
}
|