forked from opentiny/tiny-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlang.controller.ts
More file actions
68 lines (63 loc) · 1.67 KB
/
Copy pathlang.controller.ts
File metadata and controls
68 lines (63 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import {
Body,
Controller,
Delete,
Get,
Param,
ParseIntPipe,
Patch,
Post,
} from '@nestjs/common';
import { I18LangService } from './lang.service';
import { CreateLang } from './dto/create-lang.dto';
import { Permission } from '../public/permission.decorator';
import { Reject } from '../public/reject.decorator';
import { ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiParam } from '@nestjs/swagger';
import { Lang } from '@app/models';
@Controller('/lang')
export class I18nLangController {
constructor(private readonly langService: I18LangService) {}
@ApiOperation({summary: '创建一个语言'})
@ApiCreatedResponse({type: Lang})
@Permission('lang::add')
@Post('')
createLang(@Body() data: CreateLang) {
return this.langService.create(data);
}
@ApiOperation({summary: '列出所有的语言'})
@ApiCreatedResponse({type: [Lang]})
@Permission('lang::query')
@Get('')
findAllLang() {
return this.langService.findAll();
}
@ApiOperation({summary: '修改某个的语言'})
@ApiOkResponse({type: Lang})
@ApiParam({
name: 'id',
description: '语言的数据库主键',
type: Number
})
@Reject()
@Permission('lang::update')
@Patch(':id')
updateLang(
@Param('id', ParseIntPipe) id: number,
@Body() data: Partial<CreateLang>
) {
return this.langService.update(id, data);
}
@ApiOperation({summary: '修改某个的语言'})
@ApiOkResponse({type: Lang})
@ApiParam({
name: 'id',
description: '语言的数据库主键',
type: Number
})
@Reject()
@Permission('lang::remove')
@Delete(':id')
removeLang(@Param('id', ParseIntPipe) id: number) {
return this.langService.remove(id);
}
}