-
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.
- Loading branch information
yuanjunjie
committed
Jul 26, 2024
1 parent
57f6ba0
commit c669c8c
Showing
20 changed files
with
630 additions
and
96 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
80 changes: 80 additions & 0 deletions
80
nest-admin/servers/src/website/memorandum-management/memorandum/dto/memorandum.dto.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsString, Length, IsOptional, IsNotEmpty, IsIn } from 'class-validator' | ||
import { StatusValue2 } from 'src/common/enums/common.enum' | ||
import { ReqListQuery } from 'src/common/utils/req-list-query' | ||
import { ReqQuery } from 'src/common/utils/req-query' | ||
import { $enum } from 'ts-enum-util' | ||
|
||
export class AddMemorandumDto extends ReqQuery { | ||
@ApiProperty({ description: '标题' }) | ||
@IsString({ message: 'name 类型错误, 正确类型 string' }) | ||
@IsNotEmpty({ message: 'name 不能为空' }) | ||
@Length(0, 100, { message: 'name 字符长度在 0~100' }) | ||
readonly name: string | ||
|
||
@ApiProperty({ description: '内容' }) | ||
@IsString({ message: 'content 类型错误, 正确类型 string' }) | ||
@IsNotEmpty({ message: 'content 不能为空' }) | ||
readonly content: string | ||
|
||
@ApiProperty({ description: '备忘录分类', required: false }) | ||
@IsString( { each: true, message: 'id集合中存在类型错误, 正确类型 string[]' }) | ||
@IsNotEmpty({ message: 'categories 不能为空' }) | ||
readonly categories?: string[] | ||
} | ||
|
||
export class SetStickPost extends ReqQuery { | ||
@ApiProperty({ description: 'id' }) | ||
@IsString({ message: 'id 类型错误,正确类型 number' }) | ||
@IsNotEmpty({ message: 'id 不能为空' }) | ||
readonly id: string | ||
|
||
@ApiProperty({ description: '是否置顶 0-否 1-是', enum: $enum(StatusValue2).getValues() }) | ||
@IsNotEmpty({ message: 'stickyPost 不能为空' }) | ||
@IsIn($enum(StatusValue2).getValues(), { message: 'stickyPost 的值只能是 0/1' }) | ||
readonly stickyPost: StatusValue2 | ||
} | ||
|
||
export class UpdateMemorandumDto extends AddMemorandumDto { | ||
@ApiProperty({ description: 'id' }) | ||
@IsString({ message: 'id 类型错误,正确类型 number' }) | ||
@IsNotEmpty({ message: 'id 不能为空' }) | ||
id: string | ||
} | ||
|
||
export class DeleteMemorandumDto extends ReqQuery { | ||
@ApiProperty({ description: 'id' }) | ||
@IsString({ message: 'id 类型错误,正确类型 number' }) | ||
@IsNotEmpty({ message: 'id 不能为空' }) | ||
id: string | ||
} | ||
|
||
export class FindPageDto extends ReqListQuery { | ||
|
||
@ApiProperty({ description: '昵称模糊搜索', required: false }) | ||
readonly name?: string | ||
|
||
@ApiProperty({ description: '开始时间', required: false }) | ||
readonly startDate?: Date | ||
|
||
@ApiProperty({ description: '开始时间', required: false }) | ||
readonly endDate?: Date | ||
|
||
@ApiProperty({ description: '备忘录分类', required: false }) | ||
readonly categories?: string[] | ||
} | ||
|
||
export class FindListDto { | ||
|
||
@ApiProperty({ description: '昵称模糊搜索', required: false }) | ||
name?: string | ||
|
||
@ApiProperty({ description: '开始时间', required: false }) | ||
startDate?: Date | ||
|
||
@ApiProperty({ description: '开始时间', required: false }) | ||
endDate?: Date | ||
|
||
@ApiProperty({ description: '备忘录分类', required: false }) | ||
readonly categories?: string[] | ||
} |
58 changes: 54 additions & 4 deletions
58
nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.controller.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,62 @@ | ||
import { Controller, Get, Post, UploadedFile, UseInterceptors, Query, HttpCode, Body, Req } from '@nestjs/common' | ||
import { FileInterceptor } from '@nestjs/platform-express' | ||
import { ApiTags, ApiOperation, ApiConsumes, ApiBody, ApiBearerAuth } from '@nestjs/swagger' | ||
import { Controller, Get, Post, UseInterceptors, Query, Body, Delete, Put } from '@nestjs/common' | ||
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger' | ||
import { ResultData } from 'src/common/utils/result' | ||
import { UpdateInterceptor } from 'src/common/guards/update.interceptor' | ||
import { ApiResult } from 'src/common/decorators/api-result.decorator' | ||
|
||
import { MemorandumService } from './memorandum.service' | ||
import { AddMemorandumDto, DeleteMemorandumDto, FindListDto, FindPageDto, SetStickPost, UpdateMemorandumDto } from './dto/memorandum.dto' | ||
import { MemorandumEntity } from './memorandum.entity' | ||
|
||
@ApiTags('备忘录类型') | ||
@ApiTags('备忘录') | ||
@ApiBearerAuth() | ||
@Controller('memorandum') | ||
export class MemorandumController { | ||
constructor(private readonly service: MemorandumService) {} | ||
|
||
@Post() | ||
@ApiOperation({ summary: '新增' }) | ||
@ApiResult() | ||
@UseInterceptors(UpdateInterceptor) | ||
async create(@Body() dto: AddMemorandumDto): Promise<ResultData> { | ||
return await this.service.add(dto) | ||
} | ||
|
||
@Delete() | ||
@ApiOperation({ summary: '删除' }) | ||
@ApiResult() | ||
@UseInterceptors(UpdateInterceptor) | ||
async delete(@Body() dto: DeleteMemorandumDto): Promise<ResultData> { | ||
return await this.service.delete(dto) | ||
} | ||
|
||
@Put() | ||
@ApiOperation({ summary: '更新' }) | ||
@ApiResult() | ||
@UseInterceptors(UpdateInterceptor) | ||
async update(@Body() dto: UpdateMemorandumDto): Promise<ResultData> { | ||
return await this.service.update(dto) | ||
} | ||
|
||
@Get('getPage') | ||
@ApiOperation({ summary: '查询分页数据列表' }) | ||
@ApiResult(MemorandumEntity, true, true) | ||
async getPage(@Query() dto: FindPageDto): Promise<ResultData> { | ||
return await this.service.getPage(dto) | ||
} | ||
|
||
@Put('setStickPost') | ||
@ApiOperation({ summary: '置顶文章' }) | ||
@ApiResult() | ||
@UseInterceptors(UpdateInterceptor) | ||
async setStickPost(@Body() dto: SetStickPost): Promise<ResultData> { | ||
return await this.service.setStickPost(dto) | ||
} | ||
|
||
@Get('getDetail') | ||
@ApiOperation({ summary: '查询分页数据列表' }) | ||
@ApiResult(MemorandumEntity, true, true) | ||
async getDetail(@Query() dto: DeleteMemorandumDto): Promise<ResultData> { | ||
return await this.service.getDetail2(dto.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
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
Oops, something went wrong.