Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
W
Wenyuanwall Api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Wenyuanwall Api
Commits
23862051
Commit
23862051
authored
May 18, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new
parent
a9c2bb68
Pipeline
#36478
passed with stages
in 6 minutes and 9 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
166 additions
and
4 deletions
+166
-4
src/app.module.ts
src/app.module.ts
+16
-2
src/blacklist-account/blacklist-account.controller.ts
src/blacklist-account/blacklist-account.controller.ts
+2
-2
src/entities/whitelist-account.entity.ts
src/entities/whitelist-account.entity.ts
+77
-0
src/whitelist-account/whitelist-account.controller.spec.ts
src/whitelist-account/whitelist-account.controller.spec.ts
+18
-0
src/whitelist-account/whitelist-account.controller.ts
src/whitelist-account/whitelist-account.controller.ts
+18
-0
src/whitelist-account/whitelist-account.service.spec.ts
src/whitelist-account/whitelist-account.service.spec.ts
+18
-0
src/whitelist-account/whitelist-account.service.ts
src/whitelist-account/whitelist-account.service.ts
+17
-0
No files found.
src/app.module.ts
View file @
23862051
...
...
@@ -12,6 +12,9 @@ import { HttpModule } from '@nestjs/axios';
import
{
AdService
}
from
'
./ad/ad.service
'
;
import
{
AdController
}
from
'
./ad/ad.controller
'
;
import
{
Ad
}
from
'
./entities/ad.entity
'
;
import
{
WhitelistAccountService
}
from
'
./whitelist-account/whitelist-account.service
'
;
import
{
WhitelistAccountController
}
from
'
./whitelist-account/whitelist-account.controller
'
;
import
{
WhitelistAccount
}
from
'
./entities/whitelist-account.entity
'
;
@
Module
({
imports
:
[
...
...
@@ -25,11 +28,17 @@ import { Ad } from './entities/ad.entity';
inject
:
[
ConfigService
],
useFactory
:
async
(
config
:
ConfigService
)
=>
config
.
get
(
'
http
'
)
||
{},
}),
TypeOrmModule
.
forFeature
([
Blacklist
,
BlacklistAccount
,
Ad
,
WhitelistAccount
,
]),
TypeOrmModule
.
forRootAsync
({
inject
:
[
ConfigService
],
useFactory
:
async
(
config
:
ConfigService
)
=>
({
type
:
'
postgres
'
,
entities
:
[
Blacklist
,
BlacklistAccount
,
Ad
],
entities
:
[],
autoLoadEntities
:
true
,
synchronize
:
!
config
.
get
(
'
DB_NO_INIT
'
)
||
!!
config
.
get
(
'
REFETCH
'
),
dropSchema
:
!!
config
.
get
(
'
REFETCH
'
),
...
...
@@ -48,7 +57,12 @@ import { Ad } from './entities/ad.entity';
BlacklistService
,
FetchService
,
AdService
,
WhitelistAccountService
,
],
controllers
:
[
BlacklistAccountController
,
AdController
,
WhitelistAccountController
,
],
controllers
:
[
BlacklistAccountController
,
AdController
],
})
export
class
AppModule
{}
src/blacklist-account/blacklist-account.controller.ts
View file @
23862051
...
...
@@ -6,7 +6,7 @@ import { RestfulFactory } from 'nicot';
const
dec
=
new
RestfulFactory
(
BlacklistAccount
,
{
relations
:
[
'
blacklist
'
],
});
class
FindAllDto
extends
dec
.
findAllDto
{}
class
FindAll
BlacklistAccount
Dto
extends
dec
.
findAllDto
{}
@
Controller
(
'
blacklist
'
)
export
class
BlacklistAccountController
{
...
...
@@ -19,7 +19,7 @@ export class BlacklistAccountController {
'
Cache-Control
'
,
'
public, max-age=600, stale-while-revalidate=600, stale-if-error=604800
'
,
)
findAll
(@
dec
.
findAllParam
()
param
:
FindAllDto
)
{
findAll
(@
dec
.
findAllParam
()
param
:
FindAll
BlacklistAccount
Dto
)
{
return
this
.
blacklistAccountService
.
findAll
(
param
);
}
}
src/entities/whitelist-account.entity.ts
0 → 100644
View file @
23862051
import
{
BoolColumn
,
IdBase
,
NotQueryable
,
QueryColumn
,
QueryCondition
,
QueryEqual
,
RestfulFactory
,
StringColumn
,
}
from
'
nicot
'
;
import
{
Entity
,
Index
}
from
'
typeorm
'
;
@
Entity
()
export
class
WhitelistAccount
extends
IdBase
()
{
@
NotQueryable
()
@
StringColumn
(
255
,
{
required
:
true
,
description
:
'
name
'
,
})
name
:
string
;
@
Index
()
@
QueryEqual
()
@
StringColumn
(
11
,
{
required
:
true
,
description
:
'
QQ account number.
'
,
})
account
:
string
;
@
NotQueryable
()
@
StringColumn
(
255
,
{
description
:
'
Twitter ID
'
,
required
:
true
,
})
twitter
:
string
;
@
NotQueryable
()
@
StringColumn
(
255
,
{
description
:
'
Fee
'
,
})
fee
:
string
;
@
NotQueryable
()
@
StringColumn
(
255
,
{
description
:
'
type
'
,
})
type
:
string
;
@
NotQueryable
()
@
StringColumn
(
255
,
{
description
:
'
forbidden
'
,
})
forbidden
:
string
;
@
BoolColumn
({
description
:
'
false => not active
'
,
default
:
true
,
})
@
NotQueryable
()
enabled
:
boolean
;
@
QueryColumn
()
@
QueryCondition
((
obj
,
qb
,
entityName
,
key
)
=>
{
if
(
obj
[
key
]
===
1
)
{
qb
.
orderBy
(
'
RANDOM()
'
);
}
})
random
:
number
;
getRecordsPerPage
()
{
return
this
.
recordsPerPage
||
5
;
}
}
export
const
WhitelistAccountFactory
=
new
RestfulFactory
(
WhitelistAccount
,
{
relations
:
[],
});
src/whitelist-account/whitelist-account.controller.spec.ts
0 → 100644
View file @
23862051
import
{
Test
,
TestingModule
}
from
'
@nestjs/testing
'
;
import
{
WhitelistAccountController
}
from
'
./whitelist-account.controller
'
;
describe
(
'
WhitelistAccountController
'
,
()
=>
{
let
controller
:
WhitelistAccountController
;
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
controllers
:
[
WhitelistAccountController
],
}).
compile
();
controller
=
module
.
get
<
WhitelistAccountController
>
(
WhitelistAccountController
);
});
it
(
'
should be defined
'
,
()
=>
{
expect
(
controller
).
toBeDefined
();
});
});
src/whitelist-account/whitelist-account.controller.ts
0 → 100644
View file @
23862051
import
{
Controller
}
from
'
@nestjs/common
'
;
import
{
WhitelistAccountService
}
from
'
./whitelist-account.service
'
;
import
{
WhitelistAccountFactory
}
from
'
../entities/whitelist-account.entity
'
;
import
{
factory
}
from
'
ts-jest/dist/transformers/hoist-jest
'
;
class
FindWhitelistAccountDto
extends
WhitelistAccountFactory
.
findAllDto
{}
@
Controller
(
'
whitelist-account
'
)
export
class
WhitelistAccountController
{
constructor
(
private
service
:
WhitelistAccountService
)
{}
@
WhitelistAccountFactory
.
findAll
()
async
findAll
(
@
WhitelistAccountFactory
.
findAllParam
()
dto
:
FindWhitelistAccountDto
,
)
{
return
this
.
service
.
findAll
(
dto
);
}
}
src/whitelist-account/whitelist-account.service.spec.ts
0 → 100644
View file @
23862051
import
{
Test
,
TestingModule
}
from
'
@nestjs/testing
'
;
import
{
WhitelistAccountService
}
from
'
./whitelist-account.service
'
;
describe
(
'
WhitelistAccountService
'
,
()
=>
{
let
service
:
WhitelistAccountService
;
beforeEach
(
async
()
=>
{
const
module
:
TestingModule
=
await
Test
.
createTestingModule
({
providers
:
[
WhitelistAccountService
],
}).
compile
();
service
=
module
.
get
<
WhitelistAccountService
>
(
WhitelistAccountService
);
});
it
(
'
should be defined
'
,
()
=>
{
expect
(
service
).
toBeDefined
();
});
});
src/whitelist-account/whitelist-account.service.ts
0 → 100644
View file @
23862051
import
{
Injectable
}
from
'
@nestjs/common
'
;
import
{
WhitelistAccount
,
WhitelistAccountFactory
,
}
from
'
../entities/whitelist-account.entity
'
;
import
{
InjectRepository
}
from
'
@nestjs/typeorm
'
;
@
Injectable
()
export
class
WhitelistAccountService
extends
WhitelistAccountFactory
.
crudService
(
{
extraGetQuery
:
(
qb
)
=>
qb
.
andWhere
(
'
whitelistAccount.enabled = TRUE
'
),
},
)
{
constructor
(@
InjectRepository
(
WhitelistAccount
)
repo
)
{
super
(
repo
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment