| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2024-06-17 19:19:20 |
| 4 | * @LastEditTime: 2025-03-03 18:45:45 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: Cfg cfg |
| 7 | */ |
| 8 | import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common'; |
| 9 | import { ApiOperation } from '@nestjs/swagger'; |
| 10 | import { ParamsValidationPipe } from 'src/validation.pipe'; |
| 11 | import { CfgService } from './cfg.service'; |
| 12 | import { TableDto } from 'src/global/dto/table.dto'; |
| 13 | import { CfgIdDto, CfgKeyDto, CreateCfgDto } from './dto/cfg.dto'; |
| 14 | import { Manager } from 'src/auth/manager.guard'; |
| 15 | |
| 16 | @Manager() |
| 17 | @Controller('admin/cfg') |
| 18 | export class AdminCfgController { |
| 19 | constructor(private readonly cfgService: CfgService) {} |
| 20 | |
| 21 | @ApiOperation({ |
| 22 | description: '创建', |
| 23 | summary: '创建', |
| 24 | }) |
| 25 | @Post() |
| 26 | async create(@Body(new ParamsValidationPipe()) body: CreateCfgDto) { |
| 27 | const res = await this.cfgService.create(body); |
| 28 | return res; |
| 29 | } |
| 30 | |
| 31 | @ApiOperation({ |
| 32 | description: '获取信息', |
| 33 | summary: '获取信息', |
| 34 | }) |
| 35 | @Get('info/:id') |
| 36 | async getInfoById(@Param(new ParamsValidationPipe()) param: CfgIdDto) { |
| 37 | const res = await this.cfgService.getInfoById(param.id); |
| 38 | return res; |
| 39 | } |
| 40 | |
| 41 | @ApiOperation({ |
| 42 | description: '获取列表', |
| 43 | summary: '获取列表', |
| 44 | }) |
| 45 | @Get('list/:pageNo/:pageSize') |
| 46 | getList(@Param(new ParamsValidationPipe()) param: TableDto) { |
| 47 | return this.cfgService.getCfgList(param); |
| 48 | } |
| 49 | |
| 50 | @ApiOperation({ |
| 51 | description: '删除', |
| 52 | summary: '删除', |
| 53 | }) |
| 54 | @Delete(':key') |
| 55 | async del(@Param(new ParamsValidationPipe()) param: CfgKeyDto) { |
| 56 | const res = await this.cfgService.del(param.key); |
| 57 | return res; |
| 58 | } |
| 59 | } |
| 60 |