Skip to content

Commit 61e1d91

Browse files
authored
feat: palgear adapter (#101)
这个 PR 针对 palgear 的接口对 auth 进行调整 - 创建 session 支持指定 key ### 相关资料 - https://guild.adventurer.tech/projects/7/tickets/214
1 parent fde300e commit 61e1d91

3 files changed

Lines changed: 35 additions & 4 deletions

File tree

openapi.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"hash": "ce722f966bbb3c4eabd198291cd5cdc8eebf36391ba8eb0458d107822cfc8037",
2+
"hash": "3c5196d98b6096d6dcb28beda5cf923b703ff18e399556d63feff0bbccf7038b",
33
"openapi": "3.0.0",
44
"paths": {
55
"/hello": {
@@ -2353,6 +2353,14 @@
23532353
"type": "string"
23542354
}
23552355
},
2356+
{
2357+
"name": "key",
2358+
"required": false,
2359+
"in": "query",
2360+
"schema": {
2361+
"type": "string"
2362+
}
2363+
},
23562364
{
23572365
"name": "_limit",
23582366
"required": false,
@@ -2518,6 +2526,14 @@
25182526
"type": "string"
25192527
}
25202528
},
2529+
{
2530+
"name": "key",
2531+
"required": false,
2532+
"in": "query",
2533+
"schema": {
2534+
"type": "string"
2535+
}
2536+
},
25212537
{
25222538
"name": "_limit",
25232539
"required": false,
@@ -6807,6 +6823,9 @@
68076823
"CreateSessionDto": {
68086824
"type": "object",
68096825
"properties": {
6826+
"key": {
6827+
"type": "string"
6828+
},
68106829
"expireAt": {
68116830
"format": "date-time",
68126831
"type": "string",
@@ -7002,6 +7021,9 @@
70027021
"remark": {
70037022
"type": "string",
70047023
"description": "备注"
7024+
},
7025+
"key": {
7026+
"type": "string"
70057027
}
70067028
}
70077029
},
@@ -8428,6 +8450,9 @@
84288450
"type": "string",
84298451
"description": "备注"
84308452
},
8453+
"key": {
8454+
"type": "string"
8455+
},
84318456
"_limit": {
84328457
"type": "number",
84338458
"description": "分页大小"
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { OmitType } from '@nestjs/swagger';
2+
import { IsOptional, IsString } from 'class-validator';
23

34
import { SessionDoc } from '../entities/session.entity';
45

5-
export class CreateSessionDto extends OmitType(SessionDoc, ['key'] as const) {}
6+
export class CreateSessionDto extends OmitType(SessionDoc, ['key'] as const) {
7+
@IsOptional()
8+
@IsString()
9+
key?: string;
10+
}

src/session/session.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ export class SessionService {
1616
constructor(@InjectModel(Session.name) private readonly sessionModel: Model<SessionDocument>) {}
1717

1818
create(createDto: CreateSessionDto): Promise<SessionDocument> {
19-
const key = nanoid();
20-
const session = new this.sessionModel({ ...createDto, key });
19+
const { key: customKey, ...rest } = createDto;
20+
const key = customKey ?? nanoid();
21+
const session = new this.sessionModel({ ...rest, key });
2122
return session.save();
2223
}
2324

0 commit comments

Comments
 (0)