refactor: extract interface
This commit is contained in:
@@ -11,11 +11,8 @@ import {
|
||||
IsString,
|
||||
ValidateNested,
|
||||
} from 'class-validator'
|
||||
import {
|
||||
CountMixed,
|
||||
Paginator,
|
||||
WriteBaseModel,
|
||||
} from '~/shared/model/base.model'
|
||||
import { Paginator } from '~/shared/interface/paginator.interface'
|
||||
import { CountMixed, WriteBaseModel } from '~/shared/model/base.model'
|
||||
|
||||
@modelOptions({ schemaOptions: { id: false, _id: false } })
|
||||
export class Coordinate {
|
||||
|
||||
@@ -19,11 +19,8 @@ import {
|
||||
IsString,
|
||||
} from 'class-validator'
|
||||
import { Query } from 'mongoose'
|
||||
import {
|
||||
CountMixed as Count,
|
||||
Paginator,
|
||||
WriteBaseModel,
|
||||
} from '~/shared/model/base.model'
|
||||
import { Paginator } from '~/shared/interface/paginator.interface'
|
||||
import { CountMixed as Count, WriteBaseModel } from '~/shared/model/base.model'
|
||||
import { CategoryModel as Category } from '../category/category.model'
|
||||
|
||||
function autoPopulateCategory(
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
HttpCode,
|
||||
Patch,
|
||||
Post,
|
||||
SerializeOptions,
|
||||
UseGuards,
|
||||
} from '@nestjs/common'
|
||||
import { AuthGuard } from '@nestjs/passport'
|
||||
import { ApiBearerAuth, ApiOperation } from '@nestjs/swagger'
|
||||
import { Body, Controller, Get, HttpCode, Patch, Post } from '@nestjs/common'
|
||||
import { ApiOperation } from '@nestjs/swagger'
|
||||
import { Auth } from '~/common/decorator/auth.decorator'
|
||||
import { HttpCache } from '~/common/decorator/cache.decorator'
|
||||
import { CurrentUser } from '~/common/decorator/current-user.decorator'
|
||||
import { IpLocation, IpRecord } from '~/common/decorator/ip.decorator'
|
||||
@@ -36,9 +27,6 @@ export class UserController {
|
||||
}
|
||||
|
||||
@Post('register')
|
||||
@SerializeOptions({
|
||||
excludePrefixes: ['password'],
|
||||
})
|
||||
@ApiOperation({ summary: '注册' })
|
||||
async register(@Body() userDto: UserDto) {
|
||||
userDto.name = userDto.name ?? userDto.username
|
||||
@@ -71,17 +59,16 @@ export class UserController {
|
||||
|
||||
@Get('check_logged')
|
||||
@ApiOperation({ summary: '判断当前 Token 是否有效 ' })
|
||||
@ApiBearerAuth()
|
||||
@HttpCache({ disable: true })
|
||||
@Auth()
|
||||
@HttpCache.disable
|
||||
checkLogged(@IsMaster() isMaster: boolean) {
|
||||
return { ok: +isMaster, isGuest: !isMaster }
|
||||
}
|
||||
|
||||
@Patch()
|
||||
@ApiOperation({ summary: '修改主人的信息 ' })
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@HttpCache({ disable: true })
|
||||
@ApiOperation({ summary: '修改主人的信息' })
|
||||
@Auth()
|
||||
@HttpCache.disable
|
||||
async patchMasterData(
|
||||
@Body() body: UserPatchDto,
|
||||
@CurrentUser() user: UserDocument,
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
import { Paginator } from '../model/base.model'
|
||||
|
||||
export interface Pagination<T> {
|
||||
data: T[]
|
||||
pagination: Paginator
|
||||
}
|
||||
export class Paginator {
|
||||
/**
|
||||
* 总条数
|
||||
*/
|
||||
readonly total: number
|
||||
/**
|
||||
* 一页多少条
|
||||
*/
|
||||
readonly size: number
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
readonly currentPage: number
|
||||
/**
|
||||
* 总页数
|
||||
*/
|
||||
readonly totalPage: number
|
||||
readonly hasNextPage: boolean
|
||||
readonly hasPrevPage: boolean
|
||||
}
|
||||
|
||||
@@ -40,27 +40,6 @@ export class BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
export class Paginator {
|
||||
/**
|
||||
* 总条数
|
||||
*/
|
||||
readonly total: number
|
||||
/**
|
||||
* 一页多少条
|
||||
*/
|
||||
readonly size: number
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
readonly currentPage: number
|
||||
/**
|
||||
* 总页数
|
||||
*/
|
||||
readonly totalPage: number
|
||||
readonly hasNextPage: boolean
|
||||
readonly hasPrevPage: boolean
|
||||
}
|
||||
|
||||
@modelOptions({
|
||||
schemaOptions: { _id: false },
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user