chore: fix some code
This commit is contained in:
@@ -55,7 +55,6 @@
|
||||
"@socket.io/redis-emitter": "^5.1.0",
|
||||
"@trpc/server": "10.45.1",
|
||||
"@types/lodash": "^4.14.201",
|
||||
"database": "workspace:*",
|
||||
"axios": "^1.6.1",
|
||||
"bcrypt": "^5.1.1",
|
||||
"bull": "^4.11.4",
|
||||
@@ -65,6 +64,7 @@
|
||||
"cron": "^3.1.6",
|
||||
"cron-parser": "^4.9.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"database": "workspace:*",
|
||||
"dayjs": "^1.11.10",
|
||||
"dotenv": "16.3.1",
|
||||
"dotenv-expand": "^10.0.0",
|
||||
|
||||
@@ -3,5 +3,5 @@ export default async () => {
|
||||
const t = {
|
||||
["./modules/auth/auth.model"]: await import("./modules/auth/auth.model")
|
||||
};
|
||||
return { "@nestjs/swagger": { "models": [[import("./modules/auth/auth.dto"), { "LoginDto": {}, "RegisterDto": {} }], [import("./common/dto/id.dto"), { "IdDto": {} }], [import("./common/dto/pager.dto"), { "PagerDto": {} }], [import("./modules/user/dto/password.dto"), { "PasswordUpdateDto": {}, "UserPasswordDto": {} }], [import("./modules/user/dto/user.dto"), { "UserDto": {}, "UserUpdateDto": {}, "UserQueryDto": {} }], [import("./modules/user/dto/account.dto"), { "UpdateProfileDto": {}, "ResetPasswordDto": {} }], [import("./modules/user/dto/search.dto"), { "UserSearchDto": {} }], [import("./common/dto/delete.dto"), { "BatchDeleteDto": {} }], [import("./modules/todo/todo.dto"), { "TodoDto": {}, "TodoUpdateDto": {}, "TodoPagerDto": {} }], [import("./modules/auth/captcha/captcha.dto"), { "ImageCaptchaDto": {}, "SendEmailCodeDto": {}, "SendSmsCodeDto": {}, "CheckCodeDto": {} }], [import("./modules/file/file.dto"), { "FileQueryDto": {}, "FileUploadDto": {} }], [import("./common/dto/image.dto"), { "ImagesDto": {} }]], "controllers": [[import("./modules/user/user.controller"), { "UserController": { "list": {}, "getUserById": {}, "create": {}, "update": {}, "delete": {}, "password": {} } }], [import("./modules/auth/auth.admin.controller"), { "AuthAdminController": { "login": {} } }], [import("./modules/auth/auth.controller"), { "AuthController": { "login": {}, "register": {} } }], [import("./modules/auth/captcha/captcha.controller"), { "CaptchaController": { "captchaByImg": { type: t["./modules/auth/auth.model"].ImageCaptcha } } }], [import("./modules/auth/controllers/account.controller"), { "AccountController": { "profile": {}, "updateProfile": {}, "logout": {}, "password": {} } }], [import("./modules/auth/controllers/email.controller"), { "EmailController": { "sendEmailCode": {} } }], [import("./modules/file/file.controller"), { "FileController": { "getTypes": { type: Object }, "get": {}, "upload": {}, "uploadMultiple": { type: [Object] }, "delete": {} } }], [import("./modules/todo/todo.controller"), { "TodoController": { "list": {}, "findOne": {}, "create": {}, "update": {}, "delete": {}, "batchDelete": {} } }]] } };
|
||||
return { "@nestjs/swagger": { "models": [[import("./modules/auth/auth.dto"), { "LoginDto": {}, "RegisterDto": {} }], [import("./common/dto/id.dto"), { "IdDto": {} }], [import("./common/dto/pager.dto"), { "PagerDto": {} }], [import("./modules/user/dto/password.dto"), { "PasswordUpdateDto": {}, "UserPasswordDto": {} }], [import("./modules/user/dto/user.dto"), { "UserDto": {}, "UserUpdateDto": {}, "UserQueryDto": {} }], [import("./modules/user/dto/account.dto"), { "UpdateProfileDto": {}, "ResetPasswordDto": {} }], [import("./modules/user/dto/search.dto"), { "UserSearchDto": {} }], [import("./common/dto/delete.dto"), { "BatchDeleteDto": {} }], [import("./modules/todo/todo.dto"), { "TodoDto": {}, "TodoUpdateDto": {}, "TodoPagerDto": {} }], [import("./modules/auth/captcha/captcha.dto"), { "ImageCaptchaDto": {}, "SendEmailCodeDto": {}, "SendSmsCodeDto": {}, "CheckCodeDto": {} }], [import("./modules/file/file.dto"), { "FileQueryDto": {}, "FileUploadDto": {} }], [import("./common/dto/image.dto"), { "ImagesDto": {} }]], "controllers": [[import("./modules/user/user.controller"), { "UserController": { "list": {}, "getUserById": {}, "create": {}, "update": {}, "delete": {}, "password": {} } }], [import("./modules/auth/auth.admin.controller"), { "AuthAdminController": { "login": {} } }], [import("./modules/auth/auth.controller"), { "AuthController": { "login": {}, "register": {} } }], [import("./modules/auth/captcha/captcha.controller"), { "CaptchaController": { "captchaByImg": { type: t["./modules/auth/auth.model"].ImageCaptcha } } }], [import("./modules/auth/controllers/account.controller"), { "AccountController": { "profile": {}, "updateProfile": {}, "logout": {}, "password": {} } }], [import("./modules/auth/controllers/email.controller"), { "EmailController": { "sendEmailCode": {} } }], [import("./modules/file/file.controller"), { "FileController": { "getTypes": { type: Object }, "get": {}, "upload": {}, "uploadMultiple": { type: [Object] }, "delete": {} } }], [import("./modules/todo/todo.controller"), { "TodoController": { "list": {}, "page": {}, "findOne": {}, "create": {}, "update": {}, "delete": {}, "batchDelete": {} } }]] } };
|
||||
};
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Injectable, OnModuleInit } from '@nestjs/common'
|
||||
|
||||
import { BizException } from '@server/common/exceptions/biz.exception'
|
||||
import { ErrorCodeEnum } from '@server/constants/error-code.constant'
|
||||
import { TRPCRouter } from '@server/shared/trpc/trpc.decorator'
|
||||
import { defineTrpcRouter } from '@server/shared/trpc/trpc.helper'
|
||||
import { TRPCService } from '@server/shared/trpc/trpc.service'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { AuthService } from './auth.service'
|
||||
import { CredentialsSchema } from './auth.dto'
|
||||
import { BizException } from '@server/common/exceptions/biz.exception'
|
||||
import { ErrorCodeEnum } from '@server/constants/error-code.constant'
|
||||
import { AuthService } from './auth.service'
|
||||
|
||||
@TRPCRouter()
|
||||
@Injectable()
|
||||
@@ -41,7 +41,7 @@ export class AuthTrpcRouter implements OnModuleInit {
|
||||
if (user.role === 'Admin')
|
||||
throw new BizException(ErrorCodeEnum.PasswordMismatch)
|
||||
|
||||
const jwt = await this.authService.sign(user.id, user.role, { ip, ua })
|
||||
const jwt = await this.authService.sign(user.id, user.role)
|
||||
|
||||
return {
|
||||
data: { authToken: jwt },
|
||||
|
||||
@@ -5,9 +5,9 @@ import { ApiSecurityAuth } from '@server/common/decorators/swagger.decorator'
|
||||
import { AuthUser } from '@server/modules/auth/decorators/auth-user.decorator'
|
||||
import { PasswordUpdateDto } from '@server/modules/user/dto/password.dto'
|
||||
|
||||
import { UpdateProfileDto } from '../../user/dto/account.dto'
|
||||
import { UserService } from '../../user/user.service'
|
||||
import { AuthService } from '../auth.service'
|
||||
import { UpdateProfileDto } from '../../user/dto/account.dto'
|
||||
import { JwtAuthGuard } from '../guards/jwt-auth.guard'
|
||||
|
||||
@ApiTags('Account - 账户模块')
|
||||
@@ -27,9 +27,10 @@ export class AccountController {
|
||||
|
||||
@Put('profile')
|
||||
async updateProfile(
|
||||
@AuthUser() user: IAuthUser, @Body() dto: UpdateProfileDto,
|
||||
@AuthUser() user: IAuthUser, @Body()
|
||||
dto: UpdateProfileDto,
|
||||
): Promise<void> {
|
||||
await this.userService.updateProfile(user.id, dto)
|
||||
await this.userService.updateProfile(dto, user.id)
|
||||
}
|
||||
|
||||
@Get('logout')
|
||||
|
||||
@@ -14,7 +14,6 @@ export enum Action {
|
||||
export type PrismaSubjects = {
|
||||
User: User
|
||||
Todo: Todo
|
||||
|
||||
}
|
||||
|
||||
export type AppAbility = PureAbility<[Action, Subjects<PrismaSubjects>]>
|
||||
|
||||
@@ -20,10 +20,16 @@ import { TodoService } from './todo.service'
|
||||
export class TodoController {
|
||||
constructor(private readonly todoService: TodoService) { }
|
||||
|
||||
@Get('page')
|
||||
@Get()
|
||||
@Policy({ model: 'Todo', action: Action.Manage })
|
||||
async list(@Query() dto: TodoPagerDto, @AuthUser() user: IAuthUser) {
|
||||
return this.todoService.paginate(dto, user.id)
|
||||
return this.todoService.list(dto, user.id)
|
||||
}
|
||||
|
||||
@Get('page')
|
||||
@Policy({ model: 'Todo', action: Action.Manage })
|
||||
async page(@Query() dto: TodoPagerDto, @AuthUser() user: IAuthUser) {
|
||||
return this.todoService.paginate(dto)
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
|
||||
@@ -29,15 +29,6 @@ export class UserPublicService {
|
||||
},
|
||||
select: {
|
||||
...UserSelect,
|
||||
gender: true,
|
||||
yoId: true,
|
||||
campus: {
|
||||
select: {
|
||||
id: true,
|
||||
logo: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}).catch(resourceNotFoundWrapper(
|
||||
new BizException(ErrorCodeEnum.UserNotFound),
|
||||
|
||||
Reference in New Issue
Block a user