-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #432 from skyclouds2001/dev
Dev
- Loading branch information
Showing
75 changed files
with
3,332 additions
and
2,294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...nd/src/interceptors/result.interceptor.ts → backend/src/common/result.interceptor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import { beforeEach, describe, expect, it } from 'vitest' | ||
import { DepartmentsController } from './departments.controller' | ||
import { DepartmentsService } from './departments.service' | ||
|
||
describe('DepartmentsController', () => { | ||
let controller: DepartmentsController | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [DepartmentsController], | ||
providers: [DepartmentsService], | ||
}).compile() | ||
|
||
controller = module.get<DepartmentsController>(DepartmentsController) | ||
}) | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { Controller, Get, Post, Body, Param, Delete, HttpStatus, HttpCode, Query, DefaultValuePipe, ParseIntPipe, Put } from '@nestjs/common' | ||
import { ApiBody, ApiCreatedResponse, ApiOkResponse, ApiParam, ApiQuery, ApiTags } from '@nestjs/swagger' | ||
import { DepartmentsService } from './departments.service' | ||
import { CreateDepartmentDto } from './dto/create-department.dto' | ||
import { UpdateDepartmentDto } from './dto/update-department.dto' | ||
import { DepartmentEntity } from './entities/department.entity' | ||
import { Pagination } from './../common/pagination.entity' | ||
|
||
@Controller('departments') | ||
@ApiTags('departments') | ||
export class DepartmentsController { | ||
constructor(private readonly departmentsService: DepartmentsService) {} | ||
|
||
@Post() | ||
@HttpCode(HttpStatus.OK) | ||
@ApiBody({ | ||
type: CreateDepartmentDto, | ||
description: '待添加的部门信息', | ||
}) | ||
@ApiCreatedResponse({ | ||
type: DepartmentEntity, | ||
description: '部门信息', | ||
}) | ||
create(@Body() createDepartmentDto: CreateDepartmentDto) { | ||
return this.departmentsService.create(createDepartmentDto) | ||
} | ||
|
||
@Get() | ||
@ApiOkResponse({ | ||
type: DepartmentEntity, | ||
isArray: true, | ||
description: '部门信息列表', | ||
}) | ||
findAll() { | ||
return this.departmentsService.findAll() | ||
} | ||
|
||
@Get('') | ||
@ApiQuery({ | ||
name: 'page', | ||
description: '分页页码', | ||
required: false, | ||
}) | ||
@ApiQuery({ | ||
name: 'size', | ||
description: '分页容量', | ||
required: false, | ||
}) | ||
@ApiOkResponse({ | ||
type: Pagination<DepartmentEntity>, | ||
description: '部门信息分页列表', | ||
}) | ||
async findPage(@Query('page', new DefaultValuePipe(1), ParseIntPipe) page: number, @Query('size', new DefaultValuePipe(10), ParseIntPipe) size: number) { | ||
return new Pagination(await this.departmentsService.findPage(page, size), page, size, await this.departmentsService.count()) | ||
} | ||
|
||
@Get(':id') | ||
@ApiParam({ | ||
name: 'id', | ||
description: '部门ID', | ||
}) | ||
@ApiOkResponse({ | ||
type: DepartmentEntity, | ||
description: '部门信息', | ||
}) | ||
findOne(@Param('id', ParseIntPipe) id: number) { | ||
return this.departmentsService.findOne(id) | ||
} | ||
|
||
@Put(':id') | ||
@ApiParam({ | ||
name: 'id', | ||
description: '部门ID', | ||
}) | ||
@ApiBody({ | ||
type: UpdateDepartmentDto, | ||
description: '待更新的部门信息', | ||
}) | ||
@ApiOkResponse({ | ||
type: DepartmentEntity, | ||
description: '部门信息', | ||
}) | ||
update(@Param('id', ParseIntPipe) id: number, @Body() updateDepartmentDto: UpdateDepartmentDto) { | ||
return this.departmentsService.update(id, updateDepartmentDto) | ||
} | ||
|
||
@Delete(':id') | ||
@ApiParam({ | ||
name: 'id', | ||
description: '部门ID', | ||
}) | ||
@ApiOkResponse({ | ||
type: DepartmentEntity, | ||
description: '部门信息', | ||
}) | ||
remove(@Param('id', ParseIntPipe) id: number) { | ||
return this.departmentsService.remove(id) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Module } from '@nestjs/common' | ||
import { PrismaModule } from 'nestjs-prisma' | ||
import { DepartmentsService } from './departments.service' | ||
import { DepartmentsController } from './departments.controller' | ||
|
||
@Module({ | ||
controllers: [DepartmentsController], | ||
providers: [DepartmentsService], | ||
imports: [PrismaModule], | ||
exports: [DepartmentsService], | ||
}) | ||
export class DepartmentsModule {} |
Oops, something went wrong.